diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 31f395281053..89e05ef4dc57 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "microsoft.dotnet.xharness.cli": { - "version": "1.0.0-prerelease.21576.2", + "version": "1.0.0-prerelease.21579.1", "commands": [ "xharness" ] diff --git a/docs/workflow/Codespaces.md b/docs/workflow/Codespaces.md index c116e4c0bf1b..391cd4087429 100644 --- a/docs/workflow/Codespaces.md +++ b/docs/workflow/Codespaces.md @@ -7,7 +7,16 @@ dotnet/runtime runs a nightly GitHub Action to build the latest code in the repo **NOTE**: In order to use a prebuilt codespace, when you create your machine be sure to select an **`8 core`** machine. -See https://docs.github.com/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace for instructions on how to create a new codespace. +1. From https://github.com/dotnet/runtime, drop-down the `Code` button and select the `Codespaces` tab. + +![New codespace button](https://docs.github.com/assets/images/help/codespaces/new-codespace-button.png) + +2. Select `8-core` for the Machine type. This will ensure you get a "pre built" image. + +![Codespace machine size](./codespace-machine-size.png) + + +*If these instructions are out of date, see https://docs.github.com/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace for instructions on how to create a new codespace.* ## Updating dotnet/runtime's Codespaces Configuration diff --git a/docs/workflow/codespace-machine-size.png b/docs/workflow/codespace-machine-size.png new file mode 100644 index 000000000000..07945fb9ff67 Binary files /dev/null and b/docs/workflow/codespace-machine-size.png differ diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 59725d50611b..08d3e1fa2a97 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,8 +1,8 @@ - + https://github.com/dotnet/icu - 65a1c6dbbc036610145cf5dfc67027c0efe9e79d + c454e00c63464ff6b599f23448bcc0a0c9fbac5f https://github.com/dotnet/msquic @@ -94,77 +94,77 @@ https://github.com/microsoft/vstest 140434f7109d357d0158ade9e5164a4861513965 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 - + https://github.com/dotnet/llvm-project - 2059b611a9a58c0bcb25ece23c65acce83503a37 + 2e69189f031e16ffb36167d89a658e14cbdba099 https://github.com/dotnet/runtime @@ -198,17 +198,17 @@ https://github.com/dotnet/runtime 9ede9a29128629ffde91b16efb51c9dd6ad7d0f7 - + https://github.com/dotnet/linker - f2dd65f51f6096f25e00e0d1e4c6af0e85d41865 + 42460a6b2cbed0d9c09e1c28fd3bb753bdc3f99f - + https://github.com/dotnet/xharness - e54a11149adba0d04c742b0465f77422af56c456 + ed75873fb3b4c0e8746bce1fb325bfb5061b9851 - + https://github.com/dotnet/xharness - e54a11149adba0d04c742b0465f77422af56c456 + ed75873fb3b4c0e8746bce1fb325bfb5061b9851 https://github.com/dotnet/arcade @@ -230,13 +230,13 @@ https://dev.azure.com/dnceng/internal/_git/dotnet-optimization 91d6b3c1f51888d166701510189505f35714665c - + https://github.com/dotnet/hotreload-utils - 652a6ae580fdbfd58b7622a17b5b75ec15ac36c8 + 49922f7ec53df036084899e597f3c94627d709eb - + https://github.com/dotnet/runtime-assets - 043b7a65a4319c412b1fe03b8a770be67aeedfc4 + 8784c859561193c0a91b2b47108113a9a7c40038 https://github.com/dotnet/roslyn-analyzers diff --git a/eng/Versions.props b/eng/Versions.props index 37534cec4a63..99655b401a8e 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -16,7 +16,6 @@ false release - true true false false @@ -52,8 +51,6 @@ 4.0.0-4.final 4.0.0-4.final 7.0.0-preview1.21572.6 - - 4.0.0-5.21453.15 2.0.0-alpha.1.21525.11 @@ -121,17 +118,17 @@ 4.5.0 7.0.0-alpha.1.21576.4 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 - 7.0.0-beta.21575.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 + 7.0.0-beta.21579.1 1.0.0-prerelease.21577.2 1.0.0-prerelease.21577.2 @@ -154,9 +151,9 @@ 1.0.1-prerelease-00006 16.9.0-preview-20201201-01 - 1.0.0-prerelease.21576.2 - 1.0.0-prerelease.21576.2 - 1.0.2-alpha.0.21574.2 + 1.0.0-prerelease.21579.1 + 1.0.0-prerelease.21579.1 + 1.0.2-alpha.0.21579.1 2.4.2-pre.9 2.4.2 1.3.0 @@ -169,21 +166,21 @@ 6.0.0-preview-20211019.1 - 7.0.100-1.21562.1 + 7.0.100-1.21601.1 $(MicrosoftNETILLinkTasksVersion) - 7.0.0-alpha.1.21565.1 + 7.0.0-alpha.1.21579.1 7.0.0-alpha.1.21529.3 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 - 11.1.0-alpha.1.21565.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 + 11.1.0-alpha.1.21579.1 7.0.0-alpha.1.21560.2 $(MicrosoftNETWorkloadEmscriptenManifest70100Version) diff --git a/eng/build.sh b/eng/build.sh index b7e30ebef5d9..f1ef5958fdbc 100755 --- a/eng/build.sh +++ b/eng/build.sh @@ -166,7 +166,7 @@ while [[ $# > 0 ]]; do opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")" if [[ $firstArgumentChecked -eq 0 && $opt =~ ^[a-zA-Z.+]+$ ]]; then - if [ $opt == "help" ]; then + if [[ "$opt" == "help" ]]; then showSubsetHelp exit 0 fi @@ -190,7 +190,7 @@ while [[ $# > 0 ]]; do exit 0 else passedSubset="$(echo "$2" | tr "[:upper:]" "[:lower:]")" - if [ $passedSubset == "help" ]; then + if [[ "$passedSubset" == "help" ]]; then showSubsetHelp exit 0 fi @@ -461,7 +461,7 @@ if [ ${#actInt[@]} -eq 0 ]; then arguments="-restore -build $arguments" fi -if [ "$os" = "Browser" ] && [ "$arch" != "wasm" ]; then +if [[ "$os" == "Browser" && "$arch" != "wasm" ]]; then # override default arch for Browser, we only support wasm arch=wasm fi diff --git a/eng/formatting/format.sh b/eng/formatting/format.sh index 5a9edf4c3399..eb4908c078c8 100644 --- a/eng/formatting/format.sh +++ b/eng/formatting/format.sh @@ -7,14 +7,14 @@ MANAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM "*.cs" "*.vb" | exec 1>&2 -if [[ -n "$NATIVE_FILES" ]]; then +if [ -n "$NATIVE_FILES" ]; then # Format all selected files echo "$NATIVE_FILES" | cat | xargs | sed -e 's/ /,/g' | xargs "./artifacts/tools/clang-format" -style=file -i # Add back the modified files to staging echo "$NATIVE_FILES" | xargs git add fi -if [[ -n "$MANAGED_FILES" ]]; then +if [ -n "$MANAGED_FILES" ]; then # Format all selected files echo "$MANAGED_FILES" | cat | xargs | sed -e 's/ /,/g' | dotnet format --include @@ -22,5 +22,4 @@ if [[ -n "$MANAGED_FILES" ]]; then echo "$MANAGED_FILES" | xargs git add fi - exit 0 diff --git a/eng/generators.targets b/eng/generators.targets index 528323672956..13926ce90bd7 100644 --- a/eng/generators.targets +++ b/eng/generators.targets @@ -34,11 +34,11 @@ and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DllImportGenerator'))"> - - - $(DefineConstants);DLLIMPORTGENERATOR_ENABLED diff --git a/eng/illink.targets b/eng/illink.targets index 6c2d95c84772..018075d8b660 100644 --- a/eng/illink.targets +++ b/eng/illink.targets @@ -236,6 +236,7 @@ $(ILLinkArgs) -b true $(ILLinkArgs) -x "$(ILLinkDescriptorsLibraryBuildXml)" + $(ILLinkArgs) --substitutions "$(ILLinkSubstitutionsLibraryBuildXml)" $(LinkerNoWarn);IL2067;IL2068;IL2069;IL2070;IL2071;IL2072;IL2073;IL2074;IL2075;IL2076;IL2077;IL2078;IL2079;IL2080;IL2081;IL2082;IL2083;IL2084;IL2085;IL2086;IL2087;IL2088;IL2089;IL2090;IL2091 $(ILLinkArgs) --nowarn $(LinkerNoWarn) + $(ILLinkArgs) --disable-opt ipconstprop diff --git a/eng/install-native-dependencies.sh b/eng/install-native-dependencies.sh index a29dfdf78aae..0b6a8a07abcc 100755 --- a/eng/install-native-dependencies.sh +++ b/eng/install-native-dependencies.sh @@ -22,7 +22,7 @@ if [ "$1" = "Linux" ]; then if [ "$?" != "0" ]; then exit 1; fi -elif [ "$1" = "MacCatalyst" ] || [ "$1" = "OSX" ] || [ "$1" = "tvOS" ] || [ "$1" = "iOS" ]; then +elif [[ "$1" == "MacCatalyst" || "$1" == "OSX" || "$1" == "tvOS" || "$1" == "iOS" ]]; then engdir=$(dirname "${BASH_SOURCE[0]}") echo "Installed xcode version: `xcode-select -p`" diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh index 608d06e81eda..4aebd45649a0 100755 --- a/eng/native/build-commons.sh +++ b/eng/native/build-commons.sh @@ -454,7 +454,7 @@ if [[ "$__CrossBuild" == 1 ]]; then CROSSCOMPILE=1 export CROSSCOMPILE # Darwin that doesn't use rootfs - if [[ ! -n "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then + if [[ -z "$ROOTFS_DIR" && "$platform" != "Darwin" ]]; then ROOTFS_DIR="$__RepoRootDir/.tools/rootfs/$__BuildArch" export ROOTFS_DIR fi diff --git a/eng/native/init-distro-rid.sh b/eng/native/init-distro-rid.sh index 5f6b19460012..97fd64708163 100644 --- a/eng/native/init-distro-rid.sh +++ b/eng/native/init-distro-rid.sh @@ -41,7 +41,7 @@ initNonPortableDistroRid() # We have forced __PortableBuild=0. This is because -portablebuld # has been passed as false. if (( isPortable == 0 )); then - if [ "${ID}" = "rhel" ] || [ "${ID}" = "rocky" ]; then + if [[ "${ID}" == "rhel" || "${ID}" == "rocky" ]]; then # remove the last version digit VERSION_ID="${VERSION_ID%.*}" fi diff --git a/eng/pipelines/evaluate-changed-paths.sh b/eng/pipelines/evaluate-changed-paths.sh index 76bc06d52801..ee9ae31a3363 100755 --- a/eng/pipelines/evaluate-changed-paths.sh +++ b/eng/pipelines/evaluate-changed-paths.sh @@ -141,7 +141,7 @@ probePaths() { echo "******* Probing $_subset exclude paths *******"; for _path in "${exclude_paths[@]}"; do echo "$_path" - if [[ "$exclude_path_string" == "" ]]; then + if [[ -z "$exclude_path_string" ]]; then exclude_path_string=":!$_path" else exclude_path_string="$exclude_path_string :!$_path" @@ -159,7 +159,7 @@ probePaths() { echo "******* Probing $_subset include paths *******"; for _path in "${include_paths[@]}"; do echo "$_path" - if [[ "$include_path_string" == "" ]]; then + if [[ -z "$include_path_string" ]]; then include_path_string=":$_path" else include_path_string="$include_path_string :$_path" diff --git a/eng/run-test.sh b/eng/run-test.sh index e5cf6a3b21d1..64474cc435af 100644 --- a/eng/run-test.sh +++ b/eng/run-test.sh @@ -236,26 +236,22 @@ done # Compute paths to the binaries if they haven't already been computed -if [ -z "$Runtime" ] -then +if [[ -z "$Runtime" ]]; then Runtime="$ProjectRoot/artifacts/bin/testhost/netcoreapp-$OS-$Configuration-$__Arch" fi -if [ -z "$CoreFxTests" ] -then +if [[ -z "$CoreFxTests" ]]; then CoreFxTests="$ProjectRoot/artifacts/bin" fi # Check parameters up front for valid values: -if [ "$Configuration" != "Debug" ] && [ "$Configuration" != "Release" ] -then +if [[ "$Configuration" != "Debug" && "$Configuration" != "Release" ]]; then echo "error: Configuration should be Debug or Release" exit 1 fi -if [ "$OS" != "FreeBSD" ] && [ "$OS" != "Linux" ] && [ "$OS" != "NetBSD" ] && [ "$OS" != "illumos" ] && [ "$OS" != "Solaris" ] -then +if [[ "$OS" != "FreeBSD" && "$OS" != "Linux" && "$OS" != "NetBSD" && "$OS" != "illumos" && "$OS" != "Solaris" ]]; then echo "error: OS should be FreeBSD, Linux, NetBSD or Linux" exit 1 fi @@ -263,8 +259,7 @@ fi export CORECLR_SERVER_GC="$serverGC" export PAL_OUTPUTDEBUGSTRING="1" -if [ -z "$LANG" ] -then +if [[ -z "$LANG" ]]; then export LANG="en_US.UTF-8" fi @@ -281,29 +276,26 @@ ensure_binaries_are_present TestsFailed=0 numberOfProcesses=0 -if [ $RunTestSequential -eq 1 ] -then +if [[ $RunTestSequential -eq 1 ]]; then maxProcesses=1; else platform="$(uname)" - if [ "$platform" = "FreeBSD" ]; then + if [[ "$platform" == "FreeBSD" ]]; then maxProcesses=$(($(sysctl -n hw.ncpu)+1)) - if [ "$platform" = "NetBSD" ] || [ "$platform" = "SunOS" ] ; then + if [[ "$platform" == "NetBSD" || "$platform" == "SunOS" ]]; then maxProcesses=$(($(getconf NPROCESSORS_ONLN)+1)) else maxProcesses=$(($(getconf _NPROCESSORS_ONLN)+1)) fi fi -if [ -n "$TestDirFile" ] || [ -n "$TestDir" ] -then +if [[ -n "$TestDirFile" || -n "$TestDir" ]]; then run_selected_tests else run_all_tests "$CoreFxTests/tests/"*.Tests fi -if [ "$TestsFailed" -gt 0 ] -then +if [[ "$TestsFailed" -gt 0 ]]; then echo "$TestsFailed test(s) failed" else echo "All tests passed." diff --git a/eng/testing/AndroidRunnerTemplate.sh b/eng/testing/AndroidRunnerTemplate.sh index 3dab96f0bf3c..d981d240c816 100644 --- a/eng/testing/AndroidRunnerTemplate.sh +++ b/eng/testing/AndroidRunnerTemplate.sh @@ -9,7 +9,7 @@ TARGET_OS=$3 TEST_NAME=$4 XHARNESS_OUT="$EXECUTION_DIR/xharness-output" -if [ -n "$5" ]; then +if [[ -n "$5" ]]; then ADDITIONAL_ARGS=${@:5} fi @@ -27,7 +27,7 @@ while true; do fi done -if [ ! -z "$XHARNESS_CLI_PATH" ]; then +if [[ -n "$XHARNESS_CLI_PATH" ]]; then # Allow overriding the path to the XHarness CLI DLL, # we need to call it directly via dotnet exec HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" diff --git a/eng/testing/AppleRunnerTemplate.sh b/eng/testing/AppleRunnerTemplate.sh index 0ebff54c4839..8f66672f739e 100644 --- a/eng/testing/AppleRunnerTemplate.sh +++ b/eng/testing/AppleRunnerTemplate.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env bash # NOTE: this script is only used locally, on CI we use the Helix SDK from arcade @@ -54,7 +54,7 @@ while true; do fi done -if [ ! -z "$XHARNESS_CLI_PATH" ]; then +if [[ -n "$XHARNESS_CLI_PATH" ]]; then # Allow overriding the path to the XHarness CLI DLL, # we need to call it directly via dotnet exec HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" diff --git a/eng/testing/RunnerTemplate.sh b/eng/testing/RunnerTemplate.sh index 4770323fdc9c..bfaa743ef6f4 100644 --- a/eng/testing/RunnerTemplate.sh +++ b/eng/testing/RunnerTemplate.sh @@ -39,7 +39,7 @@ while [[ $# > 0 ]]; do shift done -if [ "$RUNTIME_PATH" == "" ]; then +if [[ -z "$RUNTIME_PATH" ]]; then echo "error: -r|--runtime-path argument is required." usage exit -1 @@ -127,7 +127,7 @@ function copy_core_file_to_temp_location { } # ========================= BEGIN Core File Setup ============================ -if [ "$(uname -s)" == "Darwin" ]; then +if [[ "$(uname -s)" == "Darwin" ]]; then # On OS X, we will enable core dump generation only if there are no core # files already in /cores/ at this point. This is being done to prevent # inadvertently flooding the CI machines with dumps. @@ -135,7 +135,7 @@ if [ "$(uname -s)" == "Darwin" ]; then ulimit -c unlimited fi -elif [ "$(uname -s)" == "Linux" ]; then +elif [[ "$(uname -s)" == "Linux" ]]; then # On Linux, we'll enable core file generation unconditionally, and if a dump # is generated, we will print some useful information from it and delete the # dump immediately. @@ -163,7 +163,7 @@ test_exitcode=$? popd echo ----- end $(date) ----- exit code $test_exitcode ---------------------------------------------------------- -if [ "${exitcode_list[$test_exitcode]}" != "" ]; then +if [[ -n "${exitcode_list[$test_exitcode]}" ]]; then echo exit code $test_exitcode means ${exitcode_list[$test_exitcode]} fi # ========================= END Test Execution =============================== @@ -200,11 +200,11 @@ if [[ "$(uname -s)" == "Linux" && $test_exitcode -ne 0 ]]; then # or "core." by default. We read /proc/sys/kernel/core_uses_pid to # determine which it is. core_name_uses_pid=0 - if [ -e /proc/sys/kernel/core_uses_pid ] && [ "1" == $(cat /proc/sys/kernel/core_uses_pid) ]; then + if [[ -e /proc/sys/kernel/core_uses_pid && "1" == $(cat /proc/sys/kernel/core_uses_pid) ]]; then core_name_uses_pid=1 fi - if [ $core_name_uses_pid == "1" ]; then + if [[ "$core_name_uses_pid" == "1" ]]; then # We don't know what the PID of the process was, so let's look at all core # files whose name matches core.NUMBER echo Looking for files matching core.* ... @@ -224,7 +224,7 @@ popd >/dev/null # ======================== END Core File Inspection ========================== # The helix work item should not exit with non-zero if tests ran and produced results # The special console runner for runtime returns 1 when tests fail -if [ "$test_exitcode" == "1" ]; then +if [[ "$test_exitcode" == "1" ]]; then if [ -n "$HELIX_WORKITEM_PAYLOAD" ]; then exit 0 fi diff --git a/eng/testing/WasmRunnerAOTTemplate.sh b/eng/testing/WasmRunnerAOTTemplate.sh index af3e499f457c..4aa271b960a5 100644 --- a/eng/testing/WasmRunnerAOTTemplate.sh +++ b/eng/testing/WasmRunnerAOTTemplate.sh @@ -11,7 +11,7 @@ else XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" fi -if [ ! -z "$XHARNESS_CLI_PATH" ]; then +if [[ -n "$XHARNESS_CLI_PATH" ]]; then # When running in CI, we only have the .NET runtime available # We need to call the XHarness CLI DLL directly via dotnet exec HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" @@ -19,7 +19,7 @@ else HARNESS_RUNNER="dotnet xharness" fi -if [ "$SCENARIO" == "WasmTestOnBrowser" ]; then +if [[ "$SCENARIO" == "WasmTestOnBrowser" ]]; then XHARNESS_COMMAND="test-browser" elif [ -z "$XHARNESS_COMMAND" ]; then XHARNESS_COMMAND="test" diff --git a/eng/testing/WasmRunnerTemplate.sh b/eng/testing/WasmRunnerTemplate.sh index 8997e222177c..412c33724aa1 100644 --- a/eng/testing/WasmRunnerTemplate.sh +++ b/eng/testing/WasmRunnerTemplate.sh @@ -5,13 +5,13 @@ SCENARIO=$3 cd $EXECUTION_DIR -if [ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]; then +if [[ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then XHARNESS_OUT="$EXECUTION_DIR/xharness-output" else XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" fi -if [ ! -z "$XHARNESS_CLI_PATH" ]; then +if [[ -n "$XHARNESS_CLI_PATH" ]]; then # When running in CI, we only have the .NET runtime available # We need to call the XHarness CLI DLL directly via dotnet exec HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" @@ -19,9 +19,9 @@ else HARNESS_RUNNER="dotnet xharness" fi -if [ "$SCENARIO" == "WasmTestOnBrowser" ]; then +if [[ "$SCENARIO" == "WasmTestOnBrowser" ]]; then XHARNESS_COMMAND="test-browser" -elif [ -z "$XHARNESS_COMMAND" ]; then +elif [[ -z "$XHARNESS_COMMAND" ]]; then XHARNESS_COMMAND="test" fi diff --git a/eng/testing/performance/performance-setup.sh b/eng/testing/performance/performance-setup.sh index cffd9ca8d6cd..b58a031bac3c 100755 --- a/eng/testing/performance/performance-setup.sh +++ b/eng/testing/performance/performance-setup.sh @@ -162,7 +162,7 @@ while (($# > 0)); do echo " --internal If the benchmarks are running as an official job." echo " --monodotnet Pass the path to the mono dotnet for mono performance testing." echo " --wasm Path to the unpacked wasm runtime pack." - echo " --wasmaot Indicate wasm aot" + echo " --wasmaot Indicate wasm aot" echo " --latestdotnet --dotnet-versions will not be specified. --dotnet-versions defaults to LKG version in global.json " echo " --alpine Set for runs on Alpine" echo "" @@ -171,7 +171,7 @@ while (($# > 0)); do esac done -if [ "$repository" == "dotnet/performance" ] || [ "$repository" == "dotnet-performance" ]; then +if [[ "$repository" == "dotnet/performance" || "$repository" == "dotnet-performance" ]]; then run_from_perf_repo=true fi @@ -202,38 +202,38 @@ if [[ "$internal" == true ]]; then helix_source_prefix="official" creator= extra_benchmark_dotnet_arguments= - - if [[ "$architecture" = "arm64" ]]; then + + if [[ "$architecture" == "arm64" ]]; then queue=Ubuntu.1804.Arm64.Perf else - if [[ "$logical_machine" = "perfowl" ]]; then + if [[ "$logical_machine" == "perfowl" ]]; then queue=Ubuntu.1804.Amd64.Owl.Perf else queue=Ubuntu.1804.Amd64.Tiger.Perf fi fi - if [[ "$alpine" = "true" ]]; then + if [[ "$alpine" == "true" ]]; then queue=alpine.amd64.tiger.perf fi else - if [[ "$architecture" = "arm64" ]]; then + if [[ "$architecture" == "arm64" ]]; then queue=ubuntu.1804.armarch.open else queue=Ubuntu.1804.Amd64.Open fi - if [[ "$alpine" = "true" ]]; then + if [[ "$alpine" == "true" ]]; then queue=alpine.amd64.tiger.perf fi fi -if [[ "$mono_dotnet" != "" ]] && [[ "$monointerpreter" == "false" ]]; then +if [[ -n "$mono_dotnet" && "$monointerpreter" == "false" ]]; then configurations="$configurations LLVM=$llvm MonoInterpreter=$monointerpreter MonoAOT=$monoaot" extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --category-exclusion-filter NoMono" fi -if [[ "$wasm_runtime_loc" != "" ]]; then +if [[ -n "$wasm_runtime_loc" ]]; then if [[ "$wasmaot" == "true" ]]; then configurations="CompilationMode=wasm AOT=true RunKind=$kind" else @@ -245,7 +245,7 @@ if [[ "$wasm_runtime_loc" != "" ]]; then extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --category-exclusion-filter NoInterpreter NoWASM NoMono" fi -if [[ "$mono_dotnet" != "" ]] && [[ "$monointerpreter" == "true" ]]; then +if [[ -n "$mono_dotnet" && "$monointerpreter" == "true" ]]; then configurations="$configurations LLVM=$llvm MonoInterpreter=$monointerpreter MonoAOT=$monoaot" extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --category-exclusion-filter NoInterpreter NoMono" fi @@ -262,7 +262,7 @@ fi common_setup_arguments="--channel $cleaned_branch_name --queue $queue --build-number $build_number --build-configs $configurations --architecture $architecture" setup_arguments="--repository https://github.com/$repository --branch $branch --get-perf-hash --commit-sha $commit_sha $common_setup_arguments" -if [[ "$run_from_perf_repo" = true ]]; then +if [[ "$run_from_perf_repo" == true ]]; then payload_directory= workitem_directory=$source_directory performance_directory=$workitem_directory @@ -276,7 +276,7 @@ else mv $docs_directory $workitem_directory fi -if [[ "$wasm_runtime_loc" != "" ]]; then +if [[ -n "$wasm_runtime_loc" ]]; then using_wasm=true wasm_dotnet_path=$payload_directory/dotnet-wasm mv $wasm_runtime_loc $wasm_dotnet_path @@ -291,13 +291,13 @@ if [[ "$wasm_runtime_loc" != "" ]]; then rsync -a --progress $wasm_dotnet_path/artifacts/BrowserWasm/artifacts/* $wasm_dotnet_path/artifacts rm -r $wasm_dotnet_path/artifacts/BrowserWasm/artifacts if [[ "$wasmaot" == "true" ]]; then - extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --wasmEngine /home/helixbot/.jsvu/$javascript_engine --runtimeSrcDir \$HELIX_CORRELATION_PAYLOAD/dotnet-wasm --aotcompilermode wasm --buildTimeout 3600" + extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --wasmEngine /home/helixbot/.jsvu/$javascript_engine --runtimeSrcDir \$HELIX_CORRELATION_PAYLOAD/dotnet-wasm --aotcompilermode wasm --buildTimeout 3600" else extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --wasmEngine /home/helixbot/.jsvu/$javascript_engine --runtimeSrcDir \$HELIX_CORRELATION_PAYLOAD/dotnet-wasm" fi fi -if [[ "$mono_dotnet" != "" ]] && [[ "$monoaot" == "false" ]]; then +if [[ -n "$mono_dotnet" && "$monoaot" == "false" ]]; then using_mono=true mono_dotnet_path=$payload_directory/dotnet-mono mv $mono_dotnet $mono_dotnet_path @@ -309,12 +309,12 @@ if [[ "$monoaot" == "true" ]]; then extra_benchmark_dotnet_arguments="$extra_benchmark_dotnet_arguments --runtimes monoaotllvm --aotcompilerpath \$HELIX_CORRELATION_PAYLOAD/monoaot/sgen/mini/mono-sgen --customruntimepack \$HELIX_CORRELATION_PAYLOAD/monoaot/pack --aotcompilermode llvm" fi -if [[ "$use_core_run" = true ]]; then +if [[ "$use_core_run" == true ]]; then new_core_root=$payload_directory/Core_Root mv $core_root_directory $new_core_root fi -if [[ "$use_baseline_core_run" = true ]]; then +if [[ "$use_baseline_core_run" == true ]]; then new_baseline_core_root=$payload_directory/Baseline_Core_Root mv $baseline_core_root_directory $new_baseline_core_root fi diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h index 056904894d1f..bb756ea72246 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -144,7 +144,6 @@ LWM(IsDelegateCreationAllowed, DLDL, DWORD) LWM(IsFieldStatic, DWORDLONG, DWORD) LWM(IsIntrinsicType, DWORDLONG, DWORD) LWM(IsSDArray, DWORDLONG, DWORD) -LWM(IsStructRequiringStackAllocRetBuf, DWORDLONG, DWORD) LWM(IsValidStringRef, DLD, DWORD) LWM(GetStringLiteral, DLD, DD) LWM(IsValidToken, DLD, DWORD) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index b9195e4bbd1d..fc62daa4406e 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -1813,29 +1813,6 @@ bool MethodContext::repIsValueClass(CORINFO_CLASS_HANDLE cls) return value != 0; } -void MethodContext::recIsStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls, bool result) -{ - if (IsStructRequiringStackAllocRetBuf == nullptr) - IsStructRequiringStackAllocRetBuf = new LightWeightMap(); - - DWORDLONG key = CastHandle(cls); - DWORD value = result ? 1 : 0; - IsStructRequiringStackAllocRetBuf->Add(key, value); - DEBUG_REC(dmpIsStructRequiringStackAllocRetBuf(key, value)); -} -void MethodContext::dmpIsStructRequiringStackAllocRetBuf(DWORDLONG key, DWORD value) -{ - printf("IsStructRequiringStackAllocRetBuf key cls-%016llX, value res-%u", key, value); -} -bool MethodContext::repIsStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) -{ - DWORDLONG key = CastHandle(cls); - AssertMapAndKeyExist(IsStructRequiringStackAllocRetBuf, key, ": key %016llX", key); - DWORD value = IsStructRequiringStackAllocRetBuf->Get(key); - DEBUG_REP(dmpIsStructRequiringStackAllocRetBuf(key, value)); - return value != 0; -} - void MethodContext::recGetClassSize(CORINFO_CLASS_HANDLE cls, unsigned result) { if (GetClassSize == nullptr) diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h index f1b8e405761d..6e7c910f16d5 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -237,10 +237,6 @@ class MethodContext void dmpIsValueClass(DWORDLONG key, DWORD value); bool repIsValueClass(CORINFO_CLASS_HANDLE cls); - void recIsStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls, bool result); - void dmpIsStructRequiringStackAllocRetBuf(DWORDLONG key, DWORD value); - bool repIsStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls); - void recGetClassSize(CORINFO_CLASS_HANDLE cls, unsigned result); void dmpGetClassSize(DWORDLONG key, DWORD val); unsigned repGetClassSize(CORINFO_CLASS_HANDLE cls); @@ -1009,7 +1005,7 @@ enum mcPackets Packet_IsCompatibleDelegate = 99, //Packet_IsInstantiationOfVerifiedGeneric = 100, Packet_IsSDArray = 101, - Packet_IsStructRequiringStackAllocRetBuf = 102, + //Packet_IsStructRequiringStackAllocRetBuf = 102, Packet_IsValidStringRef = 103, //Retired6 = 104, Packet_IsValueClass = 105, diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shared/spmiutil.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shared/spmiutil.cpp index a494c2939f8f..4d21d7d2d564 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shared/spmiutil.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shared/spmiutil.cpp @@ -158,8 +158,18 @@ void ReplaceIllegalCharacters(WCHAR* fileName) *quote = W(' '); } + // Convert non-ASCII to ASCII for simplicity. + for (quote = fileName; *quote != '\0'; quote++) + { + WCHAR ch = *quote; + if ((ch <= 32) || (ch >= 127)) // Only allow textual ASCII characters + { + *quote = W('_'); + } + } + // Remove any illegal or annoying characters from the file name by converting them to underscores. - while ((quote = wcspbrk(fileName, W("=<>:\"/\\|?! *.,"))) != nullptr) + while ((quote = wcspbrk(fileName, W("()=<>:\"/\\|?! *.,"))) != nullptr) { *quote = W('_'); } @@ -172,7 +182,6 @@ WCHAR* GetResultFileName(const WCHAR* folderPath, const WCHAR* fileName, const W const size_t fileNameLength = wcslen(fileName); const size_t randomStringLength = 8; const size_t maxPathLength = MAX_PATH - 50; - bool appendRandomString = false; // See how long the folder part is, and start building the file path with the folder part. // @@ -201,31 +210,8 @@ WCHAR* GetResultFileName(const WCHAR* folderPath, const WCHAR* fileName, const W // Now figure out the file name part. // const size_t maxFileNameLength = maxPathLength - fullPathLength; - size_t usableFileNameLength = 0; - - if (fileNameLength == 0) - { - // No file name provided. Use random string. - // - fullPathLength += randomStringLength; - appendRandomString = true; - } - else if (fileNameLength < maxFileNameLength) - { - // Reasonable length file name, use as is. - // - usableFileNameLength = fileNameLength; - fullPathLength += fileNameLength; - appendRandomString = false; - } - else - { - // Overly long file name, truncate and add random string. - // - usableFileNameLength = maxFileNameLength - randomStringLength; - fullPathLength += maxFileNameLength; - appendRandomString = true; - } + size_t usableFileNameLength = min(fileNameLength, maxFileNameLength - randomStringLength); + fullPathLength += usableFileNameLength + randomStringLength; // Append the file name part // @@ -236,22 +222,19 @@ WCHAR* GetResultFileName(const WCHAR* folderPath, const WCHAR* fileName, const W // ReplaceIllegalCharacters(fullPath + folderPathLength + 1); - // Append random string, if we're using it. + // Append a random string to improve uniqueness. // - if (appendRandomString) - { - unsigned randomNumber = 0; + unsigned randomNumber = 0; #ifdef TARGET_UNIX - PAL_Random(&randomNumber, sizeof(randomNumber)); + PAL_Random(&randomNumber, sizeof(randomNumber)); #else // !TARGET_UNIX - rand_s(&randomNumber); + rand_s(&randomNumber); #endif // !TARGET_UNIX - WCHAR randomString[randomStringLength + 1]; - swprintf_s(randomString, randomStringLength + 1, W("%08X"), randomNumber); - wcsncat_s(fullPath, fullPathLength + 1, randomString, randomStringLength); - } + WCHAR randomString[randomStringLength + 1]; + swprintf_s(randomString, randomStringLength + 1, W("%08X"), randomNumber); + wcsncat_s(fullPath, fullPathLength + 1, randomString, randomStringLength); // Append extension // diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index 0d0acb208b41..ef1afc408aff 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -550,20 +550,6 @@ uint32_t interceptor_ICJI::getClassAttribs(CORINFO_CLASS_HANDLE cls) return temp; } -// Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value -// of this type must be stack-allocated. This will generally be true only if the struct -// contains GC pointers, and does not exceed some size limit. Maintaining this as an invariant allows -// an optimization: the JIT may assume that return buffer pointers for return types for which this predicate -// returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return -// buffers do not require GC write barriers. -bool interceptor_ICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) -{ - mc->cr->AddCall("isStructRequiringStackAllocRetBuf"); - bool temp = original_ICorJitInfo->isStructRequiringStackAllocRetBuf(cls); - mc->recIsStructRequiringStackAllocRetBuf(cls, temp); - return temp; -} - CORINFO_MODULE_HANDLE interceptor_ICJI::getClassModule(CORINFO_CLASS_HANDLE cls) { mc->cr->AddCall("getClassModule"); diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 94325c48f208..60ba9a998d55 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -378,13 +378,6 @@ uint32_t interceptor_ICJI::getClassAttribs( return original_ICorJitInfo->getClassAttribs(cls); } -bool interceptor_ICJI::isStructRequiringStackAllocRetBuf( - CORINFO_CLASS_HANDLE cls) -{ - mcs->AddCall("isStructRequiringStackAllocRetBuf"); - return original_ICorJitInfo->isStructRequiringStackAllocRetBuf(cls); -} - CORINFO_MODULE_HANDLE interceptor_ICJI::getClassModule( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index a06ac0857ce3..0c01d60937d6 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -333,12 +333,6 @@ uint32_t interceptor_ICJI::getClassAttribs( return original_ICorJitInfo->getClassAttribs(cls); } -bool interceptor_ICJI::isStructRequiringStackAllocRetBuf( - CORINFO_CLASS_HANDLE cls) -{ - return original_ICorJitInfo->isStructRequiringStackAllocRetBuf(cls); -} - CORINFO_MODULE_HANDLE interceptor_ICJI::getClassModule( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 29ed9e03df36..ab34fb4623da 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -482,18 +482,6 @@ uint32_t MyICJI::getClassAttribs(CORINFO_CLASS_HANDLE cls) return jitInstance->mc->repGetClassAttribs(cls); } -// Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value -// of this type must be stack-allocated. This will generally be true only if the struct -// contains GC pointers, and does not exceed some size limit. Maintaining this as an invariant allows -// an optimization: the JIT may assume that return buffer pointers for return types for which this predicate -// returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return -// buffers do not require GC write barriers. -bool MyICJI::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) -{ - jitInstance->mc->cr->AddCall("isStructRequiringStackAllocRetBuf"); - return jitInstance->mc->repIsStructRequiringStackAllocRetBuf(cls); -} - CORINFO_MODULE_HANDLE MyICJI::getClassModule(CORINFO_CLASS_HANDLE cls) { jitInstance->mc->cr->AddCall("getClassModule"); diff --git a/src/coreclr/enablesanitizers.sh b/src/coreclr/enablesanitizers.sh index 63a1e02ba09a..c79ef8c69ddf 100755 --- a/src/coreclr/enablesanitizers.sh +++ b/src/coreclr/enablesanitizers.sh @@ -79,7 +79,7 @@ else esac done - if [ $__TurnOff == 1 ]; then + if [[ "$__TurnOff" == 1 ]]; then unset DEBUG_SANITIZERS echo "Setting DEBUG_SANITIZERS=" else @@ -89,13 +89,13 @@ else # when Clang 3.8 available, add: suppressions=$(readlink -f sanitizersuppressions.txt) UBSAN_OPTIONS="print_stacktrace=1" - if [ $__EnableASan == 1 ]; then + if [[ "$__EnableASan" == 1 ]]; then __Options="$__Options asan" fi - if [ $__EnableUBSan == 1 ]; then + if [[ "$__EnableUBSan" == 1 ]]; then __Options="$__Options ubsan" fi - if [ $__EnableLSan == 1 ]; then + if [[ "$__EnableLSan" == 1 ]]; then ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=1" else ASAN_OPTIONS="$ASAN_OPTIONS detect_leaks=0" @@ -115,7 +115,7 @@ else # for compiler-rt > 3.6 Asan check that binary name is 'llvm-symbolizer', 'addr2line' or # 'atos' (for Darwin) otherwise it returns error - if [ $__ExportSymbolizerPath == 1 ]; then + if [[ "$__ExportSymbolizerPath" == 1 ]]; then # used by ASan at run-time ASAN_SYMBOLIZER_PATH="/usr/bin/llvm-symbolizer-$__ClangMajorVersion.$__ClangMinorVersion" export ASAN_SYMBOLIZER_PATH diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index 0003a9f75c81..4cc0c44b83c1 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -472,7 +472,6 @@ enum CorInfoHelpFunc CORINFO_HELP_GETFIELDADDR, - CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT, // Helper for context-static fields CORINFO_HELP_GETSTATICFIELDADDR_TLS, // Helper for PE TLS fields // There are a variety of specialized helpers for accessing static fields. The JIT should use @@ -886,7 +885,6 @@ enum CorInfoIntrinsics CORINFO_INTRINSIC_Array_Get, // Get the value of an element in an array CORINFO_INTRINSIC_Array_Address, // Get the address of an element in an array CORINFO_INTRINSIC_Array_Set, // Set the value of an element in an array - CORINFO_INTRINSIC_InitializeArray, // initialize an array from static data CORINFO_INTRINSIC_RTH_GetValueInternal, CORINFO_INTRINSIC_Object_GetType, CORINFO_INTRINSIC_StubHelpers_GetStubContext, @@ -2302,14 +2300,6 @@ class ICorStaticInfo CORINFO_CLASS_HANDLE cls ) = 0; - // Returns "TRUE" iff "cls" is a struct type such that return buffers used for returning a value - // of this type must be stack-allocated. This will generally be true only if the struct - // contains GC pointers, and does not exceed some size limit. Maintaining this as an invariant allows - // an optimization: the JIT may assume that return buffer pointers for return types for which this predicate - // returns TRUE are always stack allocated, and thus, that stores to the GC-pointer fields of such return - // buffers do not require GC write barriers. - virtual bool isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) = 0; - virtual CORINFO_MODULE_HANDLE getClassModule ( CORINFO_CLASS_HANDLE cls ) = 0; diff --git a/src/coreclr/inc/icorjitinfoimpl_generated.h b/src/coreclr/inc/icorjitinfoimpl_generated.h index 4cb3e3f012d9..da724e75da60 100644 --- a/src/coreclr/inc/icorjitinfoimpl_generated.h +++ b/src/coreclr/inc/icorjitinfoimpl_generated.h @@ -207,9 +207,6 @@ CorInfoInlineTypeCheck canInlineTypeCheck( uint32_t getClassAttribs( CORINFO_CLASS_HANDLE cls) override; -bool isStructRequiringStackAllocRetBuf( - CORINFO_CLASS_HANDLE cls) override; - CORINFO_MODULE_HANDLE getClassModule( CORINFO_CLASS_HANDLE cls) override; diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index ea71b2ad61e8..b51f56b2df5c 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID; #define GUID_DEFINED #endif // !GUID_DEFINED -constexpr GUID JITEEVersionIdentifier = { /* 3df3e3ec-b1f6-4e6d-8439-2e7f3f7fa2ac */ - 0x3df3e3ec, - 0xb1f6, - 0x4e6d, - {0x84, 0x39, 0x2e, 0x7f, 0x3f, 0x7f, 0xa2, 0xac} +constexpr GUID JITEEVersionIdentifier = { /* 0c6f2d8d-f1b7-4c28-bbe8-36c8f6b35fbf */ + 0xc6f2d8d, + 0xf1b7, + 0x4c28, + { 0xbb, 0xe8, 0x36, 0xc8, 0xf6, 0xb3, 0x5f, 0xbf} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/coreclr/inc/jithelpers.h b/src/coreclr/inc/jithelpers.h index b15d770e6728..4d1fc11f0e8c 100644 --- a/src/coreclr/inc/jithelpers.h +++ b/src/coreclr/inc/jithelpers.h @@ -173,7 +173,6 @@ JITHELPER(CORINFO_HELP_GETFIELDADDR, JIT_GetFieldAddr,CORINFO_HELP_SIG_REG_ONLY) - JITHELPER(CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) JITHELPER(CORINFO_HELP_GETSTATICFIELDADDR_TLS, NULL, CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB) JITHELPER(CORINFO_HELP_GETGENERICS_GCSTATIC_BASE, JIT_GetGenericsGCStaticBase,CORINFO_HELP_SIG_REG_ONLY) diff --git a/src/coreclr/jit/ICorJitInfo_API_names.h b/src/coreclr/jit/ICorJitInfo_API_names.h index 39e74fc1949f..64e8db858b94 100644 --- a/src/coreclr/jit/ICorJitInfo_API_names.h +++ b/src/coreclr/jit/ICorJitInfo_API_names.h @@ -49,7 +49,6 @@ DEF_CLR_API(appendClassName) DEF_CLR_API(isValueClass) DEF_CLR_API(canInlineTypeCheck) DEF_CLR_API(getClassAttribs) -DEF_CLR_API(isStructRequiringStackAllocRetBuf) DEF_CLR_API(getClassModule) DEF_CLR_API(getModuleAssembly) DEF_CLR_API(getAssemblyName) diff --git a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp index 0fade44a4fef..9f51c43b765e 100644 --- a/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp +++ b/src/coreclr/jit/ICorJitInfo_API_wrapper.hpp @@ -455,15 +455,6 @@ uint32_t WrapICorJitInfo::getClassAttribs( return temp; } -bool WrapICorJitInfo::isStructRequiringStackAllocRetBuf( - CORINFO_CLASS_HANDLE cls) -{ - API_ENTER(isStructRequiringStackAllocRetBuf); - bool temp = wrapHnd->isStructRequiringStackAllocRetBuf(cls); - API_LEAVE(isStructRequiringStackAllocRetBuf); - return temp; -} - CORINFO_MODULE_HANDLE WrapICorJitInfo::getClassModule( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index 9d94d92c6640..4472d573b0c9 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -774,7 +774,7 @@ bool BasicBlock::CloneBlockState( for (Statement* const fromStmt : from->Statements()) { - auto newExpr = compiler->gtCloneExpr(fromStmt->GetRootNode(), GTF_EMPTY, varNum, varVal); + GenTree* newExpr = compiler->gtCloneExpr(fromStmt->GetRootNode(), GTF_EMPTY, varNum, varVal); if (!newExpr) { // gtCloneExpr doesn't handle all opcodes, so may fail to clone a statement. @@ -782,7 +782,7 @@ bool BasicBlock::CloneBlockState( // return `false` to the caller to indicate that cloning was unsuccessful. return false; } - compiler->fgInsertStmtAtEnd(to, compiler->fgNewStmtFromTree(newExpr)); + compiler->fgInsertStmtAtEnd(to, compiler->fgNewStmtFromTree(newExpr, fromStmt->GetDebugInfo())); } return true; } @@ -1670,6 +1670,6 @@ void BasicBlock::unmarkLoopAlign(Compiler* compiler DEBUG_ARG(const char* reason { compiler->loopAlignCandidates--; bbFlags &= ~BBF_LOOP_ALIGN; - JITDUMP("Unmarking LOOP_ALIGN from " FMT_BB ". Reason= %s.", bbNum, reason); + JITDUMP("Unmarking LOOP_ALIGN from " FMT_BB ". Reason= %s.\n", bbNum, reason); } } diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index a0654de6c622..076df275868a 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -3080,7 +3080,7 @@ void CodeGen::genCodeForCmpXchg(GenTreeCmpXchg* treeNode) instruction CodeGen::genGetInsForOper(genTreeOps oper, var_types type) { - instruction ins = INS_brk; + instruction ins = INS_BREAKPOINT; if (varTypeIsFloating(type)) { diff --git a/src/coreclr/jit/codegenlinear.cpp b/src/coreclr/jit/codegenlinear.cpp index ef49804dc850..38ac9a92d86d 100644 --- a/src/coreclr/jit/codegenlinear.cpp +++ b/src/coreclr/jit/codegenlinear.cpp @@ -344,8 +344,8 @@ void CodeGen::genCodeForBBlist() #if FEATURE_LOOP_ALIGN if (GetEmitter()->emitEndsWithAlignInstr()) { - // we had better be planning on starting a new IG - assert(needLabel); + // Force new label if current IG ends with an align instruction. + needLabel = true; } #endif diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 62496ab0c4c4..e56c96b026c0 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -5242,6 +5242,7 @@ void Compiler::placeLoopAlignInstructions() } int loopsToProcess = loopAlignCandidates; + JITDUMP("Inside placeLoopAlignInstructions for %d loops.\n", loopAlignCandidates); // Add align only if there were any loops that needed alignment weight_t minBlockSoFar = BB_MAX_WEIGHT; diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 9f9b904fa6ea..cbd45e04c319 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -4509,10 +4509,10 @@ class Compiler void impEndTreeList(BasicBlock* block, Statement* firstStmt, Statement* lastStmt); void impEndTreeList(BasicBlock* block); void impAppendStmtCheck(Statement* stmt, unsigned chkLevel); - void impAppendStmt(Statement* stmt, unsigned chkLevel); + void impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsumedDebugInfo = true); void impAppendStmt(Statement* stmt); void impInsertStmtBefore(Statement* stmt, Statement* stmtBefore); - Statement* impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di); + Statement* impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di, bool checkConsumedDebugInfo = true); void impInsertTreeBefore(GenTree* tree, const DebugInfo& di, Statement* stmtBefore); void impAssignTempGen(unsigned tmp, GenTree* val, @@ -5492,6 +5492,8 @@ class Compiler // For a store to an address-exposed local at curTree, record the new curMemoryVN and update curTree's MemorySsaMap. void recordAddressExposedLocalStore(GenTree* curTree, ValueNum memoryVN DEBUGARG(const char* msg)); + void fgSetCurrentMemoryVN(MemoryKind memoryKind, ValueNum newMemoryVN); + // Tree caused an update in the current memory VN. If "tree" has an associated heap SSA #, record that // value in that SSA #. void fgValueNumberRecordMemorySsa(MemoryKind memoryKind, GenTree* tree); @@ -10003,7 +10005,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX bool compInitMem : 1; // Is the CORINFO_OPT_INIT_LOCALS bit set in the method info options? bool compProfilerCallback : 1; // JIT inserted a profiler Enter callback bool compPublishStubParam : 1; // EAX captured in prolog will be available through an intrinsic - bool compRetBuffDefStack : 1; // The ret buff argument definitely points into the stack. bool compHasNextCallRetAddr : 1; // The NextCallReturnAddress intrinsic is used. var_types compRetType; // Return type of the method as declared in IL @@ -12000,7 +12001,9 @@ const instruction INS_SQRT = INS_vsqrt; const instruction INS_MULADD = INS_madd; inline const instruction INS_BREAKPOINT_osHelper() { - return TargetOS::IsUnix ? INS_brk : INS_bkpt; + // GDB needs the encoding of brk #0 + // Windbg needs the encoding of brk #F000 + return TargetOS::IsUnix ? INS_brk_unix : INS_brk_windows; } #define INS_BREAKPOINT INS_BREAKPOINT_osHelper() diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 813db076569e..8fad38af36f8 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -3622,9 +3622,8 @@ inline bool Compiler::IsSharedStaticHelper(GenTree* tree) helper == CORINFO_HELP_STRCNS || helper == CORINFO_HELP_BOX || // helpers being added to IsSharedStaticHelper - helper == CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT || helper == CORINFO_HELP_GETSTATICFIELDADDR_TLS || - helper == CORINFO_HELP_GETGENERICS_GCSTATIC_BASE || helper == CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE || - helper == CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE || + helper == CORINFO_HELP_GETSTATICFIELDADDR_TLS || helper == CORINFO_HELP_GETGENERICS_GCSTATIC_BASE || + helper == CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE || helper == CORINFO_HELP_GETGENERICS_GCTHREADSTATIC_BASE || helper == CORINFO_HELP_GETGENERICS_NONGCTHREADSTATIC_BASE || helper == CORINFO_HELP_GETSHARED_GCSTATIC_BASE || helper == CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE || diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index cee57456782e..1bcda1dd0a88 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -3649,21 +3649,20 @@ void emitter::emitIns_I(instruction ins, emitAttr attr, ssize_t imm) insFormat fmt = IF_NONE; /* Figure out the encoding format of the instruction */ - switch (ins) + if (ins == INS_BREAKPOINT) { - case INS_brk: - if ((imm & 0x0000ffff) == imm) - { - fmt = IF_SI_0A; - } - else - { - assert(!"Instruction cannot be encoded: IF_SI_0A"); - } - break; - default: - unreached(); - break; + if ((imm & 0x0000ffff) == imm) + { + fmt = IF_SI_0A; + } + else + { + assert(!"Instruction cannot be encoded: IF_SI_0A"); + } + } + else + { + unreached(); } assert(fmt != IF_NONE); @@ -11459,15 +11458,16 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) // then add "bkpt" instruction. instrDescAlign* alignInstr = (instrDescAlign*)id; - if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 50) && - (alignInstr->idaIG != alignInstr->idaLoopHeadPredIG) && !skipIns) + if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 50) && alignInstr->isPlacedAfterJmp && + !skipIns) { // There is no good way to squeeze in "bkpt" as well as display it // in the disassembly because there is no corresponding instrDesc for // it. As such, leave it as is, the "0xD43E0000" bytecode will be seen // next to the nop instruction in disasm. // e.g. D43E0000 align [4 bytes for IG07] - // ins = INS_bkpt; + ins = INS_BREAKPOINT; + fmt = IF_SI_0A; } #endif } @@ -14610,7 +14610,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins } break; - case IF_SN_0A: // bkpt, brk, nop + case IF_SN_0A: // nop, yield, align if (id->idIns() == INS_align) { diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 4dd0d44a8563..d472b1393518 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -10037,7 +10037,7 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst) // For cases where 'align' was placed behing a 'jmp' in an IG that does not // immediately preced the loop IG, we do not know in advance the offset of // IG having loop. For such cases, skip the padding calculation validation. - bool validatePadding = alignInstr->idaIG == alignInstr->idaLoopHeadPredIG; + bool validatePadding = !alignInstr->isPlacedAfterJmp; #endif // Candidate for loop alignment @@ -10076,7 +10076,7 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst) // then add "int3" instruction. Since int3 takes 1 byte, we would only add // it if paddingToAdd >= 1 byte. - if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 50) && !validatePadding && paddingToAdd >= 1) + if (emitComp->compStressCompile(Compiler::STRESS_EMITTER, 50) && alignInstr->isPlacedAfterJmp && paddingToAdd >= 1) { size_t int3Code = insCodeMR(INS_BREAKPOINT); // There is no good way to squeeze in "int3" as well as display it diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index a41724f8ef42..39e1dae21e35 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -5934,6 +5934,9 @@ bool Compiler::fgUpdateFlowGraph(bool doTailDuplication) // Update the loop table if we removed the bottom of a loop, for example. fgUpdateLoopsAfterCompacting(block, bNext); + // If this block was aligned, unmark it + bNext->unmarkLoopAlign(this DEBUG_ARG("Optimized jump")); + // If this is the first Cold basic block update fgFirstColdBlock if (bNext == fgFirstColdBlock) { diff --git a/src/coreclr/jit/gcinfo.cpp b/src/coreclr/jit/gcinfo.cpp index f2077471d478..85e7f688c2f2 100644 --- a/src/coreclr/jit/gcinfo.cpp +++ b/src/coreclr/jit/gcinfo.cpp @@ -728,29 +728,6 @@ GCInfo::WriteBarrierForm GCInfo::gcWriteBarrierFormFromTargetAddress(GenTree* tg assert(varDsc->TypeGet() == TYP_BYREF); return GCInfo::WBF_NoBarrier; } - - // We don't eliminate for inlined methods, where we (can) know where the "retBuff" points. - if (!compiler->compIsForInlining() && lclNum == compiler->info.compRetBuffArg) - { - assert(compiler->info.compRetType == TYP_STRUCT); // Else shouldn't have a ret buff. - - // Are we assured that the ret buff pointer points into the stack of a caller? - if (compiler->info.compRetBuffDefStack) - { -#if 0 - // This is an optional debugging mode. If the #if 0 above is changed to #if 1, - // every barrier we remove for stores to GC ref fields of a retbuff use a special - // helper that asserts that the target is not in the heap. -#ifdef DEBUG - return WBF_NoBarrier_CheckNotHeapInDebug; -#else - return WBF_NoBarrier; -#endif -#else // 0 - return GCInfo::WBF_NoBarrier; -#endif // 0 - } - } } if (tgtAddr->TypeGet() == TYP_REF) { diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 09e596a774b6..00c58d70bae1 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -21898,6 +21898,53 @@ uint16_t GenTreeLclVarCommon::GetLclOffs() const } } +#if defined(TARGET_XARCH) && defined(FEATURE_HW_INTRINSICS) +//------------------------------------------------------------------------ +// GetResultOpNumForFMA: check if the result is written into one of the operands. +// In the case that none of the operand is overwritten, check if any of them is lastUse. +// +// Return Value: +// The operand number overwritten or lastUse. 0 is the default value, where the result is written into +// a destination that is not one of the source operands and there is no last use op. +// +unsigned GenTreeHWIntrinsic::GetResultOpNumForFMA(GenTree* use, GenTree* op1, GenTree* op2, GenTree* op3) +{ + // only FMA intrinsic node should call into this function + assert(HWIntrinsicInfo::lookupIsa(gtHWIntrinsicId) == InstructionSet_FMA); + if (use != nullptr && use->OperIs(GT_STORE_LCL_VAR)) + { + // For store_lcl_var, check if any op is overwritten + + GenTreeLclVarCommon* overwritten = use->AsLclVarCommon(); + unsigned overwrittenLclNum = overwritten->GetLclNum(); + if (op1->IsLocal() && op1->AsLclVarCommon()->GetLclNum() == overwrittenLclNum) + { + return 1; + } + else if (op2->IsLocal() && op2->AsLclVarCommon()->GetLclNum() == overwrittenLclNum) + { + return 2; + } + else if (op3->IsLocal() && op3->AsLclVarCommon()->GetLclNum() == overwrittenLclNum) + { + return 3; + } + } + + // If no overwritten op, check if there is any last use op + // https://github.com/dotnet/runtime/issues/62215 + + if (op1->OperIs(GT_LCL_VAR) && op1->IsLastUse(0)) + return 1; + else if (op2->OperIs(GT_LCL_VAR) && op2->IsLastUse(0)) + return 2; + else if (op3->OperIs(GT_LCL_VAR) && op3->IsLastUse(0)) + return 3; + + return 0; +} +#endif // TARGET_XARCH && FEATURE_HW_INTRINSICS + #ifdef TARGET_ARM //------------------------------------------------------------------------ // IsOffsetMisaligned: check if the field needs a special handling on arm. diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 553ed29837c8..1a0865073982 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -5526,6 +5526,7 @@ struct GenTreeHWIntrinsic : public GenTreeJitIntrinsic { return (gtFlags & GTF_SIMDASHW_OP) != 0; } + unsigned GetResultOpNumForFMA(GenTree* use, GenTree* op1, GenTree* op2, GenTree* op3); NamedIntrinsic GetHWIntrinsicId() const; diff --git a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp index 2e6f018ddaf6..bb6a6daa815d 100644 --- a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp @@ -2034,67 +2034,82 @@ void CodeGen::genFMAIntrinsic(GenTreeHWIntrinsic* node) NamedIntrinsic intrinsicId = node->GetHWIntrinsicId(); var_types baseType = node->GetSimdBaseType(); emitAttr attr = emitActualTypeSize(Compiler::getSIMDTypeForSize(node->GetSimdSize())); - instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); + instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); // 213 form + instruction _132form = (instruction)(ins - 1); + instruction _231form = (instruction)(ins + 1); GenTree* op1 = node->Op(1); GenTree* op2 = node->Op(2); GenTree* op3 = node->Op(3); - regNumber targetReg = node->GetRegNum(); + + regNumber targetReg = node->GetRegNum(); genConsumeMultiOpOperands(node); - regNumber op1Reg; - regNumber op2Reg; + regNumber op1NodeReg = op1->GetRegNum(); + regNumber op2NodeReg = op2->GetRegNum(); + regNumber op3NodeReg = op3->GetRegNum(); + + GenTree* emitOp1 = op1; + GenTree* emitOp2 = op2; + GenTree* emitOp3 = op3; - bool isCommutative = false; const bool copiesUpperBits = HWIntrinsicInfo::CopiesUpperBits(intrinsicId); // Intrinsics with CopyUpperBits semantics cannot have op1 be contained assert(!copiesUpperBits || !op1->isContained()); - if (op2->isContained() || op2->isUsedFromSpillTemp()) + if (op1->isContained() || op1->isUsedFromSpillTemp()) { - // 132 form: op1 = (op1 * op3) + [op2] - - ins = (instruction)(ins - 1); - op1Reg = op1->GetRegNum(); - op2Reg = op3->GetRegNum(); - op3 = op2; + if (targetReg == op2NodeReg) + { + std::swap(emitOp1, emitOp2); + // op2 = ([op1] * op2) + op3 + // 132 form: XMM1 = (XMM1 * [XMM3]) + XMM2 + ins = _132form; + std::swap(emitOp2, emitOp3); + } + else + { + // targetReg == op3NodeReg or targetReg == ? + // op3 = ([op1] * op2) + op3 + // 231 form: XMM1 = (XMM2 * [XMM3]) + XMM1 + ins = _231form; + std::swap(emitOp1, emitOp3); + } } - else if (op1->isContained() || op1->isUsedFromSpillTemp()) + else if (op2->isContained() || op2->isUsedFromSpillTemp()) { - // 231 form: op3 = (op2 * op3) + [op1] - - ins = (instruction)(ins + 1); - op1Reg = op3->GetRegNum(); - op2Reg = op2->GetRegNum(); - op3 = op1; + if (!copiesUpperBits && (targetReg == op3NodeReg)) + { + // op3 = (op1 * [op2]) + op3 + // 231 form: XMM1 = (XMM2 * [XMM3]) + XMM1 + ins = _231form; + std::swap(emitOp1, emitOp3); + } + else + { + // targetReg == op1NodeReg or targetReg == ? + // op1 = (op1 * [op2]) + op3 + // 132 form: XMM1 = (XMM1 * [XMM3]) + XMM2 + ins = _132form; + } + std::swap(emitOp2, emitOp3); } else { - // 213 form: op1 = (op2 * op1) + [op3] - - op1Reg = op1->GetRegNum(); - op2Reg = op2->GetRegNum(); - - isCommutative = !copiesUpperBits; - } - - if (isCommutative && (op1Reg != targetReg) && (op2Reg == targetReg)) - { - assert(node->isRMWHWIntrinsic(compiler)); - - // We have "reg2 = (reg1 * reg2) +/- op3" where "reg1 != reg2" on a RMW intrinsic. - // - // For non-commutative intrinsics, we should have ensured that op2 was marked - // delay free in order to prevent it from getting assigned the same register - // as target. However, for commutative intrinsics, we can just swap the operands - // in order to have "reg2 = reg2 op reg1" which will end up producing the right code. - - op2Reg = op1Reg; - op1Reg = targetReg; + // targetReg could be op1NodeReg, op2NodeReg, or not equal to any op + // op1 = (op1 * op2) + [op3] or op2 = (op1 * op2) + [op3] + // ? = (op1 * op2) + [op3] or ? = (op1 * op2) + op3 + // 213 form: XMM1 = (XMM2 * XMM1) + [XMM3] + if (!copiesUpperBits && (targetReg == op2NodeReg)) + { + // op2 = (op1 * op2) + [op3] + // 213 form: XMM1 = (XMM2 * XMM1) + [XMM3] + std::swap(emitOp1, emitOp2); + } } - genHWIntrinsic_R_R_R_RM(ins, attr, targetReg, op1Reg, op2Reg, op3); + genHWIntrinsic_R_R_R_RM(ins, attr, targetReg, emitOp1->GetRegNum(), emitOp2->GetRegNum(), emitOp3); genProduceReg(node); } diff --git a/src/coreclr/jit/importer.cpp b/src/coreclr/jit/importer.cpp index 86eff6ee9250..5aaf145a3323 100644 --- a/src/coreclr/jit/importer.cpp +++ b/src/coreclr/jit/importer.cpp @@ -527,14 +527,22 @@ inline void Compiler::impAppendStmtCheck(Statement* stmt, unsigned chkLevel) #endif } -/***************************************************************************** - * - * Append the given statement to the current block's tree list. - * [0..chkLevel) is the portion of the stack which we will check for - * interference with stmt and spill if needed. - */ - -inline void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel) +//------------------------------------------------------------------------ +// impAppendStmt: Append the given statement to the current block's tree list. +// +// +// Arguments: +// stmt - The statement to add. +// chkLevel - [0..chkLevel) is the portion of the stack which we will check +// for interference with stmt and spill if needed. +// checkConsumedDebugInfo - Whether to check for consumption of impCurStmtDI. impCurStmtDI +// marks the debug info of the current boundary and is set when we +// start importing IL at that boundary. If this parameter is true, +// then the function checks if 'stmt' has been associated with the +// current boundary, and if so, clears it so that we do not attach +// it to more upcoming statements. +// +void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel, bool checkConsumedDebugInfo) { if (chkLevel == (unsigned)CHECK_SPILL_ALL) { @@ -620,7 +628,8 @@ inline void Compiler::impAppendStmt(Statement* stmt, unsigned chkLevel) // offsets here instead of debug info, since we do not set the "is call" // bit in impCurStmtDI. - if (impLastStmt->GetDebugInfo().GetLocation().GetOffset() == impCurStmtDI.GetLocation().GetOffset()) + if (checkConsumedDebugInfo && + (impLastStmt->GetDebugInfo().GetLocation().GetOffset() == impCurStmtDI.GetLocation().GetOffset())) { impCurStmtOffsSet(BAD_IL_OFFSET); } @@ -709,13 +718,26 @@ inline void Compiler::impInsertStmtBefore(Statement* stmt, Statement* stmtBefore stmtBefore->SetPrevStmt(stmt); } -/***************************************************************************** - * - * Append the given expression tree to the current block's tree list. - * Return the newly created statement. - */ - -Statement* Compiler::impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di) +//------------------------------------------------------------------------ +// impAppendTree: Append the given expression tree to the current block's tree list. +// +// +// Arguments: +// tree - The tree that will be the root of the newly created statement. +// chkLevel - [0..chkLevel) is the portion of the stack which we will check +// for interference with stmt and spill if needed. +// di - Debug information to associate with the statement. +// checkConsumedDebugInfo - Whether to check for consumption of impCurStmtDI. impCurStmtDI +// marks the debug info of the current boundary and is set when we +// start importing IL at that boundary. If this parameter is true, +// then the function checks if 'stmt' has been associated with the +// current boundary, and if so, clears it so that we do not attach +// it to more upcoming statements. +// +// Return value: +// The newly created statement. +// +Statement* Compiler::impAppendTree(GenTree* tree, unsigned chkLevel, const DebugInfo& di, bool checkConsumedDebugInfo) { assert(tree); @@ -725,7 +747,7 @@ Statement* Compiler::impAppendTree(GenTree* tree, unsigned chkLevel, const Debug /* Append the statement to the current block's stmt list */ - impAppendStmt(stmt, chkLevel); + impAppendStmt(stmt, chkLevel, checkConsumedDebugInfo); return stmt; } @@ -3629,7 +3651,6 @@ const char* Compiler::impGetIntrinsicName(CorInfoIntrinsics intrinsicID) "CORINFO_INTRINSIC_Array_Get", "CORINFO_INTRINSIC_Array_Address", "CORINFO_INTRINSIC_Array_Set", - "CORINFO_INTRINSIC_InitializeArray", "CORINFO_INTRINSIC_RTH_GetValueInternal", "CORINFO_INTRINSIC_Object_GetType", "CORINFO_INTRINSIC_StubHelpers_GetStubContext", @@ -3925,7 +3946,9 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, return new (this, GT_LABEL) GenTree(GT_LABEL, TYP_I_IMPL); } - if ((ni == NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan) && IsTargetAbi(CORINFO_CORERT_ABI)) + if (((ni == NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan) || + (ni == NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray)) && + IsTargetAbi(CORINFO_CORERT_ABI)) { // CreateSpan must be expanded for NativeAOT mustExpand = true; @@ -3953,10 +3976,6 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, { GenTree* op1; - case CORINFO_INTRINSIC_InitializeArray: - retNode = impInitializeArrayIntrinsic(sig); - break; - case CORINFO_INTRINSIC_Array_Address: case CORINFO_INTRINSIC_Array_Get: case CORINFO_INTRINSIC_Array_Set: @@ -4205,6 +4224,12 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, break; } + case NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray: + { + retNode = impInitializeArrayIntrinsic(sig); + break; + } + case NI_System_Span_get_Item: case NI_System_ReadOnlySpan_get_Item: { @@ -5328,6 +5353,10 @@ NamedIntrinsic Compiler::lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method) { result = NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan; } + else if (strcmp(methodName, "InitializeArray") == 0) + { + result = NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray; + } } else if (strncmp(namespaceName, "System.Runtime.Intrinsics", 25) == 0) { @@ -8204,7 +8233,7 @@ GenTree* Compiler::impImportStaticFieldAccess(CORINFO_RESOLVED_TOKEN* pResolvedT { FieldSeqNode* fs = GetFieldSeqStore()->CreateSingleton(pResolvedToken->hField); op1 = gtNewOperNode(GT_ADD, op1->TypeGet(), op1, - new (this, GT_CNS_INT) GenTreeIntCon(TYP_INT, pFieldInfo->offset, fs)); + new (this, GT_CNS_INT) GenTreeIntCon(TYP_I_IMPL, pFieldInfo->offset, fs)); } break; } @@ -9919,7 +9948,11 @@ var_types Compiler::impImportCall(OPCODE opcode, assert(!isFatPointerCandidate); // We should not try to inline calli. // Make the call its own tree (spill the stack if needed). - impAppendTree(call, (unsigned)CHECK_SPILL_ALL, impCurStmtDI); + // Do not consume the debug info here. This is particularly + // important if we give up on the inline, in which case the + // call will typically end up in the statement that contains + // the GT_RET_EXPR that we leave on the stack. + impAppendTree(call, (unsigned)CHECK_SPILL_ALL, impCurStmtDI, false); // TODO: Still using the widened type. GenTree* retExpr = gtNewInlineCandidateReturnExpr(call, genActualType(callRetTyp), compCurBB->bbFlags); diff --git a/src/coreclr/jit/instrsarm64.h b/src/coreclr/jit/instrsarm64.h index fbd74c103052..c89b006a4189 100644 --- a/src/coreclr/jit/instrsarm64.h +++ b/src/coreclr/jit/instrsarm64.h @@ -1566,10 +1566,10 @@ INST1(nop, "nop", 0, IF_SN_0A, 0xD503201F) INST1(yield, "yield", 0, IF_SN_0A, 0xD503203F) // yield SN_0A 1101010100000011 0010000000111111 D503 203F -INST1(bkpt, "bkpt", 0, IF_SN_0A, 0xD43E0000) - // brpt SN_0A 1101010000111110 0000000000000000 D43E 0000 0xF000 +INST1(brk_windows, "brk_windows", 0, IF_SI_0A, 0xD43E0000) + // brk (windows) SI_0A 1101010000111110 0000000000000000 D43E 0000 0xF000 -INST1(brk, "brk", 0, IF_SI_0A, 0xD4200000) +INST1(brk_unix, "brk_unix", 0, IF_SI_0A, 0xD4200000) // brk imm16 SI_0A 11010100001iiiii iiiiiiiiiii00000 D420 0000 imm16 INST1(dsb, "dsb", 0, IF_SI_0B, 0xD503309F) diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 4fb8f335883c..debf6bafcfeb 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -557,24 +557,8 @@ void Compiler::lvaInitRetBuffArg(InitVarDscInfo* varDscInfo, bool useFixedRetBuf #endif varDsc->lvOnFrame = true; // The final home for this incoming register might be our local stack frame - info.compRetBuffDefStack = 0; - if (info.compRetType == TYP_STRUCT) - { - CORINFO_SIG_INFO sigInfo; - info.compCompHnd->getMethodSig(info.compMethodHnd, &sigInfo); - assert(JITtype2varType(sigInfo.retType) == info.compRetType); // Else shouldn't have a ret buff. - - info.compRetBuffDefStack = (info.compCompHnd->isStructRequiringStackAllocRetBuf(sigInfo.retTypeClass)); - if (info.compRetBuffDefStack) - { - // If we're assured that the ret buff argument points into a callers stack, we will type it as - // "TYP_I_IMPL" - // (native int/unmanaged pointer) so that it's not tracked as a GC ref. - varDsc->lvType = TYP_I_IMPL; - } - } #ifdef FEATURE_SIMD - else if (supportSIMDTypes() && varTypeIsSIMD(info.compRetType)) + if (supportSIMDTypes() && varTypeIsSIMD(info.compRetType)) { varDsc->lvSIMDType = true; diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index a073633ec364..1c9febeb1314 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -6783,6 +6783,51 @@ void Lowering::LowerStoreIndirCommon(GenTreeStoreInd* ind) TryCreateAddrMode(ind->Addr(), true, ind->TypeGet()); if (!comp->codeGen->gcInfo.gcIsWriteBarrierStoreIndNode(ind)) { + if (varTypeIsFloating(ind) && ind->Data()->IsCnsFltOrDbl()) + { + // Optimize *x = DCON to *x = ICON which can be slightly faster and/or smaller. + GenTree* data = ind->Data(); + double dblCns = data->AsDblCon()->gtDconVal; + ssize_t intCns = 0; + var_types type = TYP_UNKNOWN; + // XARCH: we can always contain the immediates. + // ARM64: zero can always be contained, other cases will use immediates from the data + // section and it is not a clear win to switch them to inline integers. + // ARM: FP constants are assembled from integral ones, so it is always profitable + // to directly use the integers as it avoids the int -> float conversion. + CLANG_FORMAT_COMMENT_ANCHOR; + +#if defined(TARGET_XARCH) || defined(TARGET_ARM) + bool shouldSwitchToInteger = true; +#else // TARGET_ARM64 + bool shouldSwitchToInteger = !data->IsCnsNonZeroFltOrDbl(); +#endif + + if (shouldSwitchToInteger) + { + if (ind->TypeIs(TYP_FLOAT)) + { + float fltCns = static_cast(dblCns); // should be a safe round-trip + intCns = static_cast(*reinterpret_cast(&fltCns)); + type = TYP_INT; + } +#ifdef TARGET_64BIT + else + { + assert(ind->TypeIs(TYP_DOUBLE)); + intCns = static_cast(*reinterpret_cast(&dblCns)); + type = TYP_LONG; + } +#endif + } + + if (type != TYP_UNKNOWN) + { + data->BashToConst(intCns, type); + ind->ChangeType(type); + } + } + LowerStoreIndir(ind); } } @@ -6852,7 +6897,7 @@ void Lowering::TransformUnusedIndirection(GenTreeIndir* ind, Compiler* comp, Bas #ifdef TARGET_ARM64 bool useNullCheck = true; #elif TARGET_ARM - bool useNullCheck = false; + bool useNullCheck = false; #else // TARGET_XARCH bool useNullCheck = !ind->Addr()->isContained(); #endif // !TARGET_XARCH diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 5c2e320d570e..548a6033d872 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -129,36 +129,6 @@ void Lowering::LowerStoreIndir(GenTreeStoreInd* node) return; } } - else if (node->Data()->IsCnsFltOrDbl()) - { - // Optimize *x = DCON to *x = ICON which is slightly faster on xarch - GenTree* data = node->Data(); - double dblCns = data->AsDblCon()->gtDconVal; - ssize_t intCns = 0; - var_types type = TYP_UNKNOWN; - - if (node->TypeIs(TYP_FLOAT)) - { - float fltCns = static_cast(dblCns); // should be a safe round-trip - intCns = static_cast(*reinterpret_cast(&fltCns)); - type = TYP_INT; - } -#ifdef TARGET_AMD64 - else - { - assert(node->TypeIs(TYP_DOUBLE)); - intCns = static_cast(*reinterpret_cast(&dblCns)); - type = TYP_LONG; - } -#endif - - if (type != TYP_UNKNOWN) - { - data->SetContained(); - data->BashToConst(intCns, type); - node->ChangeType(type); - } - } // Optimization: do not unnecessarily zero-extend the result of setcc. if (varTypeIsByte(node) && (node->Data()->OperIsCompare() || node->Data()->OperIs(GT_SETCC))) @@ -6030,40 +6000,53 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) { if ((intrinsicId >= NI_FMA_MultiplyAdd) && (intrinsicId <= NI_FMA_MultiplySubtractNegatedScalar)) { - bool supportsRegOptional = false; + bool supportsOp1RegOptional = false; + bool supportsOp2RegOptional = false; + bool supportsOp3RegOptional = false; + unsigned resultOpNum = 0; + LIR::Use use; + GenTree* user = nullptr; + + if (BlockRange().TryGetUse(node, &use)) + { + user = use.User(); + } + resultOpNum = node->GetResultOpNumForFMA(user, op1, op2, op3); - if (IsContainableHWIntrinsicOp(node, op3, &supportsRegOptional)) + // Prioritize Containable op. Check if any one of the op is containable first. + // Set op regOptional only if none of them is containable. + + // Prefer to make op3 contained, + if (resultOpNum != 3 && IsContainableHWIntrinsicOp(node, op3, &supportsOp3RegOptional)) { - // 213 form: op1 = (op2 * op1) + [op3] + // result = (op1 * op2) + [op3] MakeSrcContained(node, op3); } - else if (IsContainableHWIntrinsicOp(node, op2, &supportsRegOptional)) + else if (resultOpNum != 2 && IsContainableHWIntrinsicOp(node, op2, &supportsOp2RegOptional)) { - // 132 form: op1 = (op1 * op3) + [op2] + // result = (op1 * [op2]) + op3 MakeSrcContained(node, op2); } - else if (IsContainableHWIntrinsicOp(node, op1, &supportsRegOptional)) + else if (resultOpNum != 1 && !HWIntrinsicInfo::CopiesUpperBits(intrinsicId) && + IsContainableHWIntrinsicOp(node, op1, &supportsOp1RegOptional)) { - // Intrinsics with CopyUpperBits semantics cannot have op1 be contained - - if (!HWIntrinsicInfo::CopiesUpperBits(intrinsicId)) - { - // 231 form: op3 = (op2 * op3) + [op1] - MakeSrcContained(node, op1); - } + // result = ([op1] * op2) + op3 + MakeSrcContained(node, op1); } - else + else if (supportsOp3RegOptional) { - assert(supportsRegOptional); - - // TODO-XArch-CQ: Technically any one of the three operands can - // be reg-optional. With a limitation on op1 where - // it can only be so if CopyUpperBits is off. - // https://github.com/dotnet/runtime/issues/6358 - - // 213 form: op1 = (op2 * op1) + op3 + assert(resultOpNum != 3); op3->SetRegOptional(); } + else if (supportsOp2RegOptional) + { + assert(resultOpNum != 2); + op2->SetRegOptional(); + } + else if (supportsOp1RegOptional) + { + op1->SetRegOptional(); + } } else { diff --git a/src/coreclr/jit/lsraxarch.cpp b/src/coreclr/jit/lsraxarch.cpp index 2926f54ce1b1..ca169600e83f 100644 --- a/src/coreclr/jit/lsraxarch.cpp +++ b/src/coreclr/jit/lsraxarch.cpp @@ -2272,48 +2272,93 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree) const bool copiesUpperBits = HWIntrinsicInfo::CopiesUpperBits(intrinsicId); - // Intrinsics with CopyUpperBits semantics cannot have op1 be contained - assert(!copiesUpperBits || !op1->isContained()); + unsigned resultOpNum = 0; + LIR::Use use; + GenTree* user = nullptr; - if (op2->isContained()) + if (LIR::AsRange(blockSequence[curBBSeqNum]).TryGetUse(intrinsicTree, &use)) { - // 132 form: op1 = (op1 * op3) + [op2] + user = use.User(); + } + resultOpNum = intrinsicTree->GetResultOpNumForFMA(user, op1, op2, op3); - tgtPrefUse = BuildUse(op1); + unsigned containedOpNum = 0; - srcCount += 1; - srcCount += BuildOperandUses(op2); - srcCount += BuildDelayFreeUses(op3, op1); + // containedOpNum remains 0 when no operand is contained or regOptional + if (op1->isContained() || op1->IsRegOptional()) + { + containedOpNum = 1; } - else if (op1->isContained()) + else if (op2->isContained() || op2->IsRegOptional()) { - // 231 form: op3 = (op2 * op3) + [op1] - - tgtPrefUse = BuildUse(op3); - - srcCount += BuildOperandUses(op1); - srcCount += BuildDelayFreeUses(op2, op1); - srcCount += 1; + containedOpNum = 2; } - else + else if (op3->isContained() || op3->IsRegOptional()) { - // 213 form: op1 = (op2 * op1) + [op3] + containedOpNum = 3; + } - tgtPrefUse = BuildUse(op1); - srcCount += 1; + GenTree* emitOp1 = op1; + GenTree* emitOp2 = op2; + GenTree* emitOp3 = op3; - if (copiesUpperBits) + // Intrinsics with CopyUpperBits semantics must have op1 as target + assert(containedOpNum != 1 || !copiesUpperBits); + + if (containedOpNum == 1) + { + // https://github.com/dotnet/runtime/issues/62215 + // resultOpNum might change between lowering and lsra, comment out assertion for now. + // assert(containedOpNum != resultOpNum); + // resultOpNum is 3 or 0: op3/? = ([op1] * op2) + op3 + std::swap(emitOp1, emitOp3); + + if (resultOpNum == 2) { - srcCount += BuildDelayFreeUses(op2, op1); + // op2 = ([op1] * op2) + op3 + std::swap(emitOp2, emitOp3); } - else + } + else if (containedOpNum == 3) + { + // assert(containedOpNum != resultOpNum); + if (resultOpNum == 2 && !copiesUpperBits) { - tgtPrefUse2 = BuildUse(op2); - srcCount += 1; + // op2 = (op1 * op2) + [op3] + std::swap(emitOp1, emitOp2); } + // else: op1/? = (op1 * op2) + [op3] + } + else if (containedOpNum == 2) + { + // assert(containedOpNum != resultOpNum); - srcCount += op3->isContained() ? BuildOperandUses(op3) : BuildDelayFreeUses(op3, op1); + // op1/? = (op1 * [op2]) + op3 + std::swap(emitOp2, emitOp3); + if (resultOpNum == 3 && !copiesUpperBits) + { + // op3 = (op1 * [op2]) + op3 + std::swap(emitOp1, emitOp2); + } } + else + { + // containedOpNum == 0 + // no extra work when resultOpNum is 0 or 1 + if (resultOpNum == 2) + { + std::swap(emitOp1, emitOp2); + } + else if (resultOpNum == 3) + { + std::swap(emitOp1, emitOp3); + } + } + tgtPrefUse = BuildUse(emitOp1); + + srcCount += 1; + srcCount += BuildDelayFreeUses(emitOp2, emitOp1); + srcCount += emitOp3->isContained() ? BuildOperandUses(emitOp3) : BuildDelayFreeUses(emitOp3, emitOp1); buildUses = false; break; diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 6df511fd8b32..0900793a1677 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -8125,37 +8125,29 @@ GenTree* Compiler::fgCreateCallDispatcherAndGetResult(GenTreeCall* orig assert(retBufArg->OperIsLocal()); assert(retBufArg->AsLclVarCommon()->GetLclNum() == info.compRetBuffArg); - if (info.compRetBuffDefStack) - { - // Use existing retbuf. - retValArg = retBufArg; - } - else - { - // Caller return buffer argument retBufArg can point to GC heap while the dispatcher expects - // the return value argument retValArg to point to the stack. - // We use a temporary stack allocated return buffer to hold the value during the dispatcher call - // and copy the value back to the caller return buffer after that. - unsigned int tmpRetBufNum = lvaGrabTemp(true DEBUGARG("substitute local for return buffer")); + // Caller return buffer argument retBufArg can point to GC heap while the dispatcher expects + // the return value argument retValArg to point to the stack. + // We use a temporary stack allocated return buffer to hold the value during the dispatcher call + // and copy the value back to the caller return buffer after that. + unsigned int tmpRetBufNum = lvaGrabTemp(true DEBUGARG("substitute local for return buffer")); - constexpr bool unsafeValueClsCheck = false; - lvaSetStruct(tmpRetBufNum, origCall->gtRetClsHnd, unsafeValueClsCheck); - lvaSetVarAddrExposed(tmpRetBufNum DEBUGARG(AddressExposedReason::DISPATCH_RET_BUF)); + constexpr bool unsafeValueClsCheck = false; + lvaSetStruct(tmpRetBufNum, origCall->gtRetClsHnd, unsafeValueClsCheck); + lvaSetVarAddrExposed(tmpRetBufNum DEBUGARG(AddressExposedReason::DISPATCH_RET_BUF)); - var_types tmpRetBufType = lvaGetDesc(tmpRetBufNum)->TypeGet(); + var_types tmpRetBufType = lvaGetDesc(tmpRetBufNum)->TypeGet(); - retValArg = gtNewOperNode(GT_ADDR, TYP_I_IMPL, gtNewLclvNode(tmpRetBufNum, tmpRetBufType)); + retValArg = gtNewOperNode(GT_ADDR, TYP_I_IMPL, gtNewLclvNode(tmpRetBufNum, tmpRetBufType)); - var_types callerRetBufType = lvaGetDesc(info.compRetBuffArg)->TypeGet(); + var_types callerRetBufType = lvaGetDesc(info.compRetBuffArg)->TypeGet(); - GenTree* dstAddr = gtNewLclvNode(info.compRetBuffArg, callerRetBufType); - GenTree* dst = gtNewObjNode(info.compMethodInfo->args.retTypeClass, dstAddr); - GenTree* src = gtNewLclvNode(tmpRetBufNum, tmpRetBufType); + GenTree* dstAddr = gtNewLclvNode(info.compRetBuffArg, callerRetBufType); + GenTree* dst = gtNewObjNode(info.compMethodInfo->args.retTypeClass, dstAddr); + GenTree* src = gtNewLclvNode(tmpRetBufNum, tmpRetBufType); - constexpr bool isVolatile = false; - constexpr bool isCopyBlock = true; - copyToRetBufNode = gtNewBlkOpNode(dst, src, isVolatile, isCopyBlock); - } + constexpr bool isVolatile = false; + constexpr bool isCopyBlock = true; + copyToRetBufNode = gtNewBlkOpNode(dst, src, isVolatile, isCopyBlock); if (origCall->gtType != TYP_VOID) { @@ -9156,48 +9148,6 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) compCurBB->bbFlags |= BBF_HAS_CALL; // This block has a call - // Make sure that return buffers containing GC pointers that aren't too large are pointers into the stack. - GenTree* origDest = nullptr; // Will only become non-null if we do the transformation (and thus require - // copy-back). - unsigned retValTmpNum = BAD_VAR_NUM; - CORINFO_CLASS_HANDLE structHnd = nullptr; - if (call->HasRetBufArg() && - call->gtCallLateArgs == nullptr) // Don't do this if we're re-morphing (which will make late args non-null). - { - // We're enforcing the invariant that return buffers pointers (at least for - // struct return types containing GC pointers) are never pointers into the heap. - // The large majority of cases are address of local variables, which are OK. - // Otherwise, allocate a local of the given struct type, pass its address, - // then assign from that into the proper destination. (We don't need to do this - // if we're passing the caller's ret buff arg to the callee, since the caller's caller - // will maintain the same invariant.) - - GenTree* dest = call->gtCallArgs->GetNode(); - assert(dest->OperGet() != GT_ARGPLACE); // If it was, we'd be in a remorph, which we've already excluded above. - if (dest->TypeIs(TYP_BYREF) && !dest->IsLocalAddrExpr()) - { - // We'll exempt helper calls from this, assuming that the helper implementation - // follows the old convention, and does whatever barrier is required. - if (call->gtCallType != CT_HELPER) - { - structHnd = call->gtRetClsHnd; - if (info.compCompHnd->isStructRequiringStackAllocRetBuf(structHnd) && - !(dest->OperGet() == GT_LCL_VAR && dest->AsLclVar()->GetLclNum() == info.compRetBuffArg)) - { - // Force re-evaluating the argInfo as the return argument has changed. - call->fgArgInfo = nullptr; - origDest = dest; - - retValTmpNum = lvaGrabTemp(true DEBUGARG("substitute local for ret buff arg")); - lvaSetStruct(retValTmpNum, structHnd, true); - dest = gtNewOperNode(GT_ADDR, TYP_BYREF, gtNewLclvNode(retValTmpNum, TYP_STRUCT)); - } - } - } - - call->gtCallArgs->SetNode(dest); - } - /* Process the "normal" argument list */ call = fgMorphArgs(call); noway_assert(call->gtOper == GT_CALL); @@ -9292,31 +9242,6 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call) } } - if (origDest != nullptr) - { - GenTree* retValVarAddr = gtNewOperNode(GT_ADDR, TYP_BYREF, gtNewLclvNode(retValTmpNum, TYP_STRUCT)); - // If the origDest expression was an assignment to a variable, it might be to an otherwise-unused - // var, which would allow the whole assignment to be optimized away to a NOP. So in that case, make the - // origDest into a comma that uses the var. Note that the var doesn't have to be a temp for this to - // be correct. - if (origDest->OperGet() == GT_ASG) - { - if (origDest->AsOp()->gtOp1->OperGet() == GT_LCL_VAR) - { - GenTree* var = origDest->AsOp()->gtOp1; - origDest = gtNewOperNode(GT_COMMA, var->TypeGet(), origDest, - gtNewLclvNode(var->AsLclVar()->GetLclNum(), var->TypeGet())); - } - } - GenTree* copyBlk = gtNewCpObjNode(origDest, retValVarAddr, structHnd, false); - copyBlk = fgMorphTree(copyBlk); - GenTree* result = gtNewOperNode(GT_COMMA, TYP_VOID, call, copyBlk); -#ifdef DEBUG - result->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED; -#endif - return result; - } - if (call->IsNoReturn()) { // @@ -9418,8 +9343,9 @@ GenTree* Compiler::fgExpandVirtualVtableCallTarget(GenTreeCall* call) tmpTree1->gtFlags |= GTF_IND_INVARIANT; // var1 + vtabOffsOfIndirection + vtabOffsAfterIndirection - GenTree* tmpTree2 = gtNewOperNode(GT_ADD, TYP_I_IMPL, gtNewLclvNode(varNum1, TYP_I_IMPL), - gtNewIconNode(vtabOffsOfIndirection + vtabOffsAfterIndirection, TYP_I_IMPL)); + GenTree* tmpTree2 = + gtNewOperNode(GT_ADD, TYP_I_IMPL, gtNewLclvNode(varNum1, TYP_I_IMPL), + gtNewIconNode(vtabOffsOfIndirection + vtabOffsAfterIndirection, TYP_I_IMPL)); // var1 + vtabOffsOfIndirection + vtabOffsAfterIndirection + [var1 + vtabOffsOfIndirection] tmpTree2 = gtNewOperNode(GT_ADD, TYP_I_IMPL, tmpTree2, tmpTree1); diff --git a/src/coreclr/jit/namedintrinsiclist.h b/src/coreclr/jit/namedintrinsiclist.h index 75740aaa4dca..62ebb80c0899 100644 --- a/src/coreclr/jit/namedintrinsiclist.h +++ b/src/coreclr/jit/namedintrinsiclist.h @@ -62,6 +62,7 @@ enum NamedIntrinsic : unsigned short NI_System_Object_MemberwiseClone, NI_System_Runtime_CompilerServices_RuntimeHelpers_CreateSpan, + NI_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray, NI_System_String_get_Chars, NI_System_String_get_Length, diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index f1e311a9a602..d6f9df4ce6b1 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -1377,7 +1377,6 @@ void HelperCallProperties::init() case CORINFO_HELP_CLASSINIT_SHARED_DYNAMICCLASS: case CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_DYNAMICCLASS: case CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS: - case CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT: case CORINFO_HELP_GETSTATICFIELDADDR_TLS: case CORINFO_HELP_GETGENERICS_GCSTATIC_BASE: case CORINFO_HELP_GETGENERICS_NONGCSTATIC_BASE: diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index 51927d5256c8..e4d18a9a0c9f 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -2217,7 +2217,7 @@ ValueNum ValueNumStore::VNForMapStore(ValueNum map, ValueNum index, ValueNum val if (m_pComp->verbose) { printf(" VNForMapStore(" FMT_VN ", " FMT_VN ", " FMT_VN "):%s in " FMT_BB " returns ", map, index, value, - varTypeName(TypeOfVN(result)), bb->bbNum); + VNMapTypeName(TypeOfVN(result)), bb->bbNum); m_pComp->vnPrint(result, 1); printf("\n"); } @@ -2255,7 +2255,7 @@ ValueNum ValueNumStore::VNForMapSelect(ValueNumKind vnk, var_types type, ValueNu #ifdef DEBUG if (m_pComp->verbose) { - printf(" VNForMapSelect(" FMT_VN ", " FMT_VN "):%s returns ", map, index, varTypeName(type)); + printf(" VNForMapSelect(" FMT_VN ", " FMT_VN "):%s returns ", map, index, VNMapTypeName(type)); m_pComp->vnPrint(result, 1); printf("\n"); } @@ -4265,8 +4265,8 @@ ValueNum Compiler::fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, bool invalidateArray = false; ValueNum elemTypeEqVN = vnStore->VNForHandle(ssize_t(elemTypeEq), GTF_ICON_CLASS_HDL); var_types arrElemType = DecodeElemType(elemTypeEq); - ValueNum hAtArrType = vnStore->VNForMapSelect(VNK_Liberal, TYP_REF, fgCurMemoryVN[GcHeap], elemTypeEqVN); - ValueNum hAtArrTypeAtArr = vnStore->VNForMapSelect(VNK_Liberal, TYP_REF, hAtArrType, arrVN); + ValueNum hAtArrType = vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, fgCurMemoryVN[GcHeap], elemTypeEqVN); + ValueNum hAtArrTypeAtArr = vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, hAtArrType, arrVN); ValueNum hAtArrTypeAtArrAtInx = vnStore->VNForMapSelect(VNK_Liberal, arrElemType, hAtArrTypeAtArr, inxVN); ValueNum newValAtInx = ValueNumStore::NoVN; @@ -4279,7 +4279,7 @@ ValueNum Compiler::fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, JITDUMP(" *** NotAField sequence encountered in fgValueNumberArrIndexAssign\n"); // Store a new unique value for newValAtArrType - newValAtArrType = vnStore->VNForExpr(compCurBB, TYP_REF); + newValAtArrType = vnStore->VNForExpr(compCurBB, TYP_MEM); invalidateArray = true; } else @@ -4301,7 +4301,7 @@ ValueNum Compiler::fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, JITDUMP(" *** Mismatched types in fgValueNumberArrIndexAssign\n"); // Store a new unique value for newValAtArrType - newValAtArrType = vnStore->VNForExpr(compCurBB, TYP_REF); + newValAtArrType = vnStore->VNForExpr(compCurBB, TYP_MEM); invalidateArray = true; } } @@ -4328,7 +4328,7 @@ ValueNum Compiler::fgValueNumberArrIndexAssign(CORINFO_CLASS_HANDLE elemTypeEq, printf(" hAtArrTypeAtArr " FMT_VN " is MapSelect(hAtArrType(" FMT_VN "), arr=" FMT_VN ")\n", hAtArrTypeAtArr, hAtArrType, arrVN); printf(" hAtArrTypeAtArrAtInx " FMT_VN " is MapSelect(hAtArrTypeAtArr(" FMT_VN "), inx=" FMT_VN "):%s\n", - hAtArrTypeAtArrAtInx, hAtArrTypeAtArr, inxVN, varTypeName(arrElemType)); + hAtArrTypeAtArrAtInx, hAtArrTypeAtArr, inxVN, ValueNumStore::VNMapTypeName(arrElemType)); if (!invalidateArray) { @@ -4401,8 +4401,8 @@ ValueNum Compiler::fgValueNumberArrIndexVal(GenTree* tree, else { ValueNum elemTypeEqVN = vnStore->VNForHandle(ssize_t(elemTypeEq), GTF_ICON_CLASS_HDL); - ValueNum hAtArrType = vnStore->VNForMapSelect(VNK_Liberal, TYP_REF, fgCurMemoryVN[GcHeap], elemTypeEqVN); - ValueNum hAtArrTypeAtArr = vnStore->VNForMapSelect(VNK_Liberal, TYP_REF, hAtArrType, arrVN); + ValueNum hAtArrType = vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, fgCurMemoryVN[GcHeap], elemTypeEqVN); + ValueNum hAtArrTypeAtArr = vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, hAtArrType, arrVN); ValueNum wholeElem = vnStore->VNForMapSelect(VNK_Liberal, elemTyp, hAtArrTypeAtArr, inxVN); #ifdef DEBUG @@ -6291,8 +6291,7 @@ const char* ValueNumStore::VNFuncNameArr[] = { #undef ValueNumFuncDef }; -// static -const char* ValueNumStore::VNFuncName(VNFunc vnf) +/* static */ const char* ValueNumStore::VNFuncName(VNFunc vnf) { if (vnf < VNF_Boundary) { @@ -6304,6 +6303,19 @@ const char* ValueNumStore::VNFuncName(VNFunc vnf) } } +/* static */ const char* ValueNumStore::VNMapTypeName(var_types type) +{ + switch (type) + { + case TYP_HEAP: + return "heap"; + case TYP_MEM: + return "mem"; + default: + return varTypeName(type); + } +} + static const char* s_reservedNameArr[] = { "$VN.Recursive", // -2 RecursiveVN "$VN.No", // -1 NoVN @@ -6757,7 +6769,7 @@ void Compiler::fgValueNumber() } } // Give memory an initial value number (about which we know nothing). - ValueNum memoryInitVal = vnStore->VNForFunc(TYP_REF, VNF_InitVal, vnStore->VNForIntCon(-1)); // Use -1 for memory. + ValueNum memoryInitVal = vnStore->VNForFunc(TYP_HEAP, VNF_InitVal, vnStore->VNForIntCon(-1)); // Use -1 for memory. GetMemoryPerSsaData(SsaConfig::FIRST_SSA_NUM)->m_vnPair.SetBoth(memoryInitVal); #ifdef DEBUG if (verbose) @@ -6894,8 +6906,8 @@ void Compiler::fgValueNumberBlock(BasicBlock* blk) // Is there a phi for this block? if (blk->bbMemorySsaPhiFunc[memoryKind] == nullptr) { - fgCurMemoryVN[memoryKind] = GetMemoryPerSsaData(blk->bbMemorySsaNumIn[memoryKind])->m_vnPair.GetLiberal(); - assert(fgCurMemoryVN[memoryKind] != ValueNumStore::NoVN); + ValueNum newMemoryVN = GetMemoryPerSsaData(blk->bbMemorySsaNumIn[memoryKind])->m_vnPair.GetLiberal(); + fgSetCurrentMemoryVN(memoryKind, newMemoryVN); } else { @@ -6943,7 +6955,7 @@ void Compiler::fgValueNumberBlock(BasicBlock* blk) unsigned phiArgSSANum = phiArgs->GetSsaNum(); ValueNum phiArgSSANumVN = vnStore->VNForIntCon(phiArgSSANum); JITDUMP(" Building phi application: $%x = SSA# %d.\n", phiArgSSANumVN, phiArgSSANum); - phiAppVN = vnStore->VNForFunc(TYP_REF, VNF_Phi, phiArgSSANumVN, phiAppVN); + phiAppVN = vnStore->VNForFunc(TYP_HEAP, VNF_Phi, phiArgSSANumVN, phiAppVN); JITDUMP(" Building phi application: $%x = phi($%x, $%x).\n", phiAppVN, phiArgSSANumVN, oldPhiAppVN); phiArgs = phiArgs->m_nextArg; @@ -6954,16 +6966,16 @@ void Compiler::fgValueNumberBlock(BasicBlock* blk) } else { - newMemoryVN = vnStore->VNForFunc(TYP_REF, VNF_PhiMemoryDef, + newMemoryVN = vnStore->VNForFunc(TYP_HEAP, VNF_PhiMemoryDef, vnStore->VNForHandle(ssize_t(blk), GTF_EMPTY), phiAppVN); } } GetMemoryPerSsaData(blk->bbMemorySsaNumIn[memoryKind])->m_vnPair.SetLiberal(newMemoryVN); - fgCurMemoryVN[memoryKind] = newMemoryVN; + fgSetCurrentMemoryVN(memoryKind, newMemoryVN); if ((memoryKind == GcHeap) && byrefStatesMatchGcHeapStates) { // Keep the CurMemoryVNs in sync - fgCurMemoryVN[ByrefExposed] = newMemoryVN; + fgSetCurrentMemoryVN(ByrefExposed, newMemoryVN); } } #ifdef DEBUG @@ -7061,7 +7073,7 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, // If this loop has memory havoc effects, just use a new, unique VN. if (optLoopTable[loopNum].lpLoopHasMemoryHavoc[memoryKind]) { - ValueNum res = vnStore->VNForExpr(entryBlock, TYP_REF); + ValueNum res = vnStore->VNForExpr(entryBlock, TYP_HEAP); #ifdef DEBUG if (verbose) { @@ -7101,7 +7113,7 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, } if (multipleNonLoopPreds) { - ValueNum res = vnStore->VNForExpr(entryBlock, TYP_REF); + ValueNum res = vnStore->VNForExpr(entryBlock, TYP_HEAP); #ifdef DEBUG if (verbose) { @@ -7146,9 +7158,9 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, } #endif // DEBUG - // Instance field maps get the placeholder TYP_REF - they do not represent "singular" + // Instance field maps get a placeholder type - they do not represent "singular" // values. Static field maps, on the other hand, do, and so must be given proper types. - var_types fldMapType = eeIsFieldStatic(fldHnd) ? eeGetFieldType(fldHnd) : TYP_REF; + var_types fldMapType = eeIsFieldStatic(fldHnd) ? eeGetFieldType(fldHnd) : TYP_MEM; newMemoryVN = vnStore->VNForMapStore(newMemoryVN, fldHndVN, vnStore->VNForExpr(entryBlock, fldMapType)); } @@ -7181,7 +7193,7 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, #endif // DEBUG ValueNum elemTypeVN = vnStore->VNForHandle(ssize_t(elemClsHnd), GTF_ICON_CLASS_HDL); - ValueNum uniqueVN = vnStore->VNForExpr(entryBlock, TYP_REF); + ValueNum uniqueVN = vnStore->VNForExpr(entryBlock, TYP_MEM); newMemoryVN = vnStore->VNForMapStore(newMemoryVN, elemTypeVN, uniqueVN); } } @@ -7209,13 +7221,13 @@ ValueNum Compiler::fgMemoryVNForLoopSideEffects(MemoryKind memoryKind, void Compiler::fgMutateGcHeap(GenTree* tree DEBUGARG(const char* msg)) { // Update the current memory VN, and if we're tracking the heap SSA # caused by this node, record it. - recordGcHeapStore(tree, vnStore->VNForExpr(compCurBB, TYP_REF) DEBUGARG(msg)); + recordGcHeapStore(tree, vnStore->VNForExpr(compCurBB, TYP_HEAP) DEBUGARG(msg)); } void Compiler::fgMutateAddressExposedLocal(GenTree* tree DEBUGARG(const char* msg)) { // Update the current ByrefExposed VN, and if we're tracking the heap SSA # caused by this node, record it. - recordAddressExposedLocalStore(tree, vnStore->VNForExpr(compCurBB) DEBUGARG(msg)); + recordAddressExposedLocalStore(tree, vnStore->VNForExpr(compCurBB, TYP_HEAP) DEBUGARG(msg)); } void Compiler::recordGcHeapStore(GenTree* curTree, ValueNum gcHeapVN DEBUGARG(const char* msg)) @@ -7223,13 +7235,13 @@ void Compiler::recordGcHeapStore(GenTree* curTree, ValueNum gcHeapVN DEBUGARG(co // bbMemoryDef must include GcHeap for any block that mutates the GC Heap // and GC Heap mutations are also ByrefExposed mutations assert((compCurBB->bbMemoryDef & memoryKindSet(GcHeap, ByrefExposed)) == memoryKindSet(GcHeap, ByrefExposed)); - fgCurMemoryVN[GcHeap] = gcHeapVN; + fgSetCurrentMemoryVN(GcHeap, gcHeapVN); if (byrefStatesMatchGcHeapStates) { // Since GcHeap and ByrefExposed share SSA nodes, they need to share // value numbers too. - fgCurMemoryVN[ByrefExposed] = gcHeapVN; + fgSetCurrentMemoryVN(ByrefExposed, gcHeapVN); } else { @@ -7237,7 +7249,7 @@ void Compiler::recordGcHeapStore(GenTree* curTree, ValueNum gcHeapVN DEBUGARG(co // assume that this GcHeap store may alias any byref load/store, so don't // bother trying to record the map/select stuff, and instead just an opaque VN // for ByrefExposed - fgCurMemoryVN[ByrefExposed] = vnStore->VNForExpr(compCurBB); + fgSetCurrentMemoryVN(ByrefExposed, vnStore->VNForExpr(compCurBB, TYP_HEAP)); } #ifdef DEBUG @@ -7262,7 +7274,7 @@ void Compiler::recordAddressExposedLocalStore(GenTree* curTree, ValueNum memoryV // bbMemoryDef must include ByrefExposed for any block that mutates an address-exposed local assert((compCurBB->bbMemoryDef & memoryKindSet(ByrefExposed)) != 0); - fgCurMemoryVN[ByrefExposed] = memoryVN; + fgSetCurrentMemoryVN(ByrefExposed, memoryVN); #ifdef DEBUG if (verbose) @@ -7276,6 +7288,13 @@ void Compiler::recordAddressExposedLocalStore(GenTree* curTree, ValueNum memoryV fgValueNumberRecordMemorySsa(ByrefExposed, curTree); } +void Compiler::fgSetCurrentMemoryVN(MemoryKind memoryKind, ValueNum newMemoryVN) +{ + assert(vnStore->VNIsValid(newMemoryVN)); + assert(vnStore->TypeOfVN(newMemoryVN) == TYP_HEAP); + fgCurMemoryVN[memoryKind] = newMemoryVN; +} + void Compiler::fgValueNumberRecordMemorySsa(MemoryKind memoryKind, GenTree* tree) { unsigned ssaNum; @@ -7516,7 +7535,7 @@ void Compiler::fgValueNumberAssignment(GenTreeOp* tree) // through address-taken locals in regions of code with no calls or byref // writes. // For now, just use a new opaque VN. - ValueNum heapVN = vnStore->VNForExpr(compCurBB); + ValueNum heapVN = vnStore->VNForExpr(compCurBB, TYP_HEAP); recordAddressExposedLocalStore(tree, heapVN DEBUGARG("local assign")); } #ifdef DEBUG @@ -7599,7 +7618,7 @@ void Compiler::fgValueNumberAssignment(GenTreeOp* tree) // As with GT_LCL_VAR, we could probably use MapStore here and MapSelect at corresponding // loads, but to do so would have to identify the subset of address-exposed locals // whose fields can be disambiguated. - ValueNum heapVN = vnStore->VNForExpr(compCurBB); + ValueNum heapVN = vnStore->VNForExpr(compCurBB, TYP_HEAP); recordAddressExposedLocalStore(tree, heapVN DEBUGARG("local field assign")); } } @@ -7725,7 +7744,7 @@ void Compiler::fgValueNumberAssignment(GenTreeOp* tree) // through address-taken locals in regions of code with no calls or byref // writes. // For now, just use a new opaque VN. - ValueNum heapVN = vnStore->VNForExpr(compCurBB); + ValueNum heapVN = vnStore->VNForExpr(compCurBB, TYP_HEAP); recordAddressExposedLocalStore(tree, heapVN DEBUGARG("PtrToLoc indir")); } } @@ -7841,8 +7860,8 @@ void Compiler::fgValueNumberAssignment(GenTreeOp* tree) // Construct the "field map" VN. It represents memory state of the first field // of all objects on the heap. This is our primary map. - ValueNum fldMapVN = vnStore->VNForMapSelect(VNK_Liberal, firstFieldType, - fgCurMemoryVN[GcHeap], firstFieldSelectorVN); + ValueNum fldMapVN = vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, fgCurMemoryVN[GcHeap], + firstFieldSelectorVN); ValueNum firstFieldValueSelectorVN = ValueNumStore::NoVN; if (obj != nullptr) @@ -7911,7 +7930,7 @@ void Compiler::fgValueNumberAssignment(GenTreeOp* tree) // through address-taken locals in regions of code with no calls or byref // writes. // For now, just use a new opaque VN. - ValueNum memoryVN = vnStore->VNForExpr(compCurBB); + ValueNum memoryVN = vnStore->VNForExpr(compCurBB, TYP_HEAP); recordAddressExposedLocalStore(tree, memoryVN DEBUGARG("PtrToLoc indir")); } else if (!isLocal) @@ -9026,8 +9045,8 @@ void Compiler::fgValueNumberTree(GenTree* tree) ValueNum firstFieldSelectorVN = vnStore->VNForFieldSelector(fldSeq2->GetFieldHandle(), &firstFieldType, &structSize); - ValueNum fldMapVN = vnStore->VNForMapSelect(VNK_Liberal, firstFieldType, fgCurMemoryVN[GcHeap], - firstFieldSelectorVN); + ValueNum fldMapVN = + vnStore->VNForMapSelect(VNK_Liberal, TYP_MEM, fgCurMemoryVN[GcHeap], firstFieldSelectorVN); ValueNum firstFieldValueSelectorVN; if (obj != nullptr) @@ -10271,9 +10290,6 @@ VNFunc Compiler::fgValueNumberJitHelperMethodVNFunc(CorInfoHelpFunc helpFunc) case CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_DYNAMICCLASS: vnf = VNF_GetsharedNongcthreadstaticBaseDynamicclass; break; - case CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT: - vnf = VNF_GetStaticAddrContext; - break; case CORINFO_HELP_GETSTATICFIELDADDR_TLS: vnf = VNF_GetStaticAddrTLS; break; diff --git a/src/coreclr/jit/valuenum.h b/src/coreclr/jit/valuenum.h index 2d7559dd75fc..a45044b66203 100644 --- a/src/coreclr/jit/valuenum.h +++ b/src/coreclr/jit/valuenum.h @@ -57,17 +57,9 @@ // taken from another map at a given index. As such, it must have a type that corresponds // to the "index/selector", in practical terms - the field's type. // -// Note that the above constraints on the types for maps are not followed currently to the -// letter by the implementation - "opaque" maps can and do have TYP_REF assigned to them -// in various situations such as when initializing the "primary" VNs for loop entries. -// -// Note as well that the meaning of "the type" for a map is overloaded, because maps are used -// both to represent memory "of all fields B of all objects that have this field in the heap" -// and "the field B of this particular object on the heap". Only the latter maps can be used -// as VNs for actual nodes, while the former are used for "the first field" maps and "array -// equivalence type" maps, and, of course, for the heap VNs, which always have the placeholder -// types of TYP_REF or TYP_UNKNOWN. In principle, placeholder types could be given to all the -// maps of the former type. +// Note that we give "placeholder" types (TYP_UNDEF and TYP_UNKNOWN as TYP_MEM and TYP_HEAP) +// to maps that do not represent values found in IR. This is just to avoid confusion and +// facilitate more precise validating checks. // // Let's review the following snippet to demonstrate how the MapSelect/MapStore machinery works // together to deliver the results that it does. Say we have this snippet of (C#) code: @@ -196,6 +188,12 @@ struct VNFuncApp // This define is used with string concatenation to put this in printf format strings #define FMT_VN "$%x" +// We will use this placeholder type for memory maps that do not represent IR values ("field maps", etc). +static const var_types TYP_MEM = TYP_UNDEF; + +// We will use this placeholder type for memory maps representing "the heap" (GcHeap/ByrefExposed). +static const var_types TYP_HEAP = TYP_UNKNOWN; + class ValueNumStore { @@ -1037,9 +1035,11 @@ class ValueNumStore // Used in the implementation of the above. static const char* VNFuncNameArr[]; + // Returns a type name used for "maps", i. e. displays TYP_UNDEF and TYP_UNKNOWN as TYP_MEM and TYP_HEAP. + static const char* VNMapTypeName(var_types type); + // Returns the string name of "vn" when it is a reserved value number, nullptr otherwise static const char* reservedName(ValueNum vn); - #endif // DEBUG // Returns true if "vn" is a reserved value number diff --git a/src/coreclr/jit/valuenumfuncs.h b/src/coreclr/jit/valuenumfuncs.h index 2d7a70dbc748..d5a81d03ca50 100644 --- a/src/coreclr/jit/valuenumfuncs.h +++ b/src/coreclr/jit/valuenumfuncs.h @@ -128,7 +128,6 @@ ValueNumFuncDef(RuntimeHandleMethod, 2, false, true, false) ValueNumFuncDef(RuntimeHandleClass, 2, false, true, false) ValueNumFuncDef(ReadyToRunGenericHandle, 2, false, true, false) -ValueNumFuncDef(GetStaticAddrContext, 1, false, true, false) ValueNumFuncDef(GetStaticAddrTLS, 1, false, true, false) ValueNumFuncDef(JitNew, 2, false, true, false) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index cfa4f195b5f7..8ba6a56645b8 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -275,6 +275,11 @@ The .NET Foundation licenses this file to you under the MIT license. + + + + + diff --git a/src/coreclr/nativeaot/Directory.Build.props b/src/coreclr/nativeaot/Directory.Build.props index a2d48c2f944c..8807dca0c847 100644 --- a/src/coreclr/nativeaot/Directory.Build.props +++ b/src/coreclr/nativeaot/Directory.Build.props @@ -31,7 +31,7 @@ $(NoWarn),0419,0649,CA2249,CA1830 - $(NoWarn);CS8600;CS8602;CS8603;CS8604;CS8610;CS8618;CS8620;CS8625;CS8632;CS8765 + $(NoWarn);CS8600;CS8601;CS8602;CS8603;CS8604;CS8610;CS8618;CS8620;CS8625;CS8632;CS8765 $(NoWarn);CA1810;CA1823;CA1825;CA2208;SA1129;SA1205;SA1400;SA1517 diff --git a/src/coreclr/pal/tests/palsuite/runpaltests.sh b/src/coreclr/pal/tests/palsuite/runpaltests.sh index bda11101095f..e38f2aaa1884 100755 --- a/src/coreclr/pal/tests/palsuite/runpaltests.sh +++ b/src/coreclr/pal/tests/palsuite/runpaltests.sh @@ -99,7 +99,7 @@ PAL_XUNIT_TEST_LIST=$PAL_TEST_OUTPUT_DIR/pal_tests.xml PAL_OUT_FILE=$PAL_TEST_OUTPUT_DIR/pal_test_out # Remove and recreate the temporary test output directory, and the directory where output files were requested to be copied. -if [ "$COPY_TO_TEST_OUTPUT_DIR" == "$PAL_TEST_OUTPUT_DIR" ]; then +if [[ "$COPY_TO_TEST_OUTPUT_DIR" == "$PAL_TEST_OUTPUT_DIR" ]]; then if [ -e $PAL_TEST_OUTPUT_DIR ]; then rm -f -r $PAL_TEST_OUTPUT_DIR fi @@ -158,15 +158,15 @@ do # Change back to the output directory, and remove the test's working directory if it's empty cd $PAL_TEST_OUTPUT_DIR rmdir $TEST_WORKING_DIR 2>/dev/null - + TEST_XUNIT_NAME=$(dirname $TEST_NAME) TEST_XUNIT_CLASSNAME=$(dirname $TEST_XUNIT_NAME) TEST_XUNIT_NAME=${TEST_XUNIT_NAME#*/} TEST_XUNIT_NAME=${TEST_XUNIT_NAME#*/} - + TEST_XUNIT_NAME=$(echo $TEST_XUNIT_NAME | tr / .) TEST_XUNIT_CLASSNAME=$(echo $TEST_XUNIT_CLASSNAME | tr / .) - + echo -n "> $PAL_XUNIT_TEST_LIST_TMP # If the exit code is 0 then the test passed, otherwise record a failure. @@ -175,10 +175,10 @@ do echo "Pass\" />" >> $PAL_XUNIT_TEST_LIST_TMP else echo "Fail\" >" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP - echo "" >> $PAL_XUNIT_TEST_LIST_TMP + echo "" >> $PAL_XUNIT_TEST_LIST_TMP + echo "" >> $PAL_XUNIT_TEST_LIST_TMP + echo "" >> $PAL_XUNIT_TEST_LIST_TMP + echo "" >> $PAL_XUNIT_TEST_LIST_TMP echo "" >> $PAL_XUNIT_TEST_LIST_TMP FAILED_TEST="$TEST_NAME. Exit code: $TEST_EXIT_CODE" echo diff --git a/src/coreclr/pal/tools/smarty.sh b/src/coreclr/pal/tools/smarty.sh index d8b407e72c61..6ab63d949392 100755 --- a/src/coreclr/pal/tools/smarty.sh +++ b/src/coreclr/pal/tools/smarty.sh @@ -15,8 +15,8 @@ then export BVT_ROOT=$PWD fi -if [ -n "$PERL5LIB" ] ; then - if [ -z "`expr $PERL5LIB : ".*\($BVT_ROOT/Common/Smarty\)"`" ] ; then +if [ -n "$PERL5LIB" ]; then + if [ -z "`expr $PERL5LIB : ".*\($BVT_ROOT/Common/Smarty\)"`" ]; then export PERL5LIB="$PERL5LIB:$BVT_ROOT/Common/Smarty" fi else diff --git a/src/coreclr/scripts/superpmi.py b/src/coreclr/scripts/superpmi.py index 267879c5a9eb..8858cee0c4dc 100755 --- a/src/coreclr/scripts/superpmi.py +++ b/src/coreclr/scripts/superpmi.py @@ -210,6 +210,10 @@ more than `limit` failures. """ +compile_help = """\ +Compile only specified method contexts, e.g., `-compile 20,25`. This is passed directly to the superpmi.exe `-compile` argument. See `superpmi.exe -?` for full documentation about allowed formats. +""" + # Start of parser object creation. parser = argparse.ArgumentParser(description=description) @@ -297,6 +301,7 @@ replay_common_parser.add_argument("--force_download", action="store_true", help=force_download_help) replay_common_parser.add_argument("-jit_ee_version", help=jit_ee_version_help) replay_common_parser.add_argument("-private_store", action="append", help=private_store_help) +replay_common_parser.add_argument("-compile", "-c", help=compile_help) # subparser for replay replay_parser = subparsers.add_parser("replay", description=replay_description, parents=[core_root_parser, target_parser, superpmi_common_parser, replay_common_parser]) @@ -1212,7 +1217,7 @@ def replay(self): if self.coreclr_args.arch != self.coreclr_args.target_arch: repro_flags += [ "-target", self.coreclr_args.target_arch ] - if not self.coreclr_args.sequential: + if not self.coreclr_args.sequential and not self.coreclr_args.compile: common_flags += [ "-p" ] if self.coreclr_args.break_on_assert: @@ -1221,6 +1226,9 @@ def replay(self): if self.coreclr_args.break_on_error: common_flags += [ "-boe" ] + if self.coreclr_args.compile: + common_flags += [ "-c", self.coreclr_args.compile ] + if self.coreclr_args.spmi_log_file is not None: common_flags += [ "-w", self.coreclr_args.spmi_log_file ] @@ -1452,7 +1460,7 @@ def replay_with_asm_diffs(self): flags += base_option_flags flags += diff_option_flags - if not self.coreclr_args.sequential: + if not self.coreclr_args.sequential and not self.coreclr_args.compile: flags += [ "-p" ] if self.coreclr_args.break_on_assert: @@ -1461,6 +1469,9 @@ def replay_with_asm_diffs(self): if self.coreclr_args.break_on_error: flags += [ "-boe" ] + if self.coreclr_args.compile: + flags += [ "-c", self.coreclr_args.compile ] + if self.coreclr_args.spmi_log_file is not None: flags += [ "-w", self.coreclr_args.spmi_log_file ] @@ -2970,6 +2981,11 @@ def verify_replay_common_args(): lambda unused: True, "Unable to set mch_files") + coreclr_args.verify(args, + "compile", + lambda unused: True, + "Method context not valid") + coreclr_args.verify(args, "private_store", lambda item: True, diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs index 5e5c89774b7c..8c552704c708 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoBase.cs @@ -674,21 +674,6 @@ static uint _getClassAttribs(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLA } } - [UnmanagedCallersOnly] - static byte _isStructRequiringStackAllocRetBuf(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) - { - var _this = GetThis(thisHandle); - try - { - return _this.isStructRequiringStackAllocRetBuf(cls) ? (byte)1 : (byte)0; - } - catch (Exception ex) - { - *ppException = _this.AllocException(ex); - return default; - } - } - [UnmanagedCallersOnly] static CORINFO_MODULE_STRUCT_* _getClassModule(IntPtr thisHandle, IntPtr* ppException, CORINFO_CLASS_STRUCT_* cls) { @@ -2581,7 +2566,7 @@ static byte _doesFieldBelongToClass(IntPtr thisHandle, IntPtr* ppException, CORI static IntPtr GetUnmanagedCallbacks() { - void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 174); + void** callbacks = (void**)Marshal.AllocCoTaskMem(sizeof(IntPtr) * 173); callbacks[0] = (delegate* unmanaged)&_isJitIntrinsic; callbacks[1] = (delegate* unmanaged)&_getMethodAttribs; @@ -2628,135 +2613,134 @@ static IntPtr GetUnmanagedCallbacks() callbacks[42] = (delegate* unmanaged)&_isValueClass; callbacks[43] = (delegate* unmanaged)&_canInlineTypeCheck; callbacks[44] = (delegate* unmanaged)&_getClassAttribs; - callbacks[45] = (delegate* unmanaged)&_isStructRequiringStackAllocRetBuf; - callbacks[46] = (delegate* unmanaged)&_getClassModule; - callbacks[47] = (delegate* unmanaged)&_getModuleAssembly; - callbacks[48] = (delegate* unmanaged)&_getAssemblyName; - callbacks[49] = (delegate* unmanaged)&_LongLifetimeMalloc; - callbacks[50] = (delegate* unmanaged)&_LongLifetimeFree; - callbacks[51] = (delegate* unmanaged)&_getClassModuleIdForStatics; - callbacks[52] = (delegate* unmanaged)&_getClassSize; - callbacks[53] = (delegate* unmanaged)&_getHeapClassSize; - callbacks[54] = (delegate* unmanaged)&_canAllocateOnStack; - callbacks[55] = (delegate* unmanaged)&_getClassAlignmentRequirement; - callbacks[56] = (delegate* unmanaged)&_getClassGClayout; - callbacks[57] = (delegate* unmanaged)&_getClassNumInstanceFields; - callbacks[58] = (delegate* unmanaged)&_getFieldInClass; - callbacks[59] = (delegate* unmanaged)&_checkMethodModifier; - callbacks[60] = (delegate* unmanaged)&_getNewHelper; - callbacks[61] = (delegate* unmanaged)&_getNewArrHelper; - callbacks[62] = (delegate* unmanaged)&_getCastingHelper; - callbacks[63] = (delegate* unmanaged)&_getSharedCCtorHelper; - callbacks[64] = (delegate* unmanaged)&_getTypeForBox; - callbacks[65] = (delegate* unmanaged)&_getBoxHelper; - callbacks[66] = (delegate* unmanaged)&_getUnBoxHelper; - callbacks[67] = (delegate* unmanaged)&_getReadyToRunHelper; - callbacks[68] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; - callbacks[69] = (delegate* unmanaged)&_getHelperName; - callbacks[70] = (delegate* unmanaged)&_initClass; - callbacks[71] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; - callbacks[72] = (delegate* unmanaged)&_getBuiltinClass; - callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; - callbacks[74] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; - callbacks[75] = (delegate* unmanaged)&_canCast; - callbacks[76] = (delegate* unmanaged)&_areTypesEquivalent; - callbacks[77] = (delegate* unmanaged)&_compareTypesForCast; - callbacks[78] = (delegate* unmanaged)&_compareTypesForEquality; - callbacks[79] = (delegate* unmanaged)&_mergeClasses; - callbacks[80] = (delegate* unmanaged)&_isMoreSpecificType; - callbacks[81] = (delegate* unmanaged)&_getParentType; - callbacks[82] = (delegate* unmanaged)&_getChildType; - callbacks[83] = (delegate* unmanaged)&_satisfiesClassConstraints; - callbacks[84] = (delegate* unmanaged)&_isSDArray; - callbacks[85] = (delegate* unmanaged)&_getArrayRank; - callbacks[86] = (delegate* unmanaged)&_getArrayInitializationData; - callbacks[87] = (delegate* unmanaged)&_canAccessClass; - callbacks[88] = (delegate* unmanaged)&_getFieldName; - callbacks[89] = (delegate* unmanaged)&_getFieldClass; - callbacks[90] = (delegate* unmanaged)&_getFieldType; - callbacks[91] = (delegate* unmanaged)&_getFieldOffset; - callbacks[92] = (delegate* unmanaged)&_getFieldInfo; - callbacks[93] = (delegate* unmanaged)&_isFieldStatic; - callbacks[94] = (delegate* unmanaged)&_getBoundaries; - callbacks[95] = (delegate* unmanaged)&_setBoundaries; - callbacks[96] = (delegate* unmanaged)&_getVars; - callbacks[97] = (delegate* unmanaged)&_setVars; - callbacks[98] = (delegate* unmanaged)&_allocateArray; - callbacks[99] = (delegate* unmanaged)&_freeArray; - callbacks[100] = (delegate* unmanaged)&_getArgNext; - callbacks[101] = (delegate* unmanaged)&_getArgType; - callbacks[102] = (delegate* unmanaged)&_getArgClass; - callbacks[103] = (delegate* unmanaged)&_getHFAType; - callbacks[104] = (delegate* unmanaged)&_GetErrorHRESULT; - callbacks[105] = (delegate* unmanaged)&_GetErrorMessage; - callbacks[106] = (delegate* unmanaged)&_FilterException; - callbacks[107] = (delegate* unmanaged)&_ThrowExceptionForJitResult; - callbacks[108] = (delegate* unmanaged)&_ThrowExceptionForHelper; - callbacks[109] = (delegate* unmanaged)&_runWithErrorTrap; - callbacks[110] = (delegate* unmanaged)&_runWithSPMIErrorTrap; - callbacks[111] = (delegate* unmanaged)&_getEEInfo; - callbacks[112] = (delegate* unmanaged)&_getJitTimeLogFilename; - callbacks[113] = (delegate* unmanaged)&_getMethodDefFromMethod; - callbacks[114] = (delegate* unmanaged)&_getMethodName; - callbacks[115] = (delegate* unmanaged)&_getMethodNameFromMetadata; - callbacks[116] = (delegate* unmanaged)&_getMethodHash; - callbacks[117] = (delegate* unmanaged)&_findNameOfToken; - callbacks[118] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; - callbacks[119] = (delegate* unmanaged)&_getThreadTLSIndex; - callbacks[120] = (delegate* unmanaged)&_getInlinedCallFrameVptr; - callbacks[121] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; - callbacks[122] = (delegate* unmanaged)&_getHelperFtn; - callbacks[123] = (delegate* unmanaged)&_getFunctionEntryPoint; - callbacks[124] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; - callbacks[125] = (delegate* unmanaged)&_getMethodSync; - callbacks[126] = (delegate* unmanaged)&_getLazyStringLiteralHelper; - callbacks[127] = (delegate* unmanaged)&_embedModuleHandle; - callbacks[128] = (delegate* unmanaged)&_embedClassHandle; - callbacks[129] = (delegate* unmanaged)&_embedMethodHandle; - callbacks[130] = (delegate* unmanaged)&_embedFieldHandle; - callbacks[131] = (delegate* unmanaged)&_embedGenericHandle; - callbacks[132] = (delegate* unmanaged)&_getLocationOfThisType; - callbacks[133] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; - callbacks[134] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; - callbacks[135] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; - callbacks[136] = (delegate* unmanaged)&_getJustMyCodeHandle; - callbacks[137] = (delegate* unmanaged)&_GetProfilingHandle; - callbacks[138] = (delegate* unmanaged)&_getCallInfo; - callbacks[139] = (delegate* unmanaged)&_canAccessFamily; - callbacks[140] = (delegate* unmanaged)&_isRIDClassDomainID; - callbacks[141] = (delegate* unmanaged)&_getClassDomainID; - callbacks[142] = (delegate* unmanaged)&_getFieldAddress; - callbacks[143] = (delegate* unmanaged)&_getStaticFieldCurrentClass; - callbacks[144] = (delegate* unmanaged)&_getVarArgsHandle; - callbacks[145] = (delegate* unmanaged)&_canGetVarArgsHandle; - callbacks[146] = (delegate* unmanaged)&_constructStringLiteral; - callbacks[147] = (delegate* unmanaged)&_emptyStringLiteral; - callbacks[148] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; - callbacks[149] = (delegate* unmanaged)&_setOverride; - callbacks[150] = (delegate* unmanaged)&_addActiveDependency; - callbacks[151] = (delegate* unmanaged)&_GetDelegateCtor; - callbacks[152] = (delegate* unmanaged)&_MethodCompileComplete; - callbacks[153] = (delegate* unmanaged)&_getTailCallHelpers; - callbacks[154] = (delegate* unmanaged)&_convertPInvokeCalliToCall; - callbacks[155] = (delegate* unmanaged)&_notifyInstructionSetUsage; - callbacks[156] = (delegate* unmanaged)&_updateEntryPointForTailCall; - callbacks[157] = (delegate* unmanaged)&_allocMem; - callbacks[158] = (delegate* unmanaged)&_reserveUnwindInfo; - callbacks[159] = (delegate* unmanaged)&_allocUnwindInfo; - callbacks[160] = (delegate* unmanaged)&_allocGCInfo; - callbacks[161] = (delegate* unmanaged)&_setEHcount; - callbacks[162] = (delegate* unmanaged)&_setEHinfo; - callbacks[163] = (delegate* unmanaged)&_logMsg; - callbacks[164] = (delegate* unmanaged)&_doAssert; - callbacks[165] = (delegate* unmanaged)&_reportFatalError; - callbacks[166] = (delegate* unmanaged)&_getPgoInstrumentationResults; - callbacks[167] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; - callbacks[168] = (delegate* unmanaged)&_recordCallSite; - callbacks[169] = (delegate* unmanaged)&_recordRelocation; - callbacks[170] = (delegate* unmanaged)&_getRelocTypeHint; - callbacks[171] = (delegate* unmanaged)&_getExpectedTargetArchitecture; - callbacks[172] = (delegate* unmanaged)&_getJitFlags; - callbacks[173] = (delegate* unmanaged)&_doesFieldBelongToClass; + callbacks[45] = (delegate* unmanaged)&_getClassModule; + callbacks[46] = (delegate* unmanaged)&_getModuleAssembly; + callbacks[47] = (delegate* unmanaged)&_getAssemblyName; + callbacks[48] = (delegate* unmanaged)&_LongLifetimeMalloc; + callbacks[49] = (delegate* unmanaged)&_LongLifetimeFree; + callbacks[50] = (delegate* unmanaged)&_getClassModuleIdForStatics; + callbacks[51] = (delegate* unmanaged)&_getClassSize; + callbacks[52] = (delegate* unmanaged)&_getHeapClassSize; + callbacks[53] = (delegate* unmanaged)&_canAllocateOnStack; + callbacks[54] = (delegate* unmanaged)&_getClassAlignmentRequirement; + callbacks[55] = (delegate* unmanaged)&_getClassGClayout; + callbacks[56] = (delegate* unmanaged)&_getClassNumInstanceFields; + callbacks[57] = (delegate* unmanaged)&_getFieldInClass; + callbacks[58] = (delegate* unmanaged)&_checkMethodModifier; + callbacks[59] = (delegate* unmanaged)&_getNewHelper; + callbacks[60] = (delegate* unmanaged)&_getNewArrHelper; + callbacks[61] = (delegate* unmanaged)&_getCastingHelper; + callbacks[62] = (delegate* unmanaged)&_getSharedCCtorHelper; + callbacks[63] = (delegate* unmanaged)&_getTypeForBox; + callbacks[64] = (delegate* unmanaged)&_getBoxHelper; + callbacks[65] = (delegate* unmanaged)&_getUnBoxHelper; + callbacks[66] = (delegate* unmanaged)&_getReadyToRunHelper; + callbacks[67] = (delegate* unmanaged)&_getReadyToRunDelegateCtorHelper; + callbacks[68] = (delegate* unmanaged)&_getHelperName; + callbacks[69] = (delegate* unmanaged)&_initClass; + callbacks[70] = (delegate* unmanaged)&_classMustBeLoadedBeforeCodeIsRun; + callbacks[71] = (delegate* unmanaged)&_getBuiltinClass; + callbacks[72] = (delegate* unmanaged)&_getTypeForPrimitiveValueClass; + callbacks[73] = (delegate* unmanaged)&_getTypeForPrimitiveNumericClass; + callbacks[74] = (delegate* unmanaged)&_canCast; + callbacks[75] = (delegate* unmanaged)&_areTypesEquivalent; + callbacks[76] = (delegate* unmanaged)&_compareTypesForCast; + callbacks[77] = (delegate* unmanaged)&_compareTypesForEquality; + callbacks[78] = (delegate* unmanaged)&_mergeClasses; + callbacks[79] = (delegate* unmanaged)&_isMoreSpecificType; + callbacks[80] = (delegate* unmanaged)&_getParentType; + callbacks[81] = (delegate* unmanaged)&_getChildType; + callbacks[82] = (delegate* unmanaged)&_satisfiesClassConstraints; + callbacks[83] = (delegate* unmanaged)&_isSDArray; + callbacks[84] = (delegate* unmanaged)&_getArrayRank; + callbacks[85] = (delegate* unmanaged)&_getArrayInitializationData; + callbacks[86] = (delegate* unmanaged)&_canAccessClass; + callbacks[87] = (delegate* unmanaged)&_getFieldName; + callbacks[88] = (delegate* unmanaged)&_getFieldClass; + callbacks[89] = (delegate* unmanaged)&_getFieldType; + callbacks[90] = (delegate* unmanaged)&_getFieldOffset; + callbacks[91] = (delegate* unmanaged)&_getFieldInfo; + callbacks[92] = (delegate* unmanaged)&_isFieldStatic; + callbacks[93] = (delegate* unmanaged)&_getBoundaries; + callbacks[94] = (delegate* unmanaged)&_setBoundaries; + callbacks[95] = (delegate* unmanaged)&_getVars; + callbacks[96] = (delegate* unmanaged)&_setVars; + callbacks[97] = (delegate* unmanaged)&_allocateArray; + callbacks[98] = (delegate* unmanaged)&_freeArray; + callbacks[99] = (delegate* unmanaged)&_getArgNext; + callbacks[100] = (delegate* unmanaged)&_getArgType; + callbacks[101] = (delegate* unmanaged)&_getArgClass; + callbacks[102] = (delegate* unmanaged)&_getHFAType; + callbacks[103] = (delegate* unmanaged)&_GetErrorHRESULT; + callbacks[104] = (delegate* unmanaged)&_GetErrorMessage; + callbacks[105] = (delegate* unmanaged)&_FilterException; + callbacks[106] = (delegate* unmanaged)&_ThrowExceptionForJitResult; + callbacks[107] = (delegate* unmanaged)&_ThrowExceptionForHelper; + callbacks[108] = (delegate* unmanaged)&_runWithErrorTrap; + callbacks[109] = (delegate* unmanaged)&_runWithSPMIErrorTrap; + callbacks[110] = (delegate* unmanaged)&_getEEInfo; + callbacks[111] = (delegate* unmanaged)&_getJitTimeLogFilename; + callbacks[112] = (delegate* unmanaged)&_getMethodDefFromMethod; + callbacks[113] = (delegate* unmanaged)&_getMethodName; + callbacks[114] = (delegate* unmanaged)&_getMethodNameFromMetadata; + callbacks[115] = (delegate* unmanaged)&_getMethodHash; + callbacks[116] = (delegate* unmanaged)&_findNameOfToken; + callbacks[117] = (delegate* unmanaged)&_getSystemVAmd64PassStructInRegisterDescriptor; + callbacks[118] = (delegate* unmanaged)&_getThreadTLSIndex; + callbacks[119] = (delegate* unmanaged)&_getInlinedCallFrameVptr; + callbacks[120] = (delegate* unmanaged)&_getAddrOfCaptureThreadGlobal; + callbacks[121] = (delegate* unmanaged)&_getHelperFtn; + callbacks[122] = (delegate* unmanaged)&_getFunctionEntryPoint; + callbacks[123] = (delegate* unmanaged)&_getFunctionFixedEntryPoint; + callbacks[124] = (delegate* unmanaged)&_getMethodSync; + callbacks[125] = (delegate* unmanaged)&_getLazyStringLiteralHelper; + callbacks[126] = (delegate* unmanaged)&_embedModuleHandle; + callbacks[127] = (delegate* unmanaged)&_embedClassHandle; + callbacks[128] = (delegate* unmanaged)&_embedMethodHandle; + callbacks[129] = (delegate* unmanaged)&_embedFieldHandle; + callbacks[130] = (delegate* unmanaged)&_embedGenericHandle; + callbacks[131] = (delegate* unmanaged)&_getLocationOfThisType; + callbacks[132] = (delegate* unmanaged)&_getAddressOfPInvokeTarget; + callbacks[133] = (delegate* unmanaged)&_GetCookieForPInvokeCalliSig; + callbacks[134] = (delegate* unmanaged)&_canGetCookieForPInvokeCalliSig; + callbacks[135] = (delegate* unmanaged)&_getJustMyCodeHandle; + callbacks[136] = (delegate* unmanaged)&_GetProfilingHandle; + callbacks[137] = (delegate* unmanaged)&_getCallInfo; + callbacks[138] = (delegate* unmanaged)&_canAccessFamily; + callbacks[139] = (delegate* unmanaged)&_isRIDClassDomainID; + callbacks[140] = (delegate* unmanaged)&_getClassDomainID; + callbacks[141] = (delegate* unmanaged)&_getFieldAddress; + callbacks[142] = (delegate* unmanaged)&_getStaticFieldCurrentClass; + callbacks[143] = (delegate* unmanaged)&_getVarArgsHandle; + callbacks[144] = (delegate* unmanaged)&_canGetVarArgsHandle; + callbacks[145] = (delegate* unmanaged)&_constructStringLiteral; + callbacks[146] = (delegate* unmanaged)&_emptyStringLiteral; + callbacks[147] = (delegate* unmanaged)&_getFieldThreadLocalStoreID; + callbacks[148] = (delegate* unmanaged)&_setOverride; + callbacks[149] = (delegate* unmanaged)&_addActiveDependency; + callbacks[150] = (delegate* unmanaged)&_GetDelegateCtor; + callbacks[151] = (delegate* unmanaged)&_MethodCompileComplete; + callbacks[152] = (delegate* unmanaged)&_getTailCallHelpers; + callbacks[153] = (delegate* unmanaged)&_convertPInvokeCalliToCall; + callbacks[154] = (delegate* unmanaged)&_notifyInstructionSetUsage; + callbacks[155] = (delegate* unmanaged)&_updateEntryPointForTailCall; + callbacks[156] = (delegate* unmanaged)&_allocMem; + callbacks[157] = (delegate* unmanaged)&_reserveUnwindInfo; + callbacks[158] = (delegate* unmanaged)&_allocUnwindInfo; + callbacks[159] = (delegate* unmanaged)&_allocGCInfo; + callbacks[160] = (delegate* unmanaged)&_setEHcount; + callbacks[161] = (delegate* unmanaged)&_setEHinfo; + callbacks[162] = (delegate* unmanaged)&_logMsg; + callbacks[163] = (delegate* unmanaged)&_doAssert; + callbacks[164] = (delegate* unmanaged)&_reportFatalError; + callbacks[165] = (delegate* unmanaged)&_getPgoInstrumentationResults; + callbacks[166] = (delegate* unmanaged)&_allocPgoInstrumentationBySchema; + callbacks[167] = (delegate* unmanaged)&_recordCallSite; + callbacks[168] = (delegate* unmanaged)&_recordRelocation; + callbacks[169] = (delegate* unmanaged)&_getRelocTypeHint; + callbacks[170] = (delegate* unmanaged)&_getExpectedTargetArchitecture; + callbacks[171] = (delegate* unmanaged)&_getJitFlags; + callbacks[172] = (delegate* unmanaged)&_doesFieldBelongToClass; return (IntPtr)callbacks; } diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs index 6bc8a1999877..0765a56b21e1 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoHelpFunc.cs @@ -165,7 +165,6 @@ which is the right helper to use to allocate an object of a given type. */ CORINFO_HELP_GETFIELDADDR, - CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT, // Helper for context-static fields CORINFO_HELP_GETSTATICFIELDADDR_TLS, // Helper for PE TLS fields // There are a variety of specialized helpers for accessing static fields. The JIT should use diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.Intrinsics.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.Intrinsics.cs index ac2eb0668591..50f7783be865 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.Intrinsics.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.Intrinsics.cs @@ -79,7 +79,6 @@ static IntrinsicHashtable InitializeIntrinsicHashtable() table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_Array_Get, "Get", null, null); table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_Array_Address, "Address", null, null); table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_Array_Set, "Set", null, null); - table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_InitializeArray, "InitializeArray", "System.Runtime.CompilerServices", "RuntimeHelpers"); table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_RTH_GetValueInternal, "GetValueInternal", "System", "RuntimeTypeHandle"); table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_Object_GetType, "GetType", "System", "Object"); table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_StubHelpers_GetStubContext, "GetStubContext", "System.StubHelpers", "StubHelpers"); // interop-specific @@ -136,9 +135,6 @@ private CorInfoIntrinsics getIntrinsicID(MethodDesc method, byte* pMustExpand) break; case CorInfoIntrinsics.CORINFO_INTRINSIC_RTH_GetValueInternal: -#if !READYTORUN - case CorInfoIntrinsics.CORINFO_INTRINSIC_InitializeArray: -#endif case CorInfoIntrinsics.CORINFO_INTRINSIC_ByReference_Ctor: case CorInfoIntrinsics.CORINFO_INTRINSIC_ByReference_Value: if (pMustExpand != null) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 8d3ea0a5950a..19c4c28f9d37 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2015,13 +2015,6 @@ private uint getClassAttribsInternal(TypeDesc type) return (uint)result; } - private bool isStructRequiringStackAllocRetBuf(CORINFO_CLASS_STRUCT_* cls) - { - // Disable this optimization. It has limited value (only kicks in on x86, and only for less common structs), - // causes bugs and introduces odd ABI differences not compatible with ReadyToRun. - return false; - } - private CORINFO_MODULE_STRUCT_* getClassModule(CORINFO_CLASS_STRUCT_* cls) { throw new NotImplementedException("getClassModule"); } private CORINFO_ASSEMBLY_STRUCT_* getModuleAssembly(CORINFO_MODULE_STRUCT_* mod) diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs index d741ea823c51..bc6d53514df1 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoTypes.cs @@ -442,7 +442,6 @@ public enum CorInfoIntrinsics CORINFO_INTRINSIC_Array_Get, // Get the value of an element in an array CORINFO_INTRINSIC_Array_Address, // Get the address of an element in an array CORINFO_INTRINSIC_Array_Set, // Set the value of an element in an array - CORINFO_INTRINSIC_InitializeArray, // initialize an array from static data CORINFO_INTRINSIC_RTH_GetValueInternal, CORINFO_INTRINSIC_Object_GetType, CORINFO_INTRINSIC_StubHelpers_GetStubContext, diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt index b981056c834b..76982cd7aaff 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt @@ -198,7 +198,6 @@ FUNCTIONS bool isValueClass(CORINFO_CLASS_HANDLE cls) CorInfoInlineTypeCheck canInlineTypeCheck(CORINFO_CLASS_HANDLE cls, CorInfoInlineTypeCheckSource source) uint32_t getClassAttribs(CORINFO_CLASS_HANDLE cls) - bool isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE cls) CORINFO_MODULE_HANDLE getClassModule(CORINFO_CLASS_HANDLE cls) CORINFO_ASSEMBLY_HANDLE getModuleAssembly(CORINFO_MODULE_HANDLE mod) const char* getAssemblyName(CORINFO_ASSEMBLY_HANDLE assem) diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PgoInfoKey.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PgoInfoKey.cs index 01405217d8d4..e25f3779d9b2 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PgoInfoKey.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/PgoInfoKey.cs @@ -111,7 +111,7 @@ public PgoInfoKey(IAssemblyMetadata componentReader, string owningType, EntityHa { sb.Append(", "); } - sb.AppendFormat($"{Signature.ParameterTypes[i]}"); + sb.Append($"{Signature.ParameterTypes[i]}"); } sb.Append(")"); @@ -135,4 +135,4 @@ public static PgoInfoKey FromReadyToRunMethod(ReadyToRunMethod method) return key; } } -} \ No newline at end of file +} diff --git a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs index 9032ef274217..e1a8b87a764c 100644 --- a/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs +++ b/src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunMethod.cs @@ -465,7 +465,7 @@ public ReadyToRunMethod( { sb.Append(", "); } - sb.AppendFormat($"{Signature.ParameterTypes[i]}"); + sb.Append($"{Signature.ParameterTypes[i]}"); } sb.Append(")"); diff --git a/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj b/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj index 9f5c9844d002..0194a7f6e432 100644 --- a/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj +++ b/src/coreclr/tools/aot/ILCompiler/repro/repro.csproj @@ -32,6 +32,9 @@ + + + isStructRequiringStackAllocRetBuf(_thisHandle, &pException, cls); - if (pException != nullptr) throw pException; - return temp; -} - virtual CORINFO_MODULE_HANDLE getClassModule( CORINFO_CLASS_HANDLE cls) { diff --git a/src/coreclr/vm/ecalllist.h b/src/coreclr/vm/ecalllist.h index 01a9ef6c7332..afdbf678d118 100644 --- a/src/coreclr/vm/ecalllist.h +++ b/src/coreclr/vm/ecalllist.h @@ -625,7 +625,7 @@ FCFuncEnd() FCFuncStart(gRuntimeHelpers) FCFuncElement("GetObjectValue", ObjectNative::GetObjectValue) - FCIntrinsic("InitializeArray", ArrayNative::InitializeArray, CORINFO_INTRINSIC_InitializeArray) + FCFuncElement("InitializeArray", ArrayNative::InitializeArray) FCFuncElement("GetSpanDataFrom", ArrayNative::GetSpanDataFrom) FCFuncElement("PrepareDelegate", ReflectionInvocation::PrepareDelegate) FCFuncElement("GetHashCode", ObjectNative::GetHashCode) diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index e5646fc9ab19..94d710109489 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -3613,29 +3613,6 @@ uint32_t CEEInfo::getClassAttribs (CORINFO_CLASS_HANDLE clsHnd) return ret; } - -/*********************************************************************/ -bool CEEInfo::isStructRequiringStackAllocRetBuf(CORINFO_CLASS_HANDLE clsHnd) -{ - CONTRACTL { - THROWS; - GC_TRIGGERS; - MODE_PREEMPTIVE; - } CONTRACTL_END; - - bool ret = 0; - - JIT_TO_EE_TRANSITION_LEAF(); - - // Disable this optimization. It has limited value (only kicks in on x86, and only for less common structs), - // causes bugs and introduces odd ABI differences not compatible with ReadyToRun. - ret = false; - - EE_TO_JIT_TRANSITION_LEAF(); - - return ret; -} - /*********************************************************************/ uint32_t CEEInfo::getClassAttribsInternal (CORINFO_CLASS_HANDLE clsHnd) { diff --git a/src/installer/tests/scripts/linux-test/RuntimeInstallation.sh b/src/installer/tests/scripts/linux-test/RuntimeInstallation.sh index c4ec682f1965..df6fec7846ed 100644 --- a/src/installer/tests/scripts/linux-test/RuntimeInstallation.sh +++ b/src/installer/tests/scripts/linux-test/RuntimeInstallation.sh @@ -1,7 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash current_user=$(whoami) -if [ $current_user != "root" ]; then +if [[ "$current_user" != "root" ]]; then echo "script requires superuser privileges to run" exit 1 fi @@ -15,35 +15,34 @@ log_file="/docker/logfile.txt" exec &>> $log_file -if [ $ID == "ol" ] ; then +if [[ "$ID" == "ol" ]]; then distro="oraclelinux" fi -if [ "$distro" == "oraclelinux" ] || [ "$distro" == "rhel" ] || [ "$distro" == "opensuse" ] ; then +if [[ "$distro" == "oraclelinux" || "$distro" == "rhel" || "$distro" == "opensuse" ]]; then version=$(echo $version | cut -d . -f 1) -fi +fi echo $distro:$version runtime_version=$1 -if [ "$runtime_version" == "latest" ] ; -then +if [[ "$runtime_version" == "latest" ]]; then BLOB_RUNTIME_DIR="https://dotnetcli.blob.core.windows.net/dotnet/Runtime/master" else BLOB_RUNTIME_DIR="https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$runtime_version" fi install_curl(){ - apt-get -y install curl - if [ $? -ne 0 ] ; then + apt-get -y install curl + if [ $? -ne 0 ]; then apt-get update apt-get -y install curl fi } download_from_blob_deb(){ BLOB_PATH=$1 - if curl --output /dev/null --head --fail $BLOB_PATH; then + if curl --output /dev/null --head --fail $BLOB_PATH; then curl -O -s $BLOB_PATH - else + else echo "Could not extract file from blob" exit 1 fi @@ -60,14 +59,14 @@ install_runtime_packages_deb(){ dpkg -i *.deb } determine_runtime_version_deb(){ - if [ "$runtime_version" == "latest" ] ; then + if [[ "$runtime_version" == "latest" ]]; then runtime_version=$(dpkg-deb -f dotnet-runtime-latest-$arch.deb Package) runtime_version=${runtime_version#dotnet-runtime-} fi } check_if_runtime_is_installed_deb(){ find_runtime=$(apt list --installed | grep dotnet-runtime-$runtime_version) - if [ "$find_runtime" == "" ] ; then + if [[ -z "$find_runtime" ]]; then echo "Not able to remove runtime $runtime_version because it is not installed" exit 1 fi @@ -84,9 +83,9 @@ install_wget_zypper(){ } download_from_blob_rpm(){ BLOB_PATH=$1 - if wget --spider $BLOB_PATH; then - wget -nv $BLOB_PATH - else + if wget --spider $BLOB_PATH; then + wget -nv $BLOB_PATH + else echo "Could not extract file from blob" exit 1 fi @@ -108,7 +107,7 @@ install_runtime_packages_zypper(){ rpm -Uvh *.rpm } determine_runtime_version_rpm(){ - if [ "$runtime_version" == "latest" ] ; then + if [[ "$runtime_version" == "latest" ]]; then runtime_version=$(rpm -qip dotnet-runtime-latest-$arch.rpm | grep Version) runtime_version=$(echo $runtime_version | cut -d ":" -f 2) runtime_version=$(echo $runtime_version | tr _ -) @@ -116,7 +115,7 @@ determine_runtime_version_rpm(){ } check_if_runtime_is_installed_rpm(){ find_runtime=$(rpm -qa | grep dotnet-runtime-$runtime_version) - if [ "$find_runtime" == "" ] ; then + if [[ -z "$find_runtime" ]]; then echo "Not able to remove runtime $runtime_version because it is not installed" exit 1 fi @@ -130,9 +129,9 @@ uninstall_runtime_zypper(){ runtime_installed_packages=$(rpm -qa | grep -e dotnet) } determine_success_install(){ - if [ -e $result_file ] ; then + if [ -e $result_file ]; then installed_runtime=$(dotnet --list-runtimes | grep $runtime_version) - if [ "$installed_runtime" != "" ] ; then + if [[ -n "$installed_runtime" ]]; then success_install=1 else success_install=0 @@ -140,8 +139,8 @@ determine_success_install(){ fi } test_result_install(){ - if [ -e $result_file ] ; then - if [ $success_install -eq 1 ] ; then + if [ -e $result_file ]; then + if [ $success_install -eq 1 ]; then echo "$distro:$version install -> passed" >> $result_file else echo "$distro:$version install -> failed" >> $result_file @@ -149,19 +148,19 @@ test_result_install(){ fi } uninstall_latest_runtime_warning(){ - if [ "$runtime_version" == "latest" ] ; then + if [[ "$runtime_version" == "latest" ]]; then echo "Specify runtime version to unistall. Type dotnet --list-runtimes to see runtimes versions installed" exit 1 - fi + fi } test_result_uninstall(){ - if [ "$runtime_installed_packages" == "" ] ; then + if [[ -z "$runtime_installed_packages" ]]; then success_uninstall=1 else success_uninstall=0 fi - if [ -e $result_file ] ; then - if [ $success_uninstall -eq 1 ] ; then + if [ -e $result_file ]; then + if [ $success_uninstall -eq 1 ]; then echo "$distro:$version uninstall -> passed" >> $result_file else echo "$distro:$version uninstall -> failed" >> $result_file @@ -169,10 +168,10 @@ test_result_uninstall(){ fi } -if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] ; then - if [ "$2" == "install" ] ; then - install_curl - +if [[ "$distro" == "ubuntu" || "$distro" == "debian" ]]; then + if [[ "$2" == "install" ]]; then + install_curl + download_runtime_packages_deb install_runtime_packages_deb dotnet --list-runtimes @@ -180,19 +179,19 @@ if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] ; then determine_runtime_version_deb determine_success_install test_result_install - - elif [ "$2" == "uninstall" ] ; then + + elif [[ "$2" == "uninstall" ]]; then uninstall_latest_runtime_warning - fi + fi - if [ "$3" == "uninstall" ] || [ "$2" == "uninstall" ] ; then + if [[ "$3" == "uninstall" || "$2" == "uninstall" ]]; then check_if_runtime_is_installed_deb uninstall_runtime_deb test_result_uninstall fi -elif [ "$distro" == "fedora" ] || [ "$distro" == "centos" ] || [ "$distro" == "oraclelinux" ] || [ "$distro" == "rhel" ] ; then - if [ "$2" == "install" ] ; then +elif [[ "$distro" == "fedora" || "$distro" == "centos" || "$distro" == "oraclelinux" || "$distro" == "rhel" ]]; then + if [[ "$2" == "install" ]]; then install_wget_yum download_runtime_packages_rpm @@ -204,39 +203,39 @@ elif [ "$distro" == "fedora" ] || [ "$distro" == "centos" ] || [ "$distro" == "o determine_success_install test_result_install - elif [ "$2" == "uninstall" ] ; then - uninstall_latest_runtime_warning + elif [[ "$2" == "uninstall" ]]; then + uninstall_latest_runtime_warning fi - if [ "$3" == "uninstall" ] || [ "$2" == "uninstall" ] ; then + if [[ "$3" == "uninstall" || "$2" == "uninstall" ]]; then check_if_runtime_is_installed_rpm uninstall_runtime_yum test_result_uninstall fi -elif [ "$distro" == "opensuse" ] || [ "$distro" == "sles" ] ; then - if [ "$2" == "install" ] ; then +elif [[ "$distro" == "opensuse" || "$distro" == "sles" ]]; then + if [[ "$2" == "install" ]]; then install_wget_zypper download_runtime_packages_rpm install_runtime_packages_zypper dotnet --list-runtimes - + determine_runtime_version_rpm determine_success_install test_result_install - - elif [ "$2" == "uninstall" ] ; then - uninstall_latest_runtime_warning + + elif [[ "$2" == "uninstall" ]]; then + uninstall_latest_runtime_warning fi - if [ "$3" == "uninstall" ] || [ "$2" == "uninstall" ] ; then + if [[ "$3" == "uninstall" || "$2" == "uninstall" ]]; then check_if_runtime_is_installed_rpm uninstall_runtime_zypper test_result_uninstall - fi + fi fi -if [ -e $log_file ] ; then +if [ -e $log_file ]; then ch=$(printf "%-160s" "-") echo "${ch// /-} " fi diff --git a/src/installer/tests/scripts/linux-test/SdkInstallation.sh b/src/installer/tests/scripts/linux-test/SdkInstallation.sh index b2e068d4afa1..2701c79e14c6 100644 --- a/src/installer/tests/scripts/linux-test/SdkInstallation.sh +++ b/src/installer/tests/scripts/linux-test/SdkInstallation.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash current_user=$(whoami) if [ $current_user != "root" ]; then @@ -15,12 +15,12 @@ log_file="/docker/logfile.txt" exec &>> $log_file -if [ $ID == "ol" ] ; then +if [[ "$ID" == "ol" ]]; then distro="oraclelinux" fi -if [ "$distro" == "oraclelinux" ] || [ "$distro" == "rhel" ] || [ "$distro" == "opensuse" ] ; then +if [[ "$distro" == "oraclelinux" || "$distro" == "rhel" || "$distro" == "opensuse" ]]; then version=$(echo $version | cut -d . -f 1) -fi +fi echo $distro:$version @@ -31,23 +31,23 @@ BLOB_SDK_DIR="https://dotnetcli.blob.core.windows.net/dotnet/Sdk" BLOB_ASPNET_DIR="https://dotnetcli.blob.core.windows.net/dotnet/aspnetcore/Runtime" install_curl(){ - apt-get -y install curl - if [ $? -ne 0 ] ; then + apt-get -y install curl + if [ $? -ne 0 ]; then apt-get update apt-get -y install curl fi } download_from_blob_deb(){ BLOB_PATH=$1 - if curl --output /dev/null --head --fail $BLOB_PATH; then + if curl --output /dev/null --head --fail $BLOB_PATH; then curl -O -s $BLOB_PATH - else + else echo "Could not extract file from blob" exit 1 fi } download_sdk_package_deb(){ - if [ "$sdk_version" == "latest" ] ; then + if [[ "$sdk_version" == "latest" ]]; then download_from_blob_deb "$BLOB_SDK_DIR/master/dotnet-sdk-latest-$arch.deb" else download_from_blob_deb "$BLOB_SDK_DIR/$sdk_version/dotnet-sdk-$sdk_version-$arch.deb" @@ -59,17 +59,17 @@ download_aspnet_package_deb(){ determine_aspnet_version_install_deb(){ aspnet_version=$(dpkg -I dotnet-sdk-$sdk_version-$arch.deb | grep -o 'aspnetcore-runtime-[^ ]*') aspnet_version=${aspnet_version#aspnetcore-runtime-} - [ "${aspnet_version: -1}" == "," ] && aspnet_version=${aspnet_version%,} + [[ "${aspnet_version: -1}" == "," ]] && aspnet_version=${aspnet_version%,} } determine_runtime_sdk_install_deb(){ runtime_sdk=$(dpkg -I dotnet-sdk-$sdk_version-$arch.deb | grep -o 'dotnet-runtime-[^ ]*') runtime_sdk=${runtime_sdk#dotnet-runtime-} - [ "${runtime_sdk: -1}" == "," ] && runtime_sdk=${runtime_sdk%,} + [[ "${runtime_sdk: -1}" == "," ]] && runtime_sdk=${runtime_sdk%,} } determine_runtime_aspnet_install_deb(){ runtime_aspnet=$(dpkg -I aspnetcore-runtime-$aspnet_version-$arch.deb | grep -o 'dotnet-runtime[^ ]*') runtime_aspnet=${runtime_aspnet#dotnet-runtime-} - [ "${runtime_aspnet: -1}" == "," ] && runtime_sdk=${runtime_aspnet%,} + [[ "${runtime_aspnet: -1}" == "," ]] && runtime_sdk=${runtime_aspnet%,} } download_runtime_packages_deb(){ download_from_blob_deb "$BLOB_RUNTIME_DIR/$runtime_version/dotnet-runtime-deps-$runtime_version-$distro.$version-$arch.deb" @@ -88,7 +88,7 @@ install_aspnet_and_sdk_deb(){ } check_if_sdk_is_installed_deb(){ find_sdk=$(apt list --installed | grep dotnet-sdk-$sdk_version) - if [ "$find_sdk" == "" ] ; then + if [[ -z "$find_sdk" ]]; then echo "Not able to remove sdk $sdk_version because it is not installed" exit 1 fi @@ -117,15 +117,15 @@ install_wget_zypper(){ } download_from_blob_rpm(){ BLOB_PATH=$1 - if wget --spider $BLOB_PATH; then + if wget --spider $BLOB_PATH; then wget -nv $BLOB_PATH - else + else echo "Could not extract file from blob" exit 1 fi } download_sdk_package_rpm(){ - if [ "$sdk_version" == "latest" ] ; then + if [[ "$sdk_version" == "latest" ]]; then download_from_blob_rpm "$BLOB_SDK_DIR/master/dotnet-sdk-latest-$arch.rpm" else download_from_blob_rpm "$BLOB_SDK_DIR/$sdk_version/dotnet-sdk-$sdk_version-$arch.rpm" @@ -170,8 +170,7 @@ install_aspnet_and_sdk_rpm(){ } check_if_sdk_is_installed_rpm(){ find_sdk=$(rpm -qa | grep dotnet-sdk-$sdk_version) - if [ "$find_sdk" == "" ] ; - then + if [[ -z "$find_sdk" ]]; then echo "Not able to remove sdk $sdk_version because it is not installed" exit 1 fi @@ -192,7 +191,7 @@ uninstall_dotnet_yum(){ dotnet_installed_packages=$(rpm -qa | grep -e dotnet -e aspnet) } uninstall_dotnet_zypper(){ - zypper -n rm $(rpm -qa | grep -e dotnet -e aspnet) + zypper -n rm $(rpm -qa | grep -e dotnet -e aspnet) dotnet_installed_packages=$(rpm -qa | grep -e dotnet -e aspnet) } checkout_new_folder(){ @@ -203,12 +202,12 @@ checkout_previous_folder(){ cd .. } run_app(){ - if [ -e $result_file ] ; then + if [ -e $result_file ]; then dotnet new console -o dockerApp cd dockerApp dotnet restore -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json project_output=$(dotnet run) - if [ "$project_output" == 'Hello World!' ] ; + if [[ "$project_output" == 'Hello World!' ]]; then sucess_install=1; else @@ -217,8 +216,8 @@ run_app(){ fi } test_result_install(){ - if [ -e $result_file ] ; then - if [ $sucess_install -eq 1 ] ; then + if [ -e $result_file ]; then + if [ $sucess_install -eq 1 ]; then echo "$distro:$version install -> passed" >> $result_file else echo "$distro:$version install -> failed" >> $result_file @@ -226,15 +225,15 @@ test_result_install(){ fi } test_result_uninstall(){ - - if [ "$dotnet_installed_packages" == "" ] ; then + + if [[ -z "$dotnet_installed_packages" ]]; then sucess_uninstall=1; else sucess_uninstall=0; fi - if [ -e $result_file ] ; then - if [ $sucess_uninstall -eq 1 ] ; then + if [ -e $result_file ]; then + if [ $sucess_uninstall -eq 1 ]; then echo "$distro:$version uninstall -> passed" >> $result_file else echo "$distro:$version uninstall -> failed" >> $result_file @@ -242,77 +241,77 @@ test_result_uninstall(){ fi } uninstall_latest_sdk_warning(){ - if [ "$sdk_version" == "latest" ] ; then + if [[ "$sdk_version" == "latest" ]]; then echo "Specify sdk version to unistall. Type dotnet --list-sdks to see sdks versions installed" exit 1 - fi + fi } -if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] ; then - if [ "$2" == "install" ] ; then - install_curl - +if [[ "$distro" == "ubuntu" || "$distro" == "debian" ]]; then + if [[ "$2" == "install" ]]; then + install_curl + download_sdk_package_deb - + determine_aspnet_version_install_deb - download_aspnet_package_deb + download_aspnet_package_deb determine_runtime_aspnet_install_deb determine_runtime_sdk_install_deb - + runtime_version="$runtime_aspnet" download_runtime_packages_deb install_runtime_packages_deb - - if [ "$runtime_aspnet" != "$runtime_sdk" ] ; then + + if [ "$runtime_aspnet" != "$runtime_sdk" ]; then runtime_version="$runtime_sdk" checkout_new_folder download_runtime_packages_deb install_runtime_packages_deb checkout_previous_folder - fi + fi install_aspnet_and_sdk_deb - + dotnet --list-runtimes dotnet --list-sdks run_app test_result_install - - elif [ "$2" == "uninstall" ] ; then - uninstall_latest_sdk_warning + + elif [[ "$2" == "uninstall" ]]; then + uninstall_latest_sdk_warning check_if_sdk_is_installed_deb - + determine_runtime_sdk_uninstall_deb determine_aspnet_package_name_uninstall_deb determine_runtime_aspnet_uninstall_deb - - fi - if [ "$3" == "uninstall" ] && [ $sucess_install -eq 1 ] || [ "$2" == "uninstall" ] ; then + fi + + if [[ "$3" == "uninstall" && "$sucess_install" == 1 || "$2" == "uninstall" ]]; then uninstall_dotnet_deb test_result_uninstall fi -elif [ "$distro" == "fedora" ] || [ "$distro" == "centos" ] || [ "$distro" == "oraclelinux" ] || [ "$distro" == "rhel" ] ; then - if [ "$2" == "install" ] ; then +elif [[ "$distro" == "fedora" || "$distro" == "centos" || "$distro" == "oraclelinux" || "$distro" == "rhel" ]]; then + if [[ "$2" == "install" ]]; then install_wget_yum download_sdk_package_rpm - + determine_aspnet_version_install_rpm download_aspnet_package_rpm determine_runtime_aspnet_install_rpm determine_runtime_sdk_install_rpm - + checkout_new_folder runtime_version="$runtime_aspnet" download_runtime_packages_rpm install_runtime_deps_package_yum - - if [ "$runtime_aspnet" != "$runtime_sdk" ] ; then + + if [ "$runtime_aspnet" != "$runtime_sdk" ]; then runtime_version="$runtime_sdk" download_runtime_packages_rpm install_runtime_deps_package_yum @@ -328,42 +327,42 @@ elif [ "$distro" == "fedora" ] || [ "$distro" == "centos" ] || [ "$distro" == "o run_app test_result_install - elif [ "$2" == "uninstall" ] ; then - uninstall_latest_sdk_warning + elif [[ "$2" == "uninstall" ]]; then + uninstall_latest_sdk_warning check_if_sdk_is_installed_rpm - + determine_runtime_sdk_uninstall_rpm determine_aspnet_package_name_uninstall_rpm determine_runtime_aspnet_uninstall_rpm - + echo $runtime_sdk echo $runtime_aspnet fi - if [ "$3" == "uninstall" ] && [ $sucess_install -eq 1 ]|| [ "$2" == "uninstall" ] ; then + if [[ "$3" == "uninstall" && "$sucess_install" == 1 || "$2" == "uninstall" ]]; then uninstall_dotnet_yum test_result_uninstall fi -elif [ "$distro" == "opensuse" ] || [ "$distro" == "sles" ] ; then - if [ "$2" == "install" ] ; then +elif [[ "$distro" == "opensuse" || "$distro" == "sles" ]]; then + if [[ "$2" == "install" ]]; then install_wget_zypper download_sdk_package_rpm - + determine_aspnet_version_install_rpm download_aspnet_package_rpm determine_runtime_aspnet_install_rpm determine_runtime_sdk_install_rpm - + checkout_new_folder runtime_version="$runtime_aspnet" download_runtime_packages_rpm install_runtime_deps_package_zypper - - if [ "$runtime_aspnet" != "$runtime_sdk" ] ; then + + if [ "$runtime_aspnet" != "$runtime_sdk" ]; then runtime_version="$runtime_sdk" download_runtime_packages_rpm install_runtime_deps_package_zypper @@ -376,30 +375,30 @@ elif [ "$distro" == "opensuse" ] || [ "$distro" == "sles" ] ; then dotnet --list-runtimes dotnet --list-sdks - + run_app test_result_install - elif [ "$2" == "uninstall" ] ; then - uninstall_latest_sdk_warning + elif [[ "$2" == "uninstall" ]]; then + uninstall_latest_sdk_warning check_if_sdk_is_installed_rpm - + determine_runtime_sdk_uninstall_rpm determine_aspnet_package_name_uninstall_rpm determine_runtime_aspnet_uninstall_rpm - + echo $runtime_sdk echo $runtime_aspnet fi - if [ "$3" == "uninstall" ] && [ $sucess_install -eq 1 ] || [ "$2" == "uninstall" ] ; then + if [[ "$3" == "uninstall" && "$sucess_install" == 1 || "$2" == "uninstall" ]]; then uninstall_dotnet_zypper test_result_uninstall - fi + fi fi -if [ -e $log_file ] ; then +if [ -e $log_file ]; then ch=$(printf "%-160s" "-") echo "${ch// /-} " fi diff --git a/src/installer/tests/scripts/linux-test/VerificationTestOnDocker.sh b/src/installer/tests/scripts/linux-test/VerificationTestOnDocker.sh index a71d4c93627e..b62d729a5b7f 100644 --- a/src/installer/tests/scripts/linux-test/VerificationTestOnDocker.sh +++ b/src/installer/tests/scripts/linux-test/VerificationTestOnDocker.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash InstallationTestResult="result.txt" InstallationTestLogFile="logfile.txt" @@ -10,14 +10,14 @@ if [ $current_user != "root" ]; then exit 1 fi -if [ -e $InstallationTestLogFile ] ; then +if [ -e $InstallationTestLogFile ]; then rm $InstallationTestLogFile -f fi -if [ "$1" == "sdk" ] ; then +if [[ "$1" == "sdk" ]]; then InstallationScript="SdkInstallation.sh" echo -e ".NET SDK verification test result\n" > $InstallationTestResult -elif [ "$1" == "runtime" ] ; then +elif [[ "$1" == "runtime" ]]; then InstallationScript="RuntimeInstallation.sh" echo -e ".NET Runtime verification test result\n" > $InstallationTestResult fi @@ -25,6 +25,6 @@ fi while IFS='' read -r image || [[ -n "$image" ]]; do echo $image docker run --rm -v $(pwd):/docker -t $image /bin/bash /docker/$InstallationScript $2 $3 $4 -done <$ImagesFile +done <$ImagesFile cat $InstallationTestResult >> $InstallationTestLogFile diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/H3StaticTable.Http3.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/H3StaticTable.Http3.cs index 8e812b15c64b..6e109d6f8c54 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/H3StaticTable.Http3.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/H3StaticTable.Http3.cs @@ -48,7 +48,7 @@ public static bool TryGetStatusIndex(int status, out int index) // TODO: just use Dictionary directly to avoid interface dispatch. public static IReadOnlyDictionary MethodIndex => s_methodIndex; - public static HeaderField GetHeaderFieldAt(int index) => s_staticTable[index]; + public static ref HeaderField Get(int index) => ref s_staticTable[index]; private static readonly HeaderField[] s_staticTable = new HeaderField[] { diff --git a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecoder.cs b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecoder.cs index 8488d0a07132..edd361871ca0 100644 --- a/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecoder.cs +++ b/src/libraries/Common/src/System/Net/Http/aspnetcore/Http3/QPack/QPackDecoder.cs @@ -180,11 +180,18 @@ public void Decode(in ReadOnlySequence headerBlock, bool endHeaders, IHttp { foreach (ReadOnlyMemory segment in headerBlock) { - Decode(segment.Span, endHeaders: false, handler); + DecodeCore(segment.Span, handler); } + CheckIncompleteHeaderBlock(endHeaders); } public void Decode(ReadOnlySpan headerBlock, bool endHeaders, IHttpHeadersHandler handler) + { + DecodeCore(headerBlock, handler); + CheckIncompleteHeaderBlock(endHeaders); + } + + private void DecodeCore(ReadOnlySpan headerBlock, IHttpHeadersHandler handler) { foreach (byte b in headerBlock) { @@ -192,6 +199,17 @@ public void Decode(ReadOnlySpan headerBlock, bool endHeaders, IHttpHeaders } } + private void CheckIncompleteHeaderBlock(bool endHeaders) + { + if (endHeaders) + { + if (_state != State.CompressedHeaders) + { + throw new QPackDecodingException(SR.net_http_hpack_incomplete_header_block); + } + } + } + private void OnByte(byte b, IHttpHeadersHandler handler) { int intResult; diff --git a/src/libraries/Common/tests/Extensions/ConfigurationRootTest.cs b/src/libraries/Common/tests/Extensions/ConfigurationRootTest.cs index 44ea87e8a78a..cf3258f80a1a 100644 --- a/src/libraries/Common/tests/Extensions/ConfigurationRootTest.cs +++ b/src/libraries/Common/tests/Extensions/ConfigurationRootTest.cs @@ -11,6 +11,8 @@ namespace Microsoft.Extensions.Configuration.Test { public class ConfigurationRootTest { + private const string SecretCover = "*****"; + [Fact] public void RootDisposesProviders() { @@ -77,12 +79,56 @@ public void ChainedConfigurationIsDisposed(bool shouldDispose) Assert.Equal(shouldDispose, provider.IsDisposed); } + [Fact] + public void SecretsAreConcealed() + { + var provider = new SecretConfigurationProvider("secret", "secret-value"); + + var config = new ConfigurationRoot(new IConfigurationProvider[] { + provider + }); + + var debugView = config.GetDebugView(ProcessValue); + + Assert.Contains(SecretCover, debugView); + } + + [Fact] + public void NonSecretsAreNotConcealed() + { + var provider = new TestConfigurationProvider("foo", "foo-value"); + + var config = new ConfigurationRoot(new IConfigurationProvider[] { + provider + }); + + var debugView = config.GetDebugView(ProcessValue); + + Assert.DoesNotContain(SecretCover, debugView); + } + + private string ProcessValue(ConfigurationDebugViewContext context) + { + if (context.ConfigurationProvider.ToString() == nameof(SecretConfigurationProvider)) + { + return SecretCover; + } + + return context.Value; + } + private class TestConfigurationProvider : ConfigurationProvider { public TestConfigurationProvider(string key, string value) => Data.Add(key, value); } + private class SecretConfigurationProvider : ConfigurationProvider + { + public SecretConfigurationProvider(string key, string value) + => Data.Add(key, value); + } + private class DisposableTestConfigurationProvider : ConfigurationProvider, IDisposable { public bool IsDisposed { get; set; } diff --git a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/run.sh b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/run.sh index 0b4a615157c0..8fd72c5f2c72 100644 --- a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/run.sh +++ b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/run.sh @@ -1,16 +1,16 @@ -#!/bin/bash -x +#!/usr/bin/env bash -x echo "$@" > /tmp/args cp /SHARED/apacheweb.keytab /etc/krb5.keytab -if [ "$1" == "-debug" ]; then +if [[ "$1" == "-debug" ]]; then while [ 1 ];do sleep 10000 done fi -if [ "$1" == "-DNTLM" ]; then +if [[ "$1" == "-DNTLM" ]]; then # NTLM/Winbind is aggressive and eats Negotiate so it cannot be combined with Kerberos ./setup-pdc.sh /usr/sbin/apache2 -DALTPORT "$@" diff --git a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-digest.sh b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-digest.sh index ef3a9c610ee0..d42341810a1e 100644 --- a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-digest.sh +++ b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-digest.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash echo -n 'user1:Digest Login:' > /setup/digest_pw echo -n 'user1:Digest Login:PLACEHOLDERcorrect20' | md5sum | cut -d ' ' -f 1 >> /setup/digest_pw diff --git a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-pdc.sh b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-pdc.sh index 871e8da79e45..86aabb90a68e 100644 --- a/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-pdc.sh +++ b/src/libraries/Common/tests/System/Net/EnterpriseTests/setup/apacheweb/setup-pdc.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash rm -f /etc/samba/smb.conf # Configure domain and start daemons diff --git a/src/libraries/Common/tests/System/Xml/DisableParallelization.cs b/src/libraries/Common/tests/TestUtilities/System/DisableParallelizationPerAssembly.cs similarity index 78% rename from src/libraries/Common/tests/System/Xml/DisableParallelization.cs rename to src/libraries/Common/tests/TestUtilities/System/DisableParallelizationPerAssembly.cs index e6fb8acae3b2..62b4f0e3730d 100644 --- a/src/libraries/Common/tests/System/Xml/DisableParallelization.cs +++ b/src/libraries/Common/tests/TestUtilities/System/DisableParallelizationPerAssembly.cs @@ -1,5 +1,4 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// Tests are old and depend on the static state -[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] +[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index f851d6090d4a..50d40f9b3754 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -83,15 +83,7 @@ public static partial class PlatformDetection private static readonly Lazy s_LinqExpressionsBuiltWithIsInterpretingOnly = new Lazy(GetLinqExpressionsBuiltWithIsInterpretingOnly); private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly() { - Type type = typeof(LambdaExpression); - if (type != null) - { - // The "Accept" method is under FEATURE_COMPILE conditional so it should not exist - MethodInfo methodInfo = type.GetMethod("Accept", BindingFlags.NonPublic | BindingFlags.Static); - return methodInfo == null; - } - - return false; + return !(bool)typeof(LambdaExpression).GetMethod("get_CanCompileToIL").Invoke(null, Array.Empty()); } // Please make sure that you have the libgdiplus dependency installed. diff --git a/src/libraries/Common/tests/Tests/System/Net/aspnetcore/Http3/QPackDecoderTest.cs b/src/libraries/Common/tests/Tests/System/Net/aspnetcore/Http3/QPackDecoderTest.cs new file mode 100644 index 000000000000..57810746c778 --- /dev/null +++ b/src/libraries/Common/tests/Tests/System/Net/aspnetcore/Http3/QPackDecoderTest.cs @@ -0,0 +1,210 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Buffers; +using System.Linq; +using System.Collections.Generic; +using System.Text; +using Xunit; +using System.Net.Http.QPack; +using System.Net.Http.HPack; +using HeaderField = System.Net.Http.QPack.HeaderField; +#if KESTREL +using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http; +#endif + +namespace System.Net.Http.Unit.Tests.QPack +{ + public class QPackDecoderTests + { + private const int MaxHeaderFieldSize = 8192; + + // 4.5.2 - Indexed Field Line - Static Table - Index 25 (:method: GET) + private static readonly byte[] _indexedFieldLineStatic = new byte[] { 0xd1 }; + + // 4.5.4 - Literal Header Field With Name Reference - Static Table - Index 44 (content-type) + private static readonly byte[] _literalHeaderFieldWithNameReferenceStatic = new byte[] { 0x5f, 0x1d }; + + // 4.5.6 - Literal Field Line With Literal Name - (translate) + private static readonly byte[] _literalFieldLineWithLiteralName = new byte[] { 0x37, 0x02, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74, 0x65 }; + + private const string _contentTypeString = "content-type"; + private const string _translateString = "translate"; + + // n e w - h e a d e r * + // 10101000 10111110 00010110 10011100 10100011 10010000 10110110 01111111 + private static readonly byte[] _headerNameHuffmanBytes = new byte[] { 0xa8, 0xbe, 0x16, 0x9c, 0xa3, 0x90, 0xb6, 0x7f }; + + private const string _headerNameString = "new-header"; + private const string _headerValueString = "value"; + + private static readonly byte[] _headerValueBytes = Encoding.ASCII.GetBytes(_headerValueString); + + // v a l u e * + // 11101110 00111010 00101101 00101111 + private static readonly byte[] _headerValueHuffmanBytes = new byte[] { 0xee, 0x3a, 0x2d, 0x2f }; + + private static readonly byte[] _headerNameHuffman = new byte[] { 0x3f, 0x01 } + .Concat(_headerNameHuffmanBytes) + .ToArray(); + + private static readonly byte[] _headerValue = new byte[] { (byte)_headerValueBytes.Length } + .Concat(_headerValueBytes) + .ToArray(); + + private static readonly byte[] _headerValueHuffman = new byte[] { (byte)(0x80 | _headerValueHuffmanBytes.Length) } + .Concat(_headerValueHuffmanBytes) + .ToArray(); + + private readonly QPackDecoder _decoder; + private readonly TestHttpHeadersHandler _handler = new TestHttpHeadersHandler(); + + public QPackDecoderTests() + { + _decoder = new QPackDecoder(MaxHeaderFieldSize); + } + + [Fact] + public void DecodesIndexedHeaderField_StaticTableWithValue() + { + _decoder.Decode(new byte[] { 0, 0 }, endHeaders: false, handler: _handler); + _decoder.Decode(_indexedFieldLineStatic, endHeaders: true, handler: _handler); + Assert.Equal("GET", _handler.DecodedHeaders[":method"]); + + Assert.Equal(":method", _handler.DecodedStaticHeaders[H3StaticTable.MethodGet].Key); + Assert.Equal("GET", _handler.DecodedStaticHeaders[H3StaticTable.MethodGet].Value); + } + + [Fact] + public void DecodesIndexedHeaderField_StaticTableLiteralValue() + { + byte[] encoded = _literalHeaderFieldWithNameReferenceStatic + .Concat(_headerValue) + .ToArray(); + + _decoder.Decode(new byte[] { 0, 0 }, endHeaders: false, handler: _handler); + _decoder.Decode(encoded, endHeaders: true, handler: _handler); + Assert.Equal(_headerValueString, _handler.DecodedHeaders[_contentTypeString]); + + Assert.Equal(_contentTypeString, _handler.DecodedStaticHeaders[H3StaticTable.ContentTypeApplicationDnsMessage].Key); + Assert.Equal(_headerValueString, _handler.DecodedStaticHeaders[H3StaticTable.ContentTypeApplicationDnsMessage].Value); + } + + [Fact] + public void DecodesLiteralFieldLineWithLiteralName_Value() + { + byte[] encoded = _literalFieldLineWithLiteralName + .Concat(_headerValue) + .ToArray(); + + TestDecodeWithoutIndexing(encoded, _translateString, _headerValueString); + } + + [Fact] + public void DecodesLiteralFieldLineWithLiteralName_HuffmanEncodedValue() + { + byte[] encoded = _literalFieldLineWithLiteralName + .Concat(_headerValueHuffman) + .ToArray(); + + TestDecodeWithoutIndexing(encoded, _translateString, _headerValueString); + } + + [Fact] + public void DecodesLiteralFieldLineWithLiteralName_HuffmanEncodedName() + { + byte[] encoded = _headerNameHuffman + .Concat(_headerValue) + .ToArray(); + + TestDecodeWithoutIndexing(encoded, _headerNameString, _headerValueString); + } + + public static readonly TheoryData _incompleteHeaderBlockData = new TheoryData + { + // Incomplete header + new byte[] { }, + new byte[] { 0x00 }, + + // 4.5.4 - Literal Header Field With Name Reference - Static Table - Index 44 (content-type) + new byte[] { 0x00, 0x00, 0x5f }, + + // 4.5.6 - Literal Field Line With Literal Name - (translate) + new byte[] { 0x00, 0x00, 0x37 }, + new byte[] { 0x00, 0x00, 0x37, 0x02 }, + new byte[] { 0x00, 0x00, 0x37, 0x02, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6c, 0x61, 0x74 }, + }; + + [Theory] + [MemberData(nameof(_incompleteHeaderBlockData))] + public void DecodesIncompleteHeaderBlock_Error(byte[] encoded) + { + QPackDecodingException exception = Assert.Throws(() => _decoder.Decode(encoded, endHeaders: true, handler: _handler)); + Assert.Equal(SR.net_http_hpack_incomplete_header_block, exception.Message); + Assert.Empty(_handler.DecodedHeaders); + } + + private static void TestDecodeWithoutIndexing(byte[] encoded, string expectedHeaderName, string expectedHeaderValue) + { + TestDecode(encoded, expectedHeaderName, expectedHeaderValue, expectDynamicTableEntry: false, byteAtATime: false); + TestDecode(encoded, expectedHeaderName, expectedHeaderValue, expectDynamicTableEntry: false, byteAtATime: true); + } + + private static void TestDecode(byte[] encoded, string expectedHeaderName, string expectedHeaderValue, bool expectDynamicTableEntry, bool byteAtATime) + { + var decoder = new QPackDecoder(MaxHeaderFieldSize); + var handler = new TestHttpHeadersHandler(); + + // Read past header + decoder.Decode(new byte[] { 0x00, 0x00 }, endHeaders: false, handler: handler); + + if (!byteAtATime) + { + decoder.Decode(encoded, endHeaders: true, handler: handler); + } + else + { + // Parse data in 1 byte chunks, separated by empty chunks + for (int i = 0; i < encoded.Length; i++) + { + bool end = i + 1 == encoded.Length; + + decoder.Decode(Array.Empty(), endHeaders: false, handler: handler); + decoder.Decode(new byte[] { encoded[i] }, endHeaders: end, handler: handler); + } + } + + Assert.Equal(expectedHeaderValue, handler.DecodedHeaders[expectedHeaderName]); + } + } + + public class TestHttpHeadersHandler : IHttpHeadersHandler + { + public Dictionary DecodedHeaders { get; } = new Dictionary(); + public Dictionary> DecodedStaticHeaders { get; } = new Dictionary>(); + + void IHttpHeadersHandler.OnHeader(ReadOnlySpan name, ReadOnlySpan value) + { + string headerName = Encoding.ASCII.GetString(name); + string headerValue = Encoding.ASCII.GetString(value); + + DecodedHeaders[headerName] = headerValue; + } + + void IHttpHeadersHandler.OnStaticIndexedHeader(int index) + { + ref readonly HeaderField entry = ref H3StaticTable.Get(index); + ((IHttpHeadersHandler)this).OnHeader(entry.Name, entry.Value); + DecodedStaticHeaders[index] = new KeyValuePair(Encoding.ASCII.GetString(entry.Name), Encoding.ASCII.GetString(entry.Value)); + } + + void IHttpHeadersHandler.OnStaticIndexedHeader(int index, ReadOnlySpan value) + { + byte[] name = H3StaticTable.Get(index).Name; + ((IHttpHeadersHandler)this).OnHeader(name, value); + DecodedStaticHeaders[index] = new KeyValuePair(Encoding.ASCII.GetString(name), Encoding.ASCII.GetString(value)); + } + + void IHttpHeadersHandler.OnHeadersComplete(bool endStream) { } + } +} diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.cs b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.cs index a7a7908f1f32..7251a33ac879 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/ref/Microsoft.Extensions.Configuration.Abstractions.cs @@ -33,6 +33,15 @@ public static partial class ConfigurationPath public static partial class ConfigurationRootExtensions { public static string GetDebugView(this Microsoft.Extensions.Configuration.IConfigurationRoot root) { throw null; } + public static string GetDebugView(this IConfigurationRoot root, System.Func? processValue) { throw null; } + } + public readonly partial struct ConfigurationDebugViewContext + { + public ConfigurationDebugViewContext(string path, string key, string? value, IConfigurationProvider configurationProvider) { throw null; } + public string Path { get; } + public string Key { get; } + public string? Value { get; } + public IConfigurationProvider ConfigurationProvider { get; } } public partial interface IConfiguration { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs new file mode 100644 index 000000000000..ec53db48792b --- /dev/null +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.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. + +namespace Microsoft.Extensions.Configuration +{ + /// + /// Provides the data about current item of the configuration. + /// + public readonly struct ConfigurationDebugViewContext + { + public ConfigurationDebugViewContext(string path, string key, string? value, IConfigurationProvider configurationProvider) + { + Path = path; + Key = key; + Value = value; + ConfigurationProvider = configurationProvider; + } + + /// + /// Gets the path of the current item. + /// + public string Path { get; } + + /// + /// Gets the key of the current item. + /// + public string Key { get; } + + /// + /// Gets the value of the current item. + /// + public string? Value { get; } + + /// + /// Gets the that was used to get the value of the current item. + /// + public IConfigurationProvider ConfigurationProvider { get; } + } +} diff --git a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs index 39abb8ec871e..ff6ac765ce1c 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -17,6 +18,22 @@ public static class ConfigurationRootExtensions /// /// The debug view. public static string GetDebugView(this IConfigurationRoot root) + { + return GetDebugView(root, processValue: null); + } + + /// + /// Generates a human-readable view of the configuration showing where each value came from. + /// + /// Configuration root + /// + /// Function for processing the value e.g. hiding secrets + /// Parameters: + /// ConfigurationDebugViewContext: Context of the current configuration item + /// returns: A string value is used to assign as the Value of the configuration section + /// + /// The debug view. + public static string GetDebugView(this IConfigurationRoot root, Func? processValue) { void RecurseChildren( StringBuilder stringBuilder, @@ -29,11 +46,15 @@ void RecurseChildren( if (valueAndProvider.Provider != null) { + string? value = processValue != null + ? processValue(new ConfigurationDebugViewContext(child.Key, child.Path, valueAndProvider.Value, valueAndProvider.Provider)) + : valueAndProvider.Value; + stringBuilder .Append(indent) .Append(child.Key) .Append('=') - .Append(valueAndProvider.Value) + .Append(value) .Append(" (") .Append(valueAndProvider.Provider) .AppendLine(")"); diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj index 2eef0a5ed967..51b2fe2717b0 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/Microsoft.Extensions.DependencyInjection.ExternalContainers.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs index 6d315d7361f7..3deffe4767d7 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.External.Tests/StashBox.cs @@ -7,8 +7,6 @@ namespace Microsoft.Extensions.DependencyInjection.Specification { public class StashBoxDependencyInjectionSpecificationTests : DependencyInjectionSpecificationTests { - public override bool SupportsIServiceProviderIsService => false; - protected override IServiceProvider CreateServiceProvider(IServiceCollection serviceCollection) { return serviceCollection.UseStashbox(); diff --git a/src/libraries/System.Console/src/System/IO/StdInReader.cs b/src/libraries/System.Console/src/System/IO/StdInReader.cs index 93c6595f2b10..fe0ab79f4fb7 100644 --- a/src/libraries/System.Console/src/System/IO/StdInReader.cs +++ b/src/libraries/System.Console/src/System/IO/StdInReader.cs @@ -116,12 +116,14 @@ public int ReadLine(Span buffer) int charsUsedTotal = 0; foreach (ReadOnlyMemory chunk in _readLineSB.GetChunks()) { + Debug.Assert(!buffer.IsEmpty); + encoder.Convert(chunk.Span, buffer, flush: false, out int charsUsed, out int bytesUsed, out bool completed); buffer = buffer.Slice(bytesUsed); bytesUsedTotal += bytesUsed; charsUsedTotal += charsUsed; - if (charsUsed == 0) + if (!completed || buffer.IsEmpty) { break; } diff --git a/src/libraries/System.Console/tests/ManualTests/ManualTests.cs b/src/libraries/System.Console/tests/ManualTests/ManualTests.cs index 70482d365b55..322322d08363 100644 --- a/src/libraries/System.Console/tests/ManualTests/ManualTests.cs +++ b/src/libraries/System.Console/tests/ManualTests/ManualTests.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Threading.Tasks; using System.IO; +using System.Text; using Xunit; namespace System @@ -45,6 +46,23 @@ public static void ReadLineFromOpenStandardInput() AssertUserExpectedResults("the characters you typed properly echoed as you typed"); } + [ConditionalFact(nameof(ManualTestsEnabled))] + public static void ReadFromOpenStandardInput() + { + // The implementation in StdInReader uses a StringBuilder for caching. We want this builder to use + // multiple chunks. So the expectedLine is longer than 16 characters (StringBuilder.DefaultCapacity). + string expectedLine = $"This is a test for ReadFromOpenStandardInput."; + Assert.True(expectedLine.Length > new StringBuilder().Capacity); + Console.WriteLine($"Please type the sentence (without the quotes): \"{expectedLine}\""); + using Stream inputStream = Console.OpenStandardInput(); + for (int i = 0; i < expectedLine.Length; i++) + { + Assert.Equal((byte)expectedLine[i], inputStream.ReadByte()); + } + Assert.Equal((byte)'\n', inputStream.ReadByte()); + AssertUserExpectedResults("the characters you typed properly echoed as you typed"); + } + [ConditionalFact(nameof(ManualTestsEnabled))] public static void ConsoleReadSupportsBackspace() { diff --git a/src/libraries/System.Console/tests/SetOut.cs b/src/libraries/System.Console/tests/SetOut.cs index 83d0f95f6e69..c1a893c9e769 100644 --- a/src/libraries/System.Console/tests/SetOut.cs +++ b/src/libraries/System.Console/tests/SetOut.cs @@ -5,6 +5,7 @@ using System.IO; using Xunit; +[Collection(nameof(DisableParallelization))] // Console.Out is a static singleton, other tests should not be using it at the same time public class SetOut { [Fact] @@ -28,7 +29,6 @@ public static void SetOutReadLine() } [Fact] - [ActiveIssue("https://github.com/dotnet/runtime/issues/57935", TestPlatforms.AnyUnix)] public static void SetOutReadToEnd() { Helpers.SetAndReadHelper(tw => Console.SetOut(tw), () => Console.Out, sr => sr.ReadToEnd()); diff --git a/src/libraries/System.Console/tests/System.Console.Tests.csproj b/src/libraries/System.Console/tests/System.Console.Tests.csproj index f92a0cdfc491..3c83ac5db2f9 100644 --- a/src/libraries/System.Console/tests/System.Console.Tests.csproj +++ b/src/libraries/System.Console/tests/System.Console.Tests.csproj @@ -28,6 +28,8 @@ Link="Common\System\IO\InterceptStreamWriter.cs" /> + diff --git a/src/libraries/System.IO.Compression/src/Resources/Strings.resx b/src/libraries/System.IO.Compression/src/Resources/Strings.resx index 286ff6ab7c72..cac801aa8fcc 100644 --- a/src/libraries/System.IO.Compression/src/Resources/Strings.resx +++ b/src/libraries/System.IO.Compression/src/Resources/Strings.resx @@ -308,4 +308,7 @@ Zip 64 End of Central Directory Record not where indicated. + + An entry named '{0}' already exists in the archive. + diff --git a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs index 5fbd00c47006..58b65209caf0 100644 --- a/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs +++ b/src/libraries/System.IO.Compression/src/System/IO/Compression/ZipArchive.cs @@ -388,6 +388,11 @@ private ZipArchiveEntry DoCreateEntry(string entryName, CompressionLevel? compre if (_mode == ZipArchiveMode.Read) throw new NotSupportedException(SR.CreateInReadMode); + if (_entriesDictionary.ContainsKey(entryName)) + { + throw new InvalidOperationException(string.Format(SR.EntryNameAlreadyExists, entryName)); + } + ThrowIfDisposed(); @@ -421,12 +426,7 @@ internal void AcquireArchiveStream(ZipArchiveEntry entry) private void AddEntry(ZipArchiveEntry entry) { _entries.Add(entry); - - string entryName = entry.FullName; - if (!_entriesDictionary.ContainsKey(entryName)) - { - _entriesDictionary.Add(entryName, entry); - } + _entriesDictionary.TryAdd(entry.FullName, entry); } [Conditional("DEBUG")] diff --git a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_CreateTests.cs b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_CreateTests.cs index b5075cd8ba59..f0c36d596762 100644 --- a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_CreateTests.cs +++ b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_CreateTests.cs @@ -178,6 +178,23 @@ public static void CreateNormal_VerifyDataDescriptor() AssertDataDescriptor(memoryStream, false); } + [Fact] + public static void CreateNormal_With2SameEntries_ThrowException() + { + using var memoryStream = new MemoryStream(); + // We need an non-seekable stream so the data descriptor bit is turned on when saving + var wrappedStream = new WrappedStream(memoryStream); + + // Creation will go through the path that sets the data descriptor bit when the stream is unseekable + using (var archive = new ZipArchive(wrappedStream, ZipArchiveMode.Create)) + { + string entryName = "duplicate.txt"; + CreateEntry(archive, entryName, "xxx"); + AssertExtensions.ThrowsContains(() => CreateEntry(archive, entryName, "yyy"), + entryName); + } + } + private static string ReadStringFromSpan(Span input) { return Text.Encoding.UTF8.GetString(input.ToArray()); diff --git a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_UpdateTests.cs b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_UpdateTests.cs index af97a9d3ab96..3cb9934fb3a7 100644 --- a/src/libraries/System.IO.Compression/tests/ZipArchive/zip_UpdateTests.cs +++ b/src/libraries/System.IO.Compression/tests/ZipArchive/zip_UpdateTests.cs @@ -92,20 +92,38 @@ public static void EmptyEntryTest(ZipArchiveMode mode) baseline = baseline.Clone(); using (ZipArchive archive = new ZipArchive(baseline, mode)) { - AddEntry(archive, "data1.txt", data1, lastWrite); + if (mode == ZipArchiveMode.Create) + { + AddEntry(archive, "data1.txt", data1, lastWrite); - ZipArchiveEntry e = archive.CreateEntry("empty.txt"); - e.LastWriteTime = lastWrite; - using (Stream s = e.Open()) { } + ZipArchiveEntry e = archive.CreateEntry("empty.txt"); + e.LastWriteTime = lastWrite; + using (Stream s = e.Open()) { } + } + else + { + Assert.Throws(() => AddEntry(archive, "data1.txt", data1, lastWrite)); + + Assert.Throws(() => archive.CreateEntry("empty.txt")); + } } test = test.Clone(); using (ZipArchive archive = new ZipArchive(test, mode)) { - AddEntry(archive, "data1.txt", data1, lastWrite); + if (mode == ZipArchiveMode.Create) + { + AddEntry(archive, "data1.txt", data1, lastWrite); - ZipArchiveEntry e = archive.CreateEntry("empty.txt"); - e.LastWriteTime = lastWrite; + ZipArchiveEntry e = archive.CreateEntry("empty.txt"); + e.LastWriteTime = lastWrite; + } + else + { + Assert.Throws(() => AddEntry(archive, "data1.txt", data1, lastWrite)); + + Assert.Throws(() => archive.CreateEntry("empty.txt")); + } } //compare Assert.True(ArraysEqual(baseline.ToArray(), test.ToArray()), "Arrays didn't match after update"); diff --git a/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj b/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj index 3d282e1aea7c..fa6aaa94a54c 100644 --- a/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj +++ b/src/libraries/System.IO.FileSystem.DriveInfo/tests/System.IO.FileSystem.DriveInfo.Tests.csproj @@ -7,5 +7,6 @@ + \ No newline at end of file diff --git a/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.IsInterpreting.LibraryBuild.xml b/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.IsInterpreting.LibraryBuild.xml new file mode 100644 index 000000000000..67051cc12615 --- /dev/null +++ b/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.IsInterpreting.LibraryBuild.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml b/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml new file mode 100644 index 000000000000..2847ed81708c --- /dev/null +++ b/src/libraries/System.Linq.Expressions/src/ILLink/ILLink.Substitutions.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/libraries/System.Linq.Expressions/src/MatchingRefApiCompatBaseline.txt b/src/libraries/System.Linq.Expressions/src/MatchingRefApiCompatBaseline.txt index 2f39245d3f87..09b8bb3f4577 100644 --- a/src/libraries/System.Linq.Expressions/src/MatchingRefApiCompatBaseline.txt +++ b/src/libraries/System.Linq.Expressions/src/MatchingRefApiCompatBaseline.txt @@ -16,4 +16,6 @@ TypesMustExist : Type 'System.Runtime.CompilerServices.CallSiteOps' does not exi TypesMustExist : Type 'System.Runtime.CompilerServices.Closure' does not exist in the reference but it does exist in the implementation. TypesMustExist : Type 'System.Runtime.CompilerServices.RuntimeOps' does not exist in the reference but it does exist in the implementation. TypesMustExist : Type 'System.Linq.Expressions.ExpressionCreator' does not exist in the reference but it does exist in the implementation. -Total Issues: 17 +MembersMustExist : Member 'public System.Boolean System.Linq.Expressions.LambdaExpression.CanCompileToIL.get()' does not exist in the reference but it does exist in the implementation. +MembersMustExist : Member 'public System.Boolean System.Linq.Expressions.LambdaExpression.CanInterpret.get()' does not exist in the reference but it does exist in the implementation. +Total Issues: 19 diff --git a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj index dc257034e404..a05427c27986 100644 --- a/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj +++ b/src/libraries/System.Linq.Expressions/src/System.Linq.Expressions.csproj @@ -1,17 +1,22 @@ - true $(NetCoreAppCurrent);$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-MacCatalyst enable - - true - $(DefineConstants);FEATURE_DYNAMIC_DELEGATE - - + false true - $(DefineConstants);FEATURE_COMPILE - $(DefineConstants);FEATURE_INTERPRET + ILLink\ILLink.Substitutions.IsInterpreting.LibraryBuild.xml + $(DefineConstants);FEATURE_FAST_CREATE + + + true + + + @@ -128,7 +133,7 @@ - + @@ -160,7 +165,7 @@ - + diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs index f54a21adb7a4..2969348e143d 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.cs @@ -7,7 +7,6 @@ namespace System.Dynamic { internal static partial class UpdateDelegates { -#if FEATURE_COMPILE [Obsolete("pregenerated CallSite.Update delegate", error: true)] internal static TRet UpdateAndExecute1(CallSite site, T0 arg0) { @@ -2895,6 +2894,5 @@ internal static void NoMatchVoid10(CallS site._match = false; return; } -#endif } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.tt b/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.tt index 44c6c3fc6280..ae41482f9489 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.tt +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/UpdateDelegates.Generated.tt @@ -13,7 +13,6 @@ namespace System.Dynamic { internal static partial class UpdateDelegates { -#if FEATURE_COMPILE <# for (int i = 1; i <= 10; i++) { @@ -330,6 +329,5 @@ for (int i = 1; i <= 10; i++) } } #> -#endif } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs index cd3446767c63..b46fa6768289 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/DelegateHelpers.cs @@ -3,28 +3,43 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; - -#if !FEATURE_DYNAMIC_DELEGATE using System.Reflection.Emit; using System.Text; using System.Threading; -#endif namespace System.Dynamic.Utils { internal static class DelegateHelpers { - internal static Delegate CreateObjectArrayDelegate(Type delegateType, Func handler) + // This can be flipped to true using feature switches at publishing time + internal static bool CanEmitObjectArrayDelegate => true; + + // Separate class so that the it can be trimmed away and doesn't get conflated + // with the Reflection.Emit statics below. + private static class DynamicDelegateLightup { -#if !FEATURE_DYNAMIC_DELEGATE - return CreateObjectArrayDelegateRefEmit(delegateType, handler); -#else - return Internal.Runtime.Augments.DynamicDelegateAugments.CreateObjectArrayDelegate(delegateType, handler); -#endif + public static Func, Delegate> CreateObjectArrayDelegate { get; } + = CreateObjectArrayDelegateInternal(); + + [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2075:UnrecognizedReflectionPattern", + Justification = "Works around https://github.com/dotnet/linker/issues/2392")] + private static Func, Delegate> CreateObjectArrayDelegateInternal() + => Type.GetType("Internal.Runtime.Augments.DynamicDelegateAugments")! + .GetMethod("CreateObjectArrayDelegate")! + .CreateDelegate, Delegate>>(); } - -#if !FEATURE_DYNAMIC_DELEGATE + internal static Delegate CreateObjectArrayDelegate(Type delegateType, Func handler) + { + if (CanEmitObjectArrayDelegate) + { + return CreateObjectArrayDelegateRefEmit(delegateType, handler); + } + else + { + return DynamicDelegateLightup.CreateObjectArrayDelegate(delegateType, handler); + } + } private static readonly CacheDict s_thunks = new CacheDict(256); private static readonly MethodInfo s_FuncInvoke = typeof(Func).GetMethod("Invoke")!; @@ -290,7 +305,5 @@ private static Type ConvertToBoxableType(Type t) { return (t.IsPointer) ? typeof(IntPtr) : t; } - -#endif } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeExtensions.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeExtensions.cs index 4b57dba01726..71244b2a67d8 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeExtensions.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeExtensions.cs @@ -80,7 +80,6 @@ internal static ParameterInfo[] GetParametersCached(this MethodBase method) return pis; } -#if FEATURE_COMPILE // Expression trees/compiler just use IsByRef, why do we need this? // (see LambdaCompiler.EmitArguments for usage in the compiler) internal static bool IsByRefParameter(this ParameterInfo pi) @@ -91,6 +90,5 @@ internal static bool IsByRefParameter(this ParameterInfo pi) return (pi.Attributes & ParameterAttributes.Out) == ParameterAttributes.Out; } -#endif } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs index f676a13dce7e..1d0fca59e306 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs @@ -911,8 +911,6 @@ public static MethodInfo GetInvokeMethod(this Type delegateType) return delegateType.GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)!; } -#if FEATURE_COMPILE - internal static bool IsUnsigned(this Type type) => IsUnsigned(GetNonNullableType(type).GetTypeCode()); internal static bool IsUnsigned(this TypeCode typeCode) @@ -946,8 +944,6 @@ internal static bool IsFloatingPoint(this TypeCode typeCode) } } -#endif - [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2070:UnrecognizedReflectionPattern", Justification = "The Array 'Get' method is dynamically constructed and is not included in IL. It is not subject to trimming.")] public static MethodInfo GetArrayGetMethod(Type arrayType) diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs index 752ed754007c..f26c16b3e448 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Common/CachedReflectionInfo.cs @@ -159,7 +159,6 @@ public static FieldInfo DateTime_MinValue (s_Math_Pow_Double_Double = typeof(Math).GetMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) })!); // Closure and RuntimeOps helpers are used only in the compiler. -#if FEATURE_COMPILE private static ConstructorInfo? s_Closure_ObjectArray_ObjectArray; public static ConstructorInfo Closure_ObjectArray_ObjectArray => s_Closure_ObjectArray_ObjectArray ?? @@ -194,6 +193,5 @@ public static FieldInfo DateTime_MinValue public static MethodInfo RuntimeOps_Quote => s_RuntimeOps_Quote ?? (s_RuntimeOps_Quote = typeof(RuntimeOps).GetMethod(nameof(RuntimeOps.Quote))!); -#endif } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs index 6e6a915e76e9..8884a2774951 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.Generated.cs @@ -84,8 +84,6 @@ private static TypeInfo NextTypeInfo(Type initialArg, TypeInfo curTypeInfo) return nextTypeInfo; } -#if !FEATURE_COMPILE - public delegate object VBCallSiteDelegate0(T callSite, object instance); public delegate object VBCallSiteDelegate1(T callSite, object instance, ref object arg1); public delegate object VBCallSiteDelegate2(T callSite, object instance, ref object arg1, ref object arg2); @@ -95,7 +93,6 @@ private static TypeInfo NextTypeInfo(Type initialArg, TypeInfo curTypeInfo) public delegate object VBCallSiteDelegate6(T callSite, object instance, ref object arg1, ref object arg2, ref object arg3, ref object arg4, ref object arg5, ref object arg6); public delegate object VBCallSiteDelegate7(T callSite, object instance, ref object arg1, ref object arg2, ref object arg3, ref object arg4, ref object arg5, ref object arg6, ref object arg7); - private static Type TryMakeVBStyledCallSite(Type[] types) { // Shape of VB CallSiteDelegates is CallSite * (instance : obj) * [arg-n : byref obj] -> obj @@ -128,7 +125,6 @@ private static Type TryMakeVBStyledCallSite(Type[] types) default: return null; } } -#endif /// /// Creates a new delegate, or uses a func/action @@ -163,11 +159,14 @@ internal static Type MakeNewDelegate(Type[] types) if (needCustom) { -#if FEATURE_COMPILE - return MakeNewCustomDelegate(types); -#else - return TryMakeVBStyledCallSite(types) ?? MakeNewCustomDelegate(types); -#endif + if (LambdaExpression.CanCompileToIL) + { + return MakeNewCustomDelegate(types); + } + else + { + return TryMakeVBStyledCallSite(types) ?? MakeNewCustomDelegate(types); + } } Type result; diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs index f1cb6e844bb9..35dae2e3a110 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Compiler/DelegateHelpers.cs @@ -107,26 +107,27 @@ private static bool IsByRef(DynamicMetaObject mo) return mo.Expression is ParameterExpression pe && pe.IsByRef; } -#if FEATURE_COMPILE - private const MethodAttributes CtorAttributes = MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public; - private const MethodImplAttributes ImplAttributes = MethodImplAttributes.Runtime | MethodImplAttributes.Managed; - private const MethodAttributes InvokeAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual; - private static readonly Type[] s_delegateCtorSignature = { typeof(object), typeof(IntPtr) }; -#endif - private static Type MakeNewCustomDelegate(Type[] types) { -#if FEATURE_COMPILE - Type returnType = types[types.Length - 1]; - Type[] parameters = types.RemoveLast(); - - TypeBuilder builder = AssemblyGen.DefineDelegateType("Delegate" + types.Length); - builder.DefineConstructor(CtorAttributes, CallingConventions.Standard, s_delegateCtorSignature).SetImplementationFlags(ImplAttributes); - builder.DefineMethod("Invoke", InvokeAttributes, returnType, parameters).SetImplementationFlags(ImplAttributes); - return builder.CreateTypeInfo()!; -#else - throw new PlatformNotSupportedException(); -#endif + if (LambdaExpression.CanCompileToIL) + { + Type returnType = types[types.Length - 1]; + Type[] parameters = types.RemoveLast(); + Type[] delegateCtorSignature = { typeof(object), typeof(IntPtr) }; + + const MethodAttributes ctorAttributes = MethodAttributes.RTSpecialName | MethodAttributes.HideBySig | MethodAttributes.Public; + const MethodImplAttributes implAttributes = MethodImplAttributes.Runtime | MethodImplAttributes.Managed; + const MethodAttributes invokeAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.NewSlot | MethodAttributes.Virtual; + + TypeBuilder builder = AssemblyGen.DefineDelegateType("Delegate" + types.Length); + builder.DefineConstructor(ctorAttributes, CallingConventions.Standard, delegateCtorSignature).SetImplementationFlags(implAttributes); + builder.DefineMethod("Invoke", invokeAttributes, returnType, parameters).SetImplementationFlags(implAttributes); + return builder.CreateTypeInfo()!; + } + else + { + throw new PlatformNotSupportedException(); + } } } } diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.Generated.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.Generated.cs index e9855aebed63..34203b5512d2 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.Generated.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.Generated.cs @@ -13,9 +13,7 @@ namespace System.Linq.Expressions.Interpreter { internal partial class CallInstruction { -#if FEATURE_DLG_INVOKE private const int MaxHelpers = 5; -#endif #if FEATURE_FAST_CREATE private const int MaxArgs = 3; @@ -158,7 +156,6 @@ private static CallInstruction FastCreate(MethodInfo target, ParameterIn } #endif -#if FEATURE_DLG_INVOKE [return: DynamicallyAccessedMembersAttribute(DynamicallyAccessedMemberTypes.PublicConstructors)] private static Type GetHelperType(MethodInfo info, Type[] arrTypes) { @@ -211,10 +208,8 @@ private static Type GetHelperType(MethodInfo info, Type[] arrTypes) } return t; } -#endif } -#if FEATURE_DLG_INVOKE internal sealed class ActionCallInstruction : CallInstruction { private readonly Action _target; @@ -577,6 +572,4 @@ public override int Run(InterpretedFrame frame) public override string ToString() => "Call(" + _target.Method + ")"; } - -#endif } diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs index f10233360deb..42ecb44bb848 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/CallInstruction.cs @@ -16,13 +16,13 @@ internal abstract partial class CallInstruction : Instruction /// public abstract int ArgumentCount { get; } + private static bool CanCreateArbitraryDelegates => true; + #region Construction public override string InstructionName => "Call"; -#if FEATURE_DLG_INVOKE private static readonly CacheDict s_cache = new CacheDict(256); -#endif public static CallInstruction Create(MethodInfo info) { @@ -47,9 +47,9 @@ public static CallInstruction Create(MethodInfo info, ParameterInfo[] parameters return GetArrayAccessor(info, argumentCount); } -#if !FEATURE_DLG_INVOKE - return new MethodInfoCallInstruction(info, argumentCount); -#else + if (!CanCreateArbitraryDelegates) + return new MethodInfoCallInstruction(info, argumentCount); + if (!info.IsStatic && info.DeclaringType!.IsValueType) { return new MethodInfoCallInstruction(info, argumentCount); @@ -119,7 +119,6 @@ public static CallInstruction Create(MethodInfo info, ParameterInfo[] parameters } return res; -#endif } private static CallInstruction GetArrayAccessor(MethodInfo info, int argumentCount) @@ -171,12 +170,11 @@ public static void ArrayItemSetter3(Array array, int index0, int index1, int ind { array.SetValue(value, index0, index1, index2); } -#if FEATURE_DLG_INVOKE + private static bool ShouldCache(MethodInfo info) { return true; } -#endif #if FEATURE_FAST_CREATE /// @@ -215,7 +213,6 @@ private static bool IndexIsNotReturnType(int index, MethodInfo target, Parameter } #endif -#if FEATURE_DLG_INVOKE /// /// Uses reflection to create new instance of the appropriate ReflectedCaller /// @@ -243,7 +240,6 @@ private static CallInstruction SlowCreate(MethodInfo info, ParameterInfo[] pis) throw ContractUtils.Unreachable; } } -#endif #endregion diff --git a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs index 0c591d6f3ae0..35c0c9cb9287 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs @@ -25,6 +25,12 @@ public abstract class LambdaExpression : Expression, IParameterProvider private readonly Expression _body; + // This can be flipped to false using feature switches at publishing time + public static bool CanCompileToIL => true; + + // This could be flipped to false using feature switches at publishing time + public static bool CanInterpret => true; + internal LambdaExpression(Expression body) { _body = body; @@ -130,11 +136,15 @@ internal static MethodInfo GetCompileMethod(Type lambdaExpressionType) /// A delegate containing the compiled version of the lambda. public Delegate Compile() { -#if FEATURE_COMPILE - return Compiler.LambdaCompiler.Compile(this); -#else - return new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); -#endif + if (CanCompileToIL) + { + return Compiler.LambdaCompiler.Compile(this); + } + else + { + Debug.Assert(CanInterpret); + return new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); + } } /// @@ -144,12 +154,11 @@ public Delegate Compile() /// A delegate containing the compiled version of the lambda. public Delegate Compile(bool preferInterpretation) { -#if FEATURE_COMPILE && FEATURE_INTERPRET - if (preferInterpretation) + if (CanCompileToIL && CanInterpret && preferInterpretation) { return new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); } -#endif + return Compile(); } @@ -169,10 +178,7 @@ public void CompileToMethod(System.Reflection.Emit.MethodBuilder method) } #endif - -#if FEATURE_COMPILE internal abstract LambdaExpression Accept(Compiler.StackSpiller spiller); -#endif /// /// Produces a delegate that represents the lambda expression. @@ -210,11 +216,15 @@ internal Expression(Expression body) /// A delegate containing the compiled version of the lambda. public new TDelegate Compile() { -#if FEATURE_COMPILE - return (TDelegate)(object)Compiler.LambdaCompiler.Compile(this); -#else - return (TDelegate)(object)new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); -#endif + if (CanCompileToIL) + { + return (TDelegate)(object)Compiler.LambdaCompiler.Compile(this); + } + else + { + Debug.Assert(CanInterpret); + return (TDelegate)(object)new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); + } } /// @@ -224,12 +234,11 @@ internal Expression(Expression body) /// A delegate containing the compiled version of the lambda. public new TDelegate Compile(bool preferInterpretation) { -#if FEATURE_COMPILE && FEATURE_INTERPRET - if (preferInterpretation) + if (CanCompileToIL && CanInterpret && preferInterpretation) { return (TDelegate)(object)new Interpreter.LightCompiler().CompileTop(this).CreateDelegate(); } -#endif + return Compile(); } @@ -290,7 +299,6 @@ protected internal override Expression Accept(ExpressionVisitor visitor) return visitor.VisitLambda(this); } -#if FEATURE_COMPILE internal override LambdaExpression Accept(Compiler.StackSpiller spiller) { return spiller.Rewrite(this); @@ -312,7 +320,6 @@ internal static Expression Create(Expression body, string? name, bool return new FullExpression(body, name, tailCall, parameters); } -#endif /// /// Produces a delegate that represents the lambda expression. @@ -325,7 +332,6 @@ internal static Expression Create(Expression body, string? name, bool } } -#if !FEATURE_COMPILE // Separate expression creation class to hide the CreateExpressionFunc function from users reflecting on Expression internal static class ExpressionCreator { @@ -346,7 +352,6 @@ public static Expression CreateExpressionFunc(Expression body, string return new FullExpression(body, name, tailCall, parameters); } } -#endif internal sealed class Expression0 : Expression { @@ -616,11 +621,16 @@ internal static LambdaExpression CreateLambda(Type delegateType, Expression body if (!factories.TryGetValue(delegateType, out fastPath)) { -#if FEATURE_COMPILE - MethodInfo create = typeof(Expression<>).MakeGenericType(delegateType).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic)!; -#else - MethodInfo create = typeof(ExpressionCreator<>).MakeGenericType(delegateType).GetMethod("CreateExpressionFunc", BindingFlags.Static | BindingFlags.Public)!; -#endif + MethodInfo create; + if (LambdaExpression.CanCompileToIL) + { + create = typeof(Expression<>).MakeGenericType(delegateType).GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic)!; + } + else + { + create = typeof(ExpressionCreator<>).MakeGenericType(delegateType).GetMethod("CreateExpressionFunc", BindingFlags.Static | BindingFlags.Public)!; + } + if (delegateType.IsCollectible) { return (LambdaExpression)create.Invoke(null, new object?[] { body, name, tailCall, parameters })!; @@ -708,11 +718,14 @@ public static Expression Lambda(Expression body, string? n { ReadOnlyCollection parameterList = parameters.ToReadOnly(); ValidateLambdaArgs(typeof(TDelegate), ref body, parameterList, nameof(TDelegate)); -#if FEATURE_COMPILE - return Expression.Create(body, name, tailCall, parameterList); -#else - return ExpressionCreator.CreateExpressionFunc(body, name, tailCall, parameterList); -#endif + if (LambdaExpression.CanCompileToIL) + { + return Expression.Create(body, name, tailCall, parameterList); + } + else + { + return ExpressionCreator.CreateExpressionFunc(body, name, tailCall, parameterList); + } } /// diff --git a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs index 13d01aeb3cec..e89265ab7333 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/CallSite.cs @@ -279,24 +279,15 @@ internal void MoveRule(int i) } } -#if FEATURE_COMPILE [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060:MakeGenericMethod", Justification = "UpdateDelegates methods don't have ILLink annotations.")] -#endif internal T MakeUpdateDelegate() { -#if !FEATURE_COMPILE Type target = typeof(T); MethodInfo invoke = target.GetInvokeMethod(); - s_cachedNoMatch = CreateCustomNoMatchDelegate(invoke); - return CreateCustomUpdateDelegate(invoke); -#else - Type target = typeof(T); - Type[] args; - MethodInfo invoke = target.GetInvokeMethod(); - - if (target.IsGenericType && IsSimpleSignature(invoke, out args)) + if (System.Linq.Expressions.LambdaExpression.CanCompileToIL + && target.IsGenericType && IsSimpleSignature(invoke, out Type[] args)) { MethodInfo? method = null; MethodInfo? noMatchMethod = null; @@ -326,10 +317,8 @@ internal T MakeUpdateDelegate() s_cachedNoMatch = CreateCustomNoMatchDelegate(invoke); return CreateCustomUpdateDelegate(invoke); -#endif } -#if FEATURE_COMPILE private static bool IsSimpleSignature(MethodInfo invoke, out Type[] sig) { ParameterInfo[] pis = invoke.GetParametersCached(); @@ -354,7 +343,6 @@ private static bool IsSimpleSignature(MethodInfo invoke, out Type[] sig) sig = args; return supported; } -#endif [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2060:MakeGenericMethod", Justification = "CallSiteOps methods don't have trimming annotations.")] diff --git a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/DebugInfoGenerator.cs b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/DebugInfoGenerator.cs index a1bd0c8c45fc..7b8127295d50 100644 --- a/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/DebugInfoGenerator.cs +++ b/src/libraries/System.Linq.Expressions/src/System/Runtime/CompilerServices/DebugInfoGenerator.cs @@ -32,7 +32,6 @@ public static DebugInfoGenerator CreatePdbGenerator() /// Debug information corresponding to the sequence point. public abstract void MarkSequencePoint(LambdaExpression method, int ilOffset, DebugInfoExpression sequencePoint); -#if FEATURE_COMPILE internal virtual void MarkSequencePoint(LambdaExpression method, MethodBase methodBase, ILGenerator ilg, DebugInfoExpression sequencePoint) { MarkSequencePoint(method, ilg.ILOffset, sequencePoint); @@ -42,6 +41,5 @@ internal virtual void SetLocalName(LocalBuilder localBuilder, string name) { // nop } -#endif } } diff --git a/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Coalesce/BinaryCoalesceTests.cs b/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Coalesce/BinaryCoalesceTests.cs index bbe954f78a1d..50131d51cbc2 100644 --- a/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Coalesce/BinaryCoalesceTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Coalesce/BinaryCoalesceTests.cs @@ -494,8 +494,7 @@ public static void CoalesceReferenceToValueType(bool useInterpreter) Assert.Equal(1, func()); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_NullableIntCoalesceToNullableInt() { @@ -523,7 +522,6 @@ [0] valuetype [System.Private.CoreLib]System.Nullable`1 IL_0015: ret }"); } -#endif [Theory, ClassData(typeof(CompilationTypes))] public static void CoalesceWideningLeft(bool useInterpreter) diff --git a/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Logical/BinaryLogicalTests.cs b/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Logical/BinaryLogicalTests.cs index ea2ebbb60b8c..c1db2afa8e14 100644 --- a/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Logical/BinaryLogicalTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/BinaryOperators/Logical/BinaryLogicalTests.cs @@ -415,9 +415,7 @@ public static void MethodDeclaringTypeHasNoTrueFalseOperator_ThrowsArgumentExcep AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(5), Expression.Constant(5), method)); } -#if FEATURE_COMPILE - - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlso_NoMethod_NotStatic_ThrowsInvalidOperationException() { TypeBuilder type = GetTypeBuilder(); @@ -430,7 +428,7 @@ public static void AndAlso_NoMethod_NotStatic_ThrowsInvalidOperationException() Assert.Throws(() => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElse_NoMethod_NotStatic_ThrowsInvalidOperationException() { TypeBuilder type = GetTypeBuilder(); @@ -443,7 +441,7 @@ public static void OrElse_NoMethod_NotStatic_ThrowsInvalidOperationException() Assert.Throws(() => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlso_NoMethod_VoidReturnType_ThrowsArgumentException() { TypeBuilder type = GetTypeBuilder(); @@ -456,7 +454,7 @@ public static void AndAlso_NoMethod_VoidReturnType_ThrowsArgumentException() AssertExtensions.Throws("method", () => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElse_NoMethod_VoidReturnType_ThrowsArgumentException() { TypeBuilder type = GetTypeBuilder(); @@ -469,7 +467,7 @@ public static void OrElse_NoMethod_VoidReturnType_ThrowsArgumentException() AssertExtensions.Throws("method", () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [InlineData(0)] [InlineData(1)] [InlineData(3)] @@ -485,7 +483,7 @@ public static void AndAlso_NoMethod_DoesntHaveTwoParameters_ThrowsInvalidOperati Assert.Throws(() => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [InlineData(0)] [InlineData(1)] [InlineData(3)] @@ -501,7 +499,7 @@ public static void OrElse_NoMethod_DoesntHaveTwoParameters_ThrowsInvalidOperatio Assert.Throws(() => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlso_NoMethod_ExpressionDoesntMatchMethodParameters_ThrowsInvalidOperationException() { TypeBuilder type = GetTypeBuilder(); @@ -514,7 +512,7 @@ public static void AndAlso_NoMethod_ExpressionDoesntMatchMethodParameters_Throws Assert.Throws(() => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElse_NoMethod_ExpressionDoesntMatchMethodParameters_ThrowsInvalidOperationException() { TypeBuilder type = GetTypeBuilder(); @@ -528,7 +526,7 @@ public static void OrElse_NoMethod_ExpressionDoesntMatchMethodParameters_ThrowsI } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlso_NoMethod_ReturnTypeNotEqualToParameterTypes_ThrowsArgumentException() { TypeBuilder type = GetTypeBuilder(); @@ -541,7 +539,7 @@ public static void AndAlso_NoMethod_ReturnTypeNotEqualToParameterTypes_ThrowsArg AssertExtensions.Throws(null, () => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElse_NoMethod_ReturnTypeNotEqualToParameterTypes_ThrowsArgumentException() { TypeBuilder type = GetTypeBuilder(); @@ -571,7 +569,7 @@ public static IEnumerable Operator_IncorrectMethod_TestData() yield return new object[] { GetTypeBuilder(), typeof(bool), new Type[0] }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [MemberData(nameof(Operator_IncorrectMethod_TestData))] public static void Method_TrueOperatorIncorrectMethod_ThrowsArgumentException(TypeBuilder builder, Type returnType, Type[] parameterTypes) { @@ -592,7 +590,7 @@ public static void Method_TrueOperatorIncorrectMethod_ThrowsArgumentException(Ty AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj), createdMethod)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [MemberData(nameof(Operator_IncorrectMethod_TestData))] public static void Method_FalseOperatorIncorrectMethod_ThrowsArgumentException(TypeBuilder builder, Type returnType, Type[]parameterTypes) { @@ -613,7 +611,7 @@ public static void Method_FalseOperatorIncorrectMethod_ThrowsArgumentException(T AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj), createdMethod)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [MemberData(nameof(Operator_IncorrectMethod_TestData))] public static void AndAlso_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentException(TypeBuilder builder, Type returnType, Type[] parameterTypes) { @@ -632,7 +630,7 @@ public static void AndAlso_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentEx AssertExtensions.Throws(null, () => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [MemberData(nameof(Operator_IncorrectMethod_TestData))] public static void OrElse_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentException(TypeBuilder builder, Type returnType, Type[] parameterTypes) { @@ -651,7 +649,7 @@ public static void OrElse_NoMethod_TrueOperatorIncorrectMethod_ThrowsArgumentExc AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [InlineData("op_True")] [InlineData("op_False")] public static void Method_NoTrueFalseOperator_ThrowsArgumentException(string name) @@ -674,7 +672,7 @@ public static void Method_NoTrueFalseOperator_ThrowsArgumentException(string nam AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj), createdMethod)); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [InlineData("op_True")] [InlineData("op_False")] public static void AndAlso_NoMethod_NoTrueFalseOperator_ThrowsArgumentException(string name) @@ -694,7 +692,7 @@ public static void AndAlso_NoMethod_NoTrueFalseOperator_ThrowsArgumentException( AssertExtensions.Throws(null, () => Expression.AndAlso(Expression.Constant(obj), Expression.Constant(obj))); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [InlineData("op_True")] [InlineData("op_False")] public static void OrElse_NoMethod_NoTrueFalseOperator_ThrowsArgumentException(string name) @@ -714,7 +712,7 @@ public static void OrElse_NoMethod_NoTrueFalseOperator_ThrowsArgumentException(s AssertExtensions.Throws(null, () => Expression.OrElse(Expression.Constant(obj), Expression.Constant(obj))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Method_ParamsDontMatchOperator_ThrowsInvalidOperationException() { TypeBuilder builder = GetTypeBuilder(); @@ -735,7 +733,7 @@ public static void Method_ParamsDontMatchOperator_ThrowsInvalidOperationExceptio Assert.Throws(() => Expression.OrElse(Expression.Constant(5), Expression.Constant(5), createdMethod)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlso_NoMethod_ParamsDontMatchOperator_ThrowsInvalidOperationException() { TypeBuilder builder = GetTypeBuilder(); @@ -753,7 +751,7 @@ public static void AndAlso_NoMethod_ParamsDontMatchOperator_ThrowsInvalidOperati Assert.Throws(() => Expression.OrElse(Expression.Constant(5), Expression.Constant(5))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElse_NoMethod_ParamsDontMatchOperator_ThrowsInvalidOperationException() { TypeBuilder builder = GetTypeBuilder(); @@ -771,8 +769,6 @@ public static void OrElse_NoMethod_ParamsDontMatchOperator_ThrowsInvalidOperatio Assert.Throws(() => Expression.OrElse(Expression.Constant(5), Expression.Constant(5))); } -#endif - [Fact] public static void ImplicitConversionToBool_ThrowsArgumentException() { @@ -821,15 +817,14 @@ public static void ToStringTest() Assert.Equal("(a OrElse b)", e2.ToString()); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void AndAlsoGlobalMethod() { MethodInfo method = GlobalMethod(typeof(int), new[] { typeof(int), typeof(int) }); AssertExtensions.Throws(null, () => Expression.AndAlso(Expression.Constant(1), Expression.Constant(2), method)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void OrElseGlobalMethod() { MethodInfo method = GlobalMethod(typeof(int), new [] { typeof(int), typeof(int) }); @@ -851,7 +846,6 @@ private static MethodInfo GlobalMethod(Type returnType, Type[] parameterTypes) module.CreateGlobalFunctions(); return module.GetMethod(globalMethod.Name); } -#endif public class NonGenericClass { diff --git a/src/libraries/System.Linq.Expressions/tests/Cast/CastTests.cs b/src/libraries/System.Linq.Expressions/tests/Cast/CastTests.cs index 090878f8fee7..64e20adf5cfd 100644 --- a/src/libraries/System.Linq.Expressions/tests/Cast/CastTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Cast/CastTests.cs @@ -2372,10 +2372,12 @@ public static IEnumerable EnumerableTypes() yield return typeof(UInt32Enum); yield return typeof(Int64Enum); yield return typeof(UInt64Enum); -#if FEATURE_COMPILE - yield return NonCSharpTypes.CharEnumType; - yield return NonCSharpTypes.BoolEnumType; -#endif + + if (PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly) + { + yield return NonCSharpTypes.CharEnumType; + yield return NonCSharpTypes.BoolEnumType; + } } public static IEnumerable EnumerableTypeArgs() => EnumerableTypes().Select(t => new object[] { t }); diff --git a/src/libraries/System.Linq.Expressions/tests/CompilerTests.cs b/src/libraries/System.Linq.Expressions/tests/CompilerTests.cs index 9f4d1f7f6a53..18cd5b02400b 100644 --- a/src/libraries/System.Linq.Expressions/tests/CompilerTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/CompilerTests.cs @@ -27,8 +27,7 @@ public static void CompileDeepTree_NoStackOverflow(bool useInterpreter) Assert.Equal(n, f()); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_NonNullableValueTypes() { VerifyEmitConstantsToIL((bool)true); @@ -49,7 +48,7 @@ public static void EmitConstantsToIL_NonNullableValueTypes() VerifyEmitConstantsToIL((decimal)49.95m); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_NullableValueTypes() { VerifyEmitConstantsToIL((bool?)null); @@ -85,14 +84,14 @@ public static void EmitConstantsToIL_NullableValueTypes() VerifyEmitConstantsToIL((DateTime?)null); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_ReferenceTypes() { VerifyEmitConstantsToIL((string)null); VerifyEmitConstantsToIL((string)"bar"); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_Enums() { VerifyEmitConstantsToIL(ConstantsEnum.A); @@ -100,21 +99,21 @@ public static void EmitConstantsToIL_Enums() VerifyEmitConstantsToIL((ConstantsEnum?)ConstantsEnum.A); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_ShareReferences() { var o = new object(); VerifyEmitConstantsToIL(Expression.Equal(Expression.Constant(o), Expression.Constant(o)), 1, true); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void EmitConstantsToIL_LiftedToClosure() { VerifyEmitConstantsToIL(DateTime.Now, 1); VerifyEmitConstantsToIL((DateTime?)DateTime.Now, 1); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void VariableBinder_CatchBlock_Filter1() { // See https://github.com/dotnet/runtime/issues/18676 for reported issue @@ -128,7 +127,7 @@ public static void VariableBinder_CatchBlock_Filter1() ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void VariableBinder_CatchBlock_Filter2() { // See https://github.com/dotnet/runtime/issues/18676 for reported issue @@ -142,7 +141,7 @@ public static void VariableBinder_CatchBlock_Filter2() ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_Simple() { @@ -159,7 +158,7 @@ .maxstack 1 }"); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_Exceptions() { @@ -220,7 +219,7 @@ [0] int32 }"); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_Closure1() { @@ -255,7 +254,7 @@ .maxstack 1 appendInnerLambdas: true); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_Closure2() { @@ -313,7 +312,7 @@ [0] object[] appendInnerLambdas: true); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_Closure3() { @@ -431,7 +430,6 @@ private static void Verify_VariableBinder_CatchBlock_Filter(CatchBlock @catch) Assert.Throws(() => e.Compile()); } -#endif } public enum ConstantsEnum diff --git a/src/libraries/System.Linq.Expressions/tests/Constant/ConstantTests.cs b/src/libraries/System.Linq.Expressions/tests/Constant/ConstantTests.cs index b5e150317213..40ff43d0d5ff 100644 --- a/src/libraries/System.Linq.Expressions/tests/Constant/ConstantTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Constant/ConstantTests.cs @@ -278,14 +278,12 @@ public static void CheckUShortConstantTest(bool useInterpreter) } } -#if FEATURE_COMPILE private static TypeBuilder GetTypeBuilder() { AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect); ModuleBuilder module = assembly.DefineDynamicModule("Name"); return module.DefineType("Type"); } -#endif [Theory, ClassData(typeof(CompilationTypes))] public static void CheckTypeConstantTest(bool useInterpreter) @@ -296,9 +294,6 @@ public static void CheckTypeConstantTest(bool useInterpreter) typeof(int), typeof(Func), typeof(List<>).GetGenericArguments()[0], -#if FEATURE_COMPILE - GetTypeBuilder(), -#endif typeof(PrivateGenericClass<>).GetGenericArguments()[0], typeof(PrivateGenericClass<>), typeof(PrivateGenericClass) @@ -306,9 +301,12 @@ public static void CheckTypeConstantTest(bool useInterpreter) { VerifyTypeConstant(value, useInterpreter); } - } -#if FEATURE_COMPILE + if (PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly) + { + VerifyTypeConstant(GetTypeBuilder(), useInterpreter); + } + } private static MethodInfo GlobalMethod(params Type[] parameterTypes) { @@ -319,7 +317,8 @@ private static MethodInfo GlobalMethod(params Type[] parameterTypes) return module.GetMethod(globalMethod.Name); } - [Theory, ClassData(typeof(CompilationTypes))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [ClassData(typeof(CompilationTypes))] public static void CheckMethodInfoConstantTest(bool useInterpreter) { foreach (MethodInfo value in new MethodInfo[] @@ -338,7 +337,6 @@ public static void CheckMethodInfoConstantTest(bool useInterpreter) VerifyMethodInfoConstant(value, useInterpreter); } } -#endif [Theory, ClassData(typeof(CompilationTypes))] public static void CheckConstructorInfoConstantTest(bool useInterpreter) diff --git a/src/libraries/System.Linq.Expressions/tests/DelegateType/GetDelegateTypeTests.cs b/src/libraries/System.Linq.Expressions/tests/DelegateType/GetDelegateTypeTests.cs index 6b790c491186..9d0852a84791 100644 --- a/src/libraries/System.Linq.Expressions/tests/DelegateType/GetDelegateTypeTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/DelegateType/GetDelegateTypeTests.cs @@ -57,17 +57,20 @@ public void GetNullaryAction() [MemberData(nameof(ManagedPointerTypeArgs))] public void CantBeFunc(Type[] typeArgs) { -#if !FEATURE_COMPILE - Assert.Throws(() => Expression.GetDelegateType(typeArgs)); -#else - Type delType = Expression.GetDelegateType(typeArgs); - Assert.True(typeof(MulticastDelegate).IsAssignableFrom(delType)); - Assert.DoesNotMatch(new Regex(@"System\.Action"), delType.FullName); - Assert.DoesNotMatch(new Regex(@"System\.Func"), delType.FullName); - Reflection.MethodInfo method = delType.GetMethod("Invoke"); - Assert.Equal(typeArgs.Last(), method.ReturnType); - Assert.Equal(typeArgs.Take(typeArgs.Length - 1), method.GetParameters().Select(p => p.ParameterType)); -#endif + if (PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly) + { + Assert.Throws(() => Expression.GetDelegateType(typeArgs)); + } + else + { + Type delType = Expression.GetDelegateType(typeArgs); + Assert.True(typeof(MulticastDelegate).IsAssignableFrom(delType)); + Assert.DoesNotMatch(new Regex(@"System\.Action"), delType.FullName); + Assert.DoesNotMatch(new Regex(@"System\.Func"), delType.FullName); + Reflection.MethodInfo method = delType.GetMethod("Invoke"); + Assert.Equal(typeArgs.Last(), method.ReturnType); + Assert.Equal(typeArgs.Take(typeArgs.Length - 1), method.GetParameters().Select(p => p.ParameterType)); + } } [Theory] @@ -80,17 +83,20 @@ public void CantBeFunc(Type[] typeArgs) public void CantBeAction(Type[] typeArgs) { Type[] delegateArgs = typeArgs.Append(typeof(void)).ToArray(); -#if !FEATURE_COMPILE - Assert.Throws(() => Expression.GetDelegateType(delegateArgs)); -#else - Type delType = Expression.GetDelegateType(delegateArgs); - Assert.True(typeof(MulticastDelegate).IsAssignableFrom(delType)); - Assert.DoesNotMatch(new Regex(@"System\.Action"), delType.FullName); - Assert.DoesNotMatch(new Regex(@"System\.Func"), delType.FullName); - Reflection.MethodInfo method = delType.GetMethod("Invoke"); - Assert.Equal(typeof(void), method.ReturnType); - Assert.Equal(typeArgs, method.GetParameters().Select(p => p.ParameterType)); -#endif + if (PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly) + { + Assert.Throws(() => Expression.GetDelegateType(delegateArgs)); + } + else + { + Type delType = Expression.GetDelegateType(delegateArgs); + Assert.True(typeof(MulticastDelegate).IsAssignableFrom(delType)); + Assert.DoesNotMatch(new Regex(@"System\.Action"), delType.FullName); + Assert.DoesNotMatch(new Regex(@"System\.Func"), delType.FullName); + Reflection.MethodInfo method = delType.GetMethod("Invoke"); + Assert.Equal(typeof(void), method.ReturnType); + Assert.Equal(typeArgs, method.GetParameters().Select(p => p.ParameterType)); + } } // Open generic type args aren't useful directly with Expressions, but creating them is allowed. diff --git a/src/libraries/System.Linq.Expressions/tests/Dynamic/InvokeMemberBindingTests.cs b/src/libraries/System.Linq.Expressions/tests/Dynamic/InvokeMemberBindingTests.cs index a9a77a61e7f9..616f22345247 100644 --- a/src/libraries/System.Linq.Expressions/tests/Dynamic/InvokeMemberBindingTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Dynamic/InvokeMemberBindingTests.cs @@ -186,8 +186,6 @@ public void CallInfoStored() Assert.Same(info, new MinimumOverrideInvokeMemberBinding("name", false, info).CallInfo); } -#if FEATURE_COMPILE // We're not testing compilation, but we do need Reflection.Emit for the test - private static dynamic GetObjectWithNonIndexerParameterProperty(bool hasGetter, bool hasSetter) { TypeBuilder typeBuild = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("TestAssembly"), AssemblyBuilderAccess.RunAndCollect) @@ -233,7 +231,8 @@ private static dynamic GetObjectWithNonIndexerParameterProperty(bool hasGetter, return Activator.CreateInstance(typeBuild.CreateType()); } - [Fact] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void NonIndexerParameterizedDirectAccess() { // If a parameterized property isn't the type's indexer, we should be allowed to use the @@ -244,7 +243,8 @@ public void NonIndexerParameterizedDirectAccess() Assert.Equal(19, value); } - [Fact] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void NonIndexerParameterizedGetterAndSetterIndexAccess() { dynamic d = GetObjectWithNonIndexerParameterProperty(true, true); @@ -254,7 +254,8 @@ public void NonIndexerParameterizedGetterAndSetterIndexAccess() Assert.Contains("set_ItemProp", ex.Message); } - [Fact] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void NonIndexerParameterizedGetterOnlyIndexAccess() { dynamic d = GetObjectWithNonIndexerParameterProperty(true, false); @@ -264,7 +265,8 @@ public void NonIndexerParameterizedGetterOnlyIndexAccess() Assert.Contains("get_ItemProp", ex.Message); } - [Fact] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void NonIndexerParameterizedSetterOnlyIndexAccess() { dynamic d = GetObjectWithNonIndexerParameterProperty(false, true); @@ -333,7 +335,8 @@ public int GetValue2( int arg10) => 11; } - [Fact] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void ManyArities() { dynamic d = new ManyOverloads(); @@ -377,7 +380,9 @@ public static IEnumerable SameNameObjectPairs() return testObjects.SelectMany(i => testObjects.Select(j => new[] { i, j })); } - [Theory, MemberData(nameof(SameNameObjectPairs))] + // We're not testing compilation, but we do need Reflection.Emit for the test + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [MemberData(nameof(SameNameObjectPairs))] public void OperationOnTwoObjectsDifferentTypesOfSameName(object x, object y) { dynamic dX = x; @@ -386,8 +391,6 @@ public void OperationOnTwoObjectsDifferentTypesOfSameName(object x, object y) Assert.Equal(x == y, equal); } -#endif - public class FuncWrapper { public delegate void OutAction(out TResult arg); diff --git a/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs b/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs index d9d1d951a441..26ca0e2ea511 100644 --- a/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs +++ b/src/libraries/System.Linq.Expressions/tests/ExceptionHandling/ExceptionHandlingExpressions.cs @@ -240,9 +240,8 @@ public void ExpressionsUnwrapeExternallyThrownRuntimeWrappedException(bool useIn Assert.Equal(4, func()); } -#if FEATURE_COMPILE - - [Theory, ClassData(typeof(CompilationTypes))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [ClassData(typeof(CompilationTypes))] public void CatchFromExternallyThrownString(bool useInterpreter) { foreach (bool assemblyWraps in new []{false, true}) @@ -274,7 +273,6 @@ public void CatchFromExternallyThrownString(bool useInterpreter) Assert.Equal("An Exceptional Exception!", func()); } } -#endif [Theory] [ClassData(typeof(CompilationTypes))] @@ -1006,11 +1004,14 @@ public void TryFinallyWithinFilterCompiledProhibited() ) ); Expression> lambda = Expression.Lambda>(tryExp); -#if FEATURE_COMPILE - Assert.Throws(() => lambda.Compile(false)); -#else - lambda.Compile(true); -#endif + if (PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly) + { + Assert.Throws(() => lambda.Compile(false)); + } + else + { + lambda.Compile(true); + } } [Theory, InlineData(true)] diff --git a/src/libraries/System.Linq.Expressions/tests/HelperTypes.cs b/src/libraries/System.Linq.Expressions/tests/HelperTypes.cs index aca1e6a4a5c5..ae01067743f9 100644 --- a/src/libraries/System.Linq.Expressions/tests/HelperTypes.cs +++ b/src/libraries/System.Linq.Expressions/tests/HelperTypes.cs @@ -246,13 +246,23 @@ public struct PS internal class CompilationTypes : IEnumerable { - private static readonly IEnumerable Booleans = new[] + private static IEnumerable Booleans { -#if FEATURE_COMPILE && FEATURE_INTERPRET - new object[] {false}, -#endif - new object[] {true}, - }; + get + { + return LambdaExpression.CanCompileToIL ? + new[] + { + new object[] {false}, + new object[] {true}, + } + : + new[] + { + new object[] {true}, + }; + } + } public IEnumerator GetEnumerator() => Booleans.GetEnumerator(); @@ -366,7 +376,6 @@ public enum UInt32Enum : uint { A = uint.MaxValue } public enum Int64Enum : long { A = long.MaxValue } public enum UInt64Enum : ulong { A = ulong.MaxValue } -#if FEATURE_COMPILE public static class NonCSharpTypes { private static Type _charEnumType; @@ -412,7 +421,6 @@ public static Type BoolEnumType } } } -#endif public class FakeExpression : Expression { @@ -467,15 +475,17 @@ public static class ExpressionAssert { public static void Verify(this LambdaExpression expression, string il, string instructions) { -#if FEATURE_COMPILE - expression.VerifyIL(il); -#endif + if (LambdaExpression.CanCompileToIL) + { + expression.VerifyIL(il); + } - // FEATURE_COMPILE is not directly required, + // LambdaExpression.CanCompileToIL is not directly required, // but this functionality relies on private reflection and that would not work with AOT -#if FEATURE_INTERPRET && FEATURE_COMPILE - expression.VerifyInstructions(instructions); -#endif + if (LambdaExpression.CanCompileToIL && LambdaExpression.CanInterpret) + { + expression.VerifyInstructions(instructions); + } } } diff --git a/src/libraries/System.Linq.Expressions/tests/IndexExpression/IndexExpressionTests.cs b/src/libraries/System.Linq.Expressions/tests/IndexExpression/IndexExpressionTests.cs index 438bdf04ea70..98a436c9f4a1 100644 --- a/src/libraries/System.Linq.Expressions/tests/IndexExpression/IndexExpressionTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/IndexExpression/IndexExpressionTests.cs @@ -92,13 +92,12 @@ public static void ToStringTest() Assert.Equal("xs[i, j]", e3.ToString()); } -#if FEATURE_COMPILE private static TypeBuilder GetTestTypeBuilder() => AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("TestAssembly"), AssemblyBuilderAccess.RunAndCollect) .DefineDynamicModule("TestModule") .DefineType("TestType"); - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14920", TestRuntimes.Mono)] public void NoAccessorIndexedProperty() { @@ -114,7 +113,7 @@ public void NoAccessorIndexedProperty() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void ByRefIndexedProperty() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -145,7 +144,7 @@ public void ByRefIndexedProperty() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void VoidIndexedProperty() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -173,7 +172,7 @@ public void VoidIndexedProperty() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14927", TestRuntimes.Mono)] public void IndexedPropertyGetReturnsWrongType() { @@ -202,7 +201,7 @@ public void IndexedPropertyGetReturnsWrongType() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertySetterNoParams() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -230,7 +229,7 @@ public void IndexedPropertySetterNoParams() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertySetterByrefValueType() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -258,7 +257,7 @@ public void IndexedPropertySetterByrefValueType() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertySetterNotReturnVoid() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -286,7 +285,7 @@ public void IndexedPropertySetterNotReturnVoid() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertyGetterInstanceSetterStatic() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -326,7 +325,7 @@ public void IndexedPropertyGetterInstanceSetterStatic() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14927", TestRuntimes.Mono)] public void IndexedPropertySetterValueTypeNotMatchPropertyType() { @@ -355,7 +354,7 @@ public void IndexedPropertySetterValueTypeNotMatchPropertyType() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertyGetterSetterArgCountMismatch() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -395,7 +394,7 @@ public void IndexedPropertyGetterSetterArgCountMismatch() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertyGetterSetterArgumentTypeMismatch() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -435,7 +434,7 @@ public void IndexedPropertyGetterSetterArgumentTypeMismatch() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0), Expression.Constant(0), Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void IndexedPropertyVarArgs() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -465,7 +464,7 @@ public void IndexedPropertyVarArgs() AssertExtensions.Throws("propertyName", () => Expression.Property(instance, "Item", Expression.Constant(0), Expression.Constant(0), Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void NullInstanceInstanceProperty() { PropertyInfo prop = typeof(Dictionary).GetProperty("Item"); @@ -473,7 +472,7 @@ public void NullInstanceInstanceProperty() AssertExtensions.Throws("instance", () => Expression.Property(null, prop, index)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void InstanceToStaticProperty() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -501,7 +500,7 @@ public void InstanceToStaticProperty() AssertExtensions.Throws("instance", () => Expression.Property(instance, prop, Expression.Constant(0))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void ByRefIndexer() { TypeBuilder typeBuild = GetTestTypeBuilder(); @@ -529,9 +528,6 @@ public void ByRefIndexer() AssertExtensions.Throws("indexes[0]", () => Expression.Property(instance, prop, Expression.Constant(0))); } -// FEATURE_COMPILE -#endif - [Fact] public void CallWithoutIndices() { diff --git a/src/libraries/System.Linq.Expressions/tests/InterpreterTests.cs b/src/libraries/System.Linq.Expressions/tests/InterpreterTests.cs index 146dffb4be4c..4298013f5f59 100644 --- a/src/libraries/System.Linq.Expressions/tests/InterpreterTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/InterpreterTests.cs @@ -1,10 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// FEATURE_COMPILE is not directly required, -// but this functionality relies on private reflection and that would not work with AOT -#if FEATURE_INTERPRET && FEATURE_COMPILE - using System.Linq.Expressions.Interpreter; using System.Reflection; using Xunit; @@ -15,7 +11,9 @@ public static class InterpreterTests { private static readonly PropertyInfo s_debugView = typeof(LightLambda).GetPropertyAssert("DebugView"); - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void VerifyInstructions_Simple() { // Using an unchecked multiplication to ensure that a mul instruction is emitted (and not mul.ovf) @@ -46,7 +44,9 @@ .maxcontinuation 0 }"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void VerifyInstructions_Exceptions() { ParameterExpression x = Expression.Parameter(typeof(int), "x"); @@ -101,7 +101,9 @@ .maxcontinuation 1 }"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue ("https://github.com/dotnet/runtime/issues/53599", platforms: TestPlatforms.MacCatalyst, runtimes: TestRuntimes.Mono)] public static void ConstructorThrows_StackTrace() { @@ -110,7 +112,9 @@ public static void ConstructorThrows_StackTrace() AssertStackTrace(() => f(), "Thrower..ctor"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void PropertyGetterThrows_StackTrace() { Expression> e = t => t.Bar; @@ -118,7 +122,9 @@ public static void PropertyGetterThrows_StackTrace() AssertStackTrace(() => f(new Thrower(error: false)), "Thrower.get_Bar"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void PropertySetterThrows_StackTrace() { ParameterExpression t = Expression.Parameter(typeof(Thrower), "t"); @@ -127,7 +133,9 @@ public static void PropertySetterThrows_StackTrace() AssertStackTrace(() => f(new Thrower(error: false)), "Thrower.set_Bar"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void IndexerGetterThrows_StackTrace() { ParameterExpression t = Expression.Parameter(typeof(Thrower), "t"); @@ -136,7 +144,9 @@ public static void IndexerGetterThrows_StackTrace() AssertStackTrace(() => f(new Thrower(error: false)), "Thrower.get_Item"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void IndexerSetterThrows_StackTrace() { ParameterExpression t = Expression.Parameter(typeof(Thrower), "t"); @@ -145,7 +155,9 @@ public static void IndexerSetterThrows_StackTrace() AssertStackTrace(() => f(new Thrower(error: false)), "Thrower.set_Item"); } - [Fact] + // IsNotLinqExpressionsBuiltWithIsInterpretingOnly is not directly required, + // but this functionality relies on private reflection and that would not work with AOT + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void MethodThrows_StackTrace() { Expression> e = t => t.Foo(); @@ -232,5 +244,3 @@ public void Foo() } } } - -#endif diff --git a/src/libraries/System.Linq.Expressions/tests/Invoke/InvocationTests.cs b/src/libraries/System.Linq.Expressions/tests/Invoke/InvocationTests.cs index ea2e7b9b85aa..829e7e435ba3 100644 --- a/src/libraries/System.Linq.Expressions/tests/Invoke/InvocationTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Invoke/InvocationTests.cs @@ -244,9 +244,9 @@ public static void LambdaAndArgChangeVisit(InvocationExpression invoke) Assert.NotSame(invoke, new ParameterAndConstantChangingVisitor().Visit(invoke)); } -#if FEATURE_COMPILE // When we don't have FEATURE_COMPILE we don't have the Reflection.Emit used in the tests. - - [Theory, ClassData(typeof(CompilationTypes))] + // When we don't have IsNotLinqExpressionsBuiltWithIsInterpretingOnly we don't have the Reflection.Emit used in the tests. + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [ClassData(typeof(CompilationTypes))] public static void InvokePrivateDelegate(bool useInterpreter) { AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect); @@ -263,7 +263,9 @@ public static void InvokePrivateDelegate(bool useInterpreter) Assert.Equal(42, invFunc()); } - [Theory, ClassData(typeof(CompilationTypes))] + // When we don't have IsNotLinqExpressionsBuiltWithIsInterpretingOnly we don't have the Reflection.Emit used in the tests. + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [ClassData(typeof(CompilationTypes))] public static void InvokePrivateDelegateTypeLambda(bool useInterpreter) { AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect); @@ -278,7 +280,6 @@ public static void InvokePrivateDelegateTypeLambda(bool useInterpreter) var invFunc = invLambda.Compile(useInterpreter); Assert.Equal(42, invFunc()); } -#endif private delegate void RefIntAction(ref int x); diff --git a/src/libraries/System.Linq.Expressions/tests/Lambda/LambdaTests.cs b/src/libraries/System.Linq.Expressions/tests/Lambda/LambdaTests.cs index 9cd8d5ef12fd..c62a6ed60273 100644 --- a/src/libraries/System.Linq.Expressions/tests/Lambda/LambdaTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Lambda/LambdaTests.cs @@ -268,9 +268,11 @@ public void ImplicitlyTyped() double, double, double, double, bool>), exp.Type); -#if FEATURE_COMPILE - // From this point on, the tests require FEATURE_COMPILE (RefEmit) support as SLE needs to create delegate types on the fly. + // From this point on, the tests require IsLinqExpressionsBuiltWithIsInterpretingOnly (RefEmit) support as SLE needs to create delegate types on the fly. // You can't instantiate Func<> over 20 arguments or over byrefs. + if (PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly) + return; + ParameterExpression[] paramList = Enumerable.Range(0, 20).Select(_ => Expression.Variable(typeof(int))).ToArray(); exp = Expression.Lambda( Expression.Constant(0), @@ -302,7 +304,6 @@ public void ImplicitlyTyped() Assert.Equal(1, delMethod.GetParameters().Length); Assert.Equal(typeof(int).MakeByRefType(), delMethod.GetParameters()[0].ParameterType); Assert.Same(delType, Expression.Lambda(Expression.Constant(3L), Expression.Parameter(typeof(int).MakeByRefType())).Type); -#endif //FEATURE_COMPILE } [Fact] @@ -790,8 +791,7 @@ public void AboveByteMaxArityArg(bool useInterpreter) Assert.Equal(23, result); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void AboveByteMaxArityArgIL() { ParameterExpression[] pars = Enumerable.Range(0, 300) @@ -808,7 +808,6 @@ .maxstack 1 } "); } -#endif private struct Mutable { @@ -882,8 +881,7 @@ public void AboveByteMaxArityArgAddress(bool useInterpreter) Assert.True(result.Mutated); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void AboveByteMaxArityArgAddressIL() { ParameterExpression parToMutate = Expression.Parameter(typeof(Mutable)); @@ -903,7 +901,6 @@ .maxstack 1 } "); } -#endif [Theory, ClassData(typeof(CompilationTypes))] public void ExcessiveArity(bool useInterpreter) @@ -927,9 +924,9 @@ public void OpenGenericDelegate() AssertExtensions.Throws("delegateType", () => Expression.Lambda(typeof(Action<>), Expression.Empty(), false, Enumerable.Empty())); } -#if FEATURE_COMPILE // When we don't have FEATURE_COMPILE we don't have the Reflection.Emit used in the tests. - - [Theory, ClassData(typeof(CompilationTypes))] + // When we don't have IsLinqExpressionsBuiltWithIsInterpretingOnly we don't have the Reflection.Emit used in the tests. + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] + [ClassData(typeof(CompilationTypes))] public void PrivateDelegate(bool useInterpreter) { AssemblyBuilder assembly = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect); @@ -944,8 +941,6 @@ public void PrivateDelegate(bool useInterpreter) Assert.Equal(42, del.DynamicInvoke()); } -#endif - [Fact] [SkipOnTargetFramework(~TargetFrameworkMonikers.Netcoreapp, "Optimization in .NET Core")] public void ValidateThatInterpreterWithSimpleTypeUsesNonDynamicThunk() diff --git a/src/libraries/System.Linq.Expressions/tests/Member/MemberAccessTests.cs b/src/libraries/System.Linq.Expressions/tests/Member/MemberAccessTests.cs index cca9a0e08c85..78466bcd842e 100644 --- a/src/libraries/System.Linq.Expressions/tests/Member/MemberAccessTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Member/MemberAccessTests.cs @@ -552,8 +552,7 @@ public static void MakeMemberAccess_MemberNotFieldOrProperty_ThrowsArgumentExcep AssertExtensions.Throws("member", () => Expression.MakeMemberAccess(Expression.Constant(new PC()), member)); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14920", TestRuntimes.Mono)] public static void Property_NoGetOrSetAccessors_ThrowsArgumentException() { @@ -575,7 +574,6 @@ public static void Property_NoGetOrSetAccessors_ThrowsArgumentException() AssertExtensions.Throws("property", () => Expression.MakeMemberAccess(expression, createdProperty)); } -#endif [Fact] public static void ToStringTest() diff --git a/src/libraries/System.Linq.Expressions/tests/MemberInit/BindTests.cs b/src/libraries/System.Linq.Expressions/tests/MemberInit/BindTests.cs index 006c4d51cdd3..8777d108110b 100644 --- a/src/libraries/System.Linq.Expressions/tests/MemberInit/BindTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/MemberInit/BindTests.cs @@ -284,8 +284,7 @@ public void BogusBindingType(MemberBinding binding) AssertExtensions.Throws("bindings[0]", () => Expression.MemberInit(Expression.New(typeof(PropertyAndFields)), binding)); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void GlobalMethod() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -296,7 +295,7 @@ public void GlobalMethod() AssertExtensions.Throws("propertyAccessor", () => Expression.Bind(globalMethodInfo, Expression.Constant(2))); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void GlobalField() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -305,6 +304,5 @@ public void GlobalField() FieldInfo globalField = module.GetField(fieldBuilder.Name); AssertExtensions.Throws("member", () => Expression.Bind(globalField, Expression.Default(globalField.FieldType))); } -#endif } } diff --git a/src/libraries/System.Linq.Expressions/tests/MemberInit/ListBindTests.cs b/src/libraries/System.Linq.Expressions/tests/MemberInit/ListBindTests.cs index c38457740ae5..3b25685e8368 100644 --- a/src/libraries/System.Linq.Expressions/tests/MemberInit/ListBindTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/MemberInit/ListBindTests.cs @@ -290,8 +290,7 @@ public void OpenGenericTypesMembers() AssertExtensions.Throws(null, () => Expression.ListBind(method)); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void GlobalMethod() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -301,7 +300,5 @@ public void GlobalMethod() MethodInfo globalMethodInfo = module.GetMethod(globalMethod.Name); AssertExtensions.Throws("propertyAccessor", () => Expression.ListBind(globalMethodInfo)); } -#endif - } } diff --git a/src/libraries/System.Linq.Expressions/tests/MemberInit/MemberBindTests.cs b/src/libraries/System.Linq.Expressions/tests/MemberInit/MemberBindTests.cs index 413ab0d7633a..8a72d0e39849 100644 --- a/src/libraries/System.Linq.Expressions/tests/MemberInit/MemberBindTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/MemberInit/MemberBindTests.cs @@ -253,8 +253,7 @@ public void StaticReadonlyInnerField(bool useInterpreter) Assert.Throws(() => exp.Compile(useInterpreter)); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void GlobalMethod() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -264,7 +263,6 @@ public void GlobalMethod() MethodInfo globalMethodInfo = module.GetMethod(globalMethod.Name); AssertExtensions.Throws("propertyAccessor", () => Expression.MemberBind(globalMethodInfo)); } -#endif [Fact] public void WriteOnlyInnerProperty() diff --git a/src/libraries/System.Linq.Expressions/tests/New/NewTests.cs b/src/libraries/System.Linq.Expressions/tests/New/NewTests.cs index 6d48041ade2b..f056ed3df36c 100644 --- a/src/libraries/System.Linq.Expressions/tests/New/NewTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/New/NewTests.cs @@ -555,8 +555,7 @@ public static void OpenGenericConstructorsInvalid(ConstructorInfo ctor, Expressi } } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void GlobalMethodInMembers() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -570,7 +569,7 @@ public static void GlobalMethodInMembers() AssertExtensions.Throws("members[0]", () => Expression.New(constructor, arguments, members)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void GlobalFieldInMembers() { ModuleBuilder module = AssemblyBuilder.DefineDynamicAssembly(new AssemblyName("Name"), AssemblyBuilderAccess.RunAndCollect).DefineDynamicModule("Module"); @@ -582,7 +581,6 @@ public static void GlobalFieldInMembers() MemberInfo[] members = { globalField }; AssertExtensions.Throws("members[0]", () => Expression.New(constructor, arguments, members)); } -#endif static class StaticCtor { diff --git a/src/libraries/System.Linq.Expressions/tests/New/NewWithByRefParameterTests.cs b/src/libraries/System.Linq.Expressions/tests/New/NewWithByRefParameterTests.cs index 09fbcfcd7ec9..04804eef82f9 100644 --- a/src/libraries/System.Linq.Expressions/tests/New/NewWithByRefParameterTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/New/NewWithByRefParameterTests.cs @@ -70,13 +70,11 @@ public void CreateByRefAliasingInterpreted() CreateByRefAliasing(useInterpreter: true); } -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public void CreateByRefAliasingCompiled() { CreateByRefAliasing(useInterpreter: false); } -#endif [Theory, ClassData(typeof(CompilationTypes))] public void CreateByRefReferencingReadonly(bool useInterpreter) diff --git a/src/libraries/System.Linq.Expressions/tests/StackSpillerTests.cs b/src/libraries/System.Linq.Expressions/tests/StackSpillerTests.cs index cff5a1da0999..480b85028db8 100644 --- a/src/libraries/System.Linq.Expressions/tests/StackSpillerTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/StackSpillerTests.cs @@ -1676,9 +1676,7 @@ .maxcontinuation 1 }"); } -#if FEATURE_COMPILE - - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_Constant() { ParameterExpression xs = Expression.Parameter(typeof(int[])); @@ -1736,7 +1734,7 @@ [2] int32 ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_Default() { ParameterExpression xs = Expression.Parameter(typeof(int[])); @@ -1794,7 +1792,7 @@ [2] int32 ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_LiteralField_NotNetFramework() { Expression> e = @@ -1842,7 +1840,7 @@ [1] float64 ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_StaticReadOnlyField() { Expression> e = @@ -1891,7 +1889,7 @@ [1] string ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_RuntimeVariables1() { ParameterExpression f = Expression.Parameter(typeof(Action)); @@ -1950,7 +1948,7 @@ [2] int32 ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_RuntimeVariables2() { ParameterExpression f = Expression.Parameter(typeof(Action)); @@ -2028,7 +2026,7 @@ [3] int32 ); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_NoSpillBeyondSpillSite1() { ParameterExpression f = Expression.Parameter(typeof(Func)); @@ -2101,7 +2099,7 @@ [2] int32 }"); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] public static void Spill_Optimizations_NoSpillBeyondSpillSite2() { ParameterExpression f = Expression.Parameter(typeof(Func)); @@ -2187,8 +2185,6 @@ [4] int32 }"); } -#endif - private static void Test(Func factory, Expression arg1) { Test(args => factory(args[0]), new[] { arg1 }, false); diff --git a/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj b/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj index c2efe998ee96..7744fdd0edbc 100644 --- a/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj +++ b/src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj @@ -1,10 +1,5 @@ - true - false - true - $(DefineConstants);FEATURE_COMPILE - $(DefineConstants);FEATURE_INTERPRET $(NetCoreAppCurrent);$(NetCoreAppCurrent)-iOS;$(NetCoreAppCurrent)-tvOS;$(NetCoreAppCurrent)-MacCatalyst @@ -221,7 +216,7 @@ - + diff --git a/src/libraries/System.Linq.Expressions/tests/TestExtensions/InlinePerCompilationTypeAttribute.cs b/src/libraries/System.Linq.Expressions/tests/TestExtensions/InlinePerCompilationTypeAttribute.cs index f68d74290d7a..992565387911 100644 --- a/src/libraries/System.Linq.Expressions/tests/TestExtensions/InlinePerCompilationTypeAttribute.cs +++ b/src/libraries/System.Linq.Expressions/tests/TestExtensions/InlinePerCompilationTypeAttribute.cs @@ -9,13 +9,8 @@ namespace System.Linq.Expressions.Tests { internal class InlinePerCompilationTypeAttribute : DataAttribute { - private static readonly object[] s_boxedBooleans = - { - false, -#if FEATURE_COMPILE && FEATURE_INTERPRET - true -#endif - }; + private static readonly object[] s_boxedBooleans = PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly ? + new object[] { false, true } : new object[] { false }; private readonly object[] _data; diff --git a/src/libraries/System.Linq.Expressions/tests/TestExtensions/PerCompilationTypeAttribute.cs b/src/libraries/System.Linq.Expressions/tests/TestExtensions/PerCompilationTypeAttribute.cs index 8caa6e908241..2f399a7078ab 100644 --- a/src/libraries/System.Linq.Expressions/tests/TestExtensions/PerCompilationTypeAttribute.cs +++ b/src/libraries/System.Linq.Expressions/tests/TestExtensions/PerCompilationTypeAttribute.cs @@ -32,42 +32,30 @@ public override IEnumerable GetData(MethodInfo testMethod) // we'd therefore end up with multiple copies of the last result. foreach (object[] received in delegatedTo.GetData(testMethod)) { -#if FEATURE_COMPILE - object[] withFalse = new object[received.Length + 1]; -#endif + object[] withFalse = null; + if (PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly) + { + withFalse = new object[received.Length + 1]; + withFalse[received.Length] = s_boxedFalse; + } -#if FEATURE_INTERPRET object[] withTrue = new object[received.Length + 1]; -#endif - -#if FEATURE_COMPILE - withFalse[received.Length] = s_boxedFalse; -#endif - -#if FEATURE_INTERPRET withTrue[received.Length] = s_boxedTrue; -#endif for (int i = 0; i != received.Length; ++i) { object arg = received[i]; -#if FEATURE_COMPILE - withFalse[i] = arg; -#endif + if (withFalse != null) + withFalse[i] = arg; -#if FEATURE_INTERPRET withTrue[i] = arg; -#endif } -#if FEATURE_COMPILE - yield return withFalse; -#endif + if (withFalse != null) + yield return withFalse; -#if FEATURE_INTERPRET yield return withTrue; -#endif } } } diff --git a/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedNullableTests.cs b/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedNullableTests.cs index ce051238ea2a..9811cd7b632d 100644 --- a/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedNullableTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedNullableTests.cs @@ -201,8 +201,7 @@ private static void VerifyArithmeticNegateCheckedNullableShort(short? value, boo #endregion -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_NullableShortNegateChecked() { @@ -234,7 +233,5 @@ [0] valuetype [System.Private.CoreLib]System.Nullable`1 IL_001d: ret }"); } -#endif - } } diff --git a/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedTests.cs b/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedTests.cs index dd44ab27bc03..460c2c2cd15f 100644 --- a/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Unary/UnaryArithmeticNegateCheckedTests.cs @@ -208,8 +208,7 @@ private static void VerifyArithmeticNegateCheckedShort(short value, bool useInte #endregion -#if FEATURE_COMPILE - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))] [ActiveIssue("https://github.com/mono/mono/issues/14919", TestRuntimes.Mono)] public static void VerifyIL_ShortNegateChecked() { @@ -229,7 +228,5 @@ .maxstack 2 IL_0004: ret }"); } -#endif - } } diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs index 75b83fbe8bae..c51adc80d5c3 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs @@ -2004,7 +2004,8 @@ static int ScavengeConnectionList(List list, ref List? if (freeIndex < list.Count) { // We know the connection at freeIndex is unusable, so dispose of it. - toDispose ??= new List { list[freeIndex] }; + toDispose ??= new List(); + toDispose.Add(list[freeIndex]); // Find the first item after the one to be removed that should be kept. int current = freeIndex + 1; diff --git a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh index a99b4c4e3172..a43ae9759172 100755 --- a/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh +++ b/src/libraries/System.Net.Http/tests/StressTests/HttpStress/run-docker-compose.sh @@ -62,16 +62,16 @@ done repo_root=$(git rev-parse --show-toplevel) -if [[ buildcurrentlibraries -eq 1 ]]; then +if [[ "$buildcurrentlibraries" -eq 1 ]]; then libraries_args=" -t $imagename -c $configuration" - if ! $repo_root/eng/docker/build-docker-sdk.sh $libraries_args; then + if ! "$repo_root"/eng/docker/build-docker-sdk.sh $libraries_args; then exit 1 fi fi build_args="" -if [[ "$imagename" != "" ]]; then +if [[ -n "$imagename" ]]; then build_args=" --build-arg SDK_BASE_IMAGE=$imagename" fi @@ -81,7 +81,7 @@ if ! docker-compose --file "$compose_file" build $build_args; then exit $? fi -if [[ $buildonly -eq 0 ]]; then +if [[ "$buildonly" -eq 0 ]]; then export DUMPS_SHARE_MOUNT_ROOT="/dumps-share" export CLIENT_DUMPS_SHARE="${CLIENT_DUMPS_SHARE:-$(mktemp -d)}" export SERVER_DUMPS_SHARE="${SERVER_DUMPS_SHARE:-$(mktemp -d)}" diff --git a/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh index dd18b894cdf2..ee1ec60f6c0a 100755 --- a/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh +++ b/src/libraries/System.Net.Security/tests/StressTests/SslStress/run-docker-compose.sh @@ -62,16 +62,16 @@ done repo_root=$(git rev-parse --show-toplevel) -if [[ buildcurrentlibraries -eq 1 ]]; then +if [[ "$buildcurrentlibraries" -eq 1 ]]; then libraries_args=" -t $imagename -c $configuration" - if ! $repo_root/eng/docker/build-docker-sdk.sh $libraries_args; then + if ! "$repo_root"/eng/docker/build-docker-sdk.sh $libraries_args; then exit 1 fi fi build_args="" -if [[ "$imagename" != "" ]]; then +if [[ -z "$imagename" ]]; then build_args=" --build-arg SDK_BASE_IMAGE=$imagename" fi diff --git a/src/libraries/System.Private.Xml/tests/Readers/CharCheckingReader/System.Xml.RW.CharCheckingReader.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/CharCheckingReader/System.Xml.RW.CharCheckingReader.Tests.csproj index 8f07f99a4bfd..500733518dd7 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/CharCheckingReader/System.Xml.RW.CharCheckingReader.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/CharCheckingReader/System.Xml.RW.CharCheckingReader.Tests.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/CustomReader/System.Xml.RW.CustomReader.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/CustomReader/System.Xml.RW.CustomReader.Tests.csproj index 0a9332d12904..c9f5d55f4dba 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/CustomReader/System.Xml.RW.CustomReader.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/CustomReader/System.Xml.RW.CustomReader.Tests.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/FactoryReader/System.Xml.RW.FactoryReader.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/FactoryReader/System.Xml.RW.FactoryReader.Tests.csproj index 8a6101b86831..5544c95e815a 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/FactoryReader/System.Xml.RW.FactoryReader.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/FactoryReader/System.Xml.RW.FactoryReader.Tests.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/NameTable/System.Xml.RW.NameTable.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/NameTable/System.Xml.RW.NameTable.Tests.csproj index b2052d0678d7..22491163aa29 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/NameTable/System.Xml.RW.NameTable.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/NameTable/System.Xml.RW.NameTable.Tests.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/ReaderSettings/System.Xml.RW.ReaderSettings.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/ReaderSettings/System.Xml.RW.ReaderSettings.Tests.csproj index 644a9f6b4d92..606537f058d2 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/ReaderSettings/System.Xml.RW.ReaderSettings.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/ReaderSettings/System.Xml.RW.ReaderSettings.Tests.csproj @@ -21,7 +21,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/SubtreeReader/System.Xml.RW.SubtreeReader.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/SubtreeReader/System.Xml.RW.SubtreeReader.Tests.csproj index 6a642e0ef328..1a332e08e5c1 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/SubtreeReader/System.Xml.RW.SubtreeReader.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/SubtreeReader/System.Xml.RW.SubtreeReader.Tests.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Readers/WrappedReader/System.Xml.RW.WrappedReader.Tests.csproj b/src/libraries/System.Private.Xml/tests/Readers/WrappedReader/System.Xml.RW.WrappedReader.Tests.csproj index ffcaad0d1e75..f93aee359a72 100644 --- a/src/libraries/System.Private.Xml/tests/Readers/WrappedReader/System.Xml.RW.WrappedReader.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Readers/WrappedReader/System.Xml.RW.WrappedReader.Tests.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Writers/RwFactory/System.Xml.RW.RwFactory.Tests.csproj b/src/libraries/System.Private.Xml/tests/Writers/RwFactory/System.Xml.RW.RwFactory.Tests.csproj index 91358a3a30f5..7b797907e05f 100644 --- a/src/libraries/System.Private.Xml/tests/Writers/RwFactory/System.Xml.RW.RwFactory.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Writers/RwFactory/System.Xml.RW.RwFactory.Tests.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/DisableParallelization.cs b/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/DisableParallelization.cs deleted file mode 100644 index e6fb8acae3b2..000000000000 --- a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/DisableParallelization.cs +++ /dev/null @@ -1,5 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// Tests are old and depend on the static state -[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] diff --git a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/System.Xml.RW.XmlWriterApi.Tests.csproj b/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/System.Xml.RW.XmlWriterApi.Tests.csproj index 66a1626bfe18..9569073b4185 100644 --- a/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/System.Xml.RW.XmlWriterApi.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/Writers/XmlWriterApi/System.Xml.RW.XmlWriterApi.Tests.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/libraries/System.Private.Xml/tests/XmlConvert/System.Xml.RW.XmlConvert.Tests.csproj b/src/libraries/System.Private.Xml/tests/XmlConvert/System.Xml.RW.XmlConvert.Tests.csproj index 2104845a322c..69106ffa4dd5 100644 --- a/src/libraries/System.Private.Xml/tests/XmlConvert/System.Xml.RW.XmlConvert.Tests.csproj +++ b/src/libraries/System.Private.Xml/tests/XmlConvert/System.Xml.RW.XmlConvert.Tests.csproj @@ -37,7 +37,7 @@ - + diff --git a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj index 843c88967ad5..85f7a7c0c00b 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj @@ -2,7 +2,7 @@ Microsoft.Interop.DllImportGenerator - netstandard2.0 + netstandard2.0 false true True diff --git a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj index e8f403d2f832..f5148d44941f 100644 --- a/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj +++ b/src/libraries/System.Runtime.InteropServices/gen/Microsoft.Interop.SourceGeneration/Microsoft.Interop.SourceGeneration.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0 false enable Microsoft.Interop diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs index f1b285818e93..de2fb1619e0c 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexFindOptimizations.cs @@ -181,13 +181,13 @@ public RegexFindOptimizations(RegexTree tree, CultureInfo culture) public List<(char[]? Chars, string Set, int Distance, bool CaseInsensitive)>? FixedDistanceSets { get; } /// Try to advance to the next starting position that might be a location for a match. - /// The text to search. - /// The position in . This is updated with the found position. - /// The index in to consider the beginning for beginning anchor purposes. - /// The index in to consider the start for start anchor purposes. - /// The index in to consider the non-inclusive end of the string. + /// The text to search. + /// The position in . This is updated with the found position. + /// The index in to consider the beginning for beginning anchor purposes. + /// The index in to consider the start for start anchor purposes. + /// The index in to consider the non-inclusive end of the string. /// true if a position to attempt a match was found; false if none was found. - public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, int start, int end) + public bool TryFindNextStartingPosition(ReadOnlySpan textSpan, ref int pos, int beginning, int start, int end) { // Return early if we know there's not enough input left to match. if (!_rightToLeft) @@ -217,16 +217,16 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, // the beginning of the string or just after a line feed), find the next // newline and position just after it. Debug.Assert(!_rightToLeft); - if (pos > beginning && text[pos - 1] != '\n') + if (pos > beginning && textSpan[pos - 1] != '\n') { - int newline = text.IndexOf('\n', pos); - if (newline == -1 || newline + 1 > end) + int newline = textSpan.Slice(pos).IndexOf('\n'); + if (newline == -1 || newline + 1 + pos > end) { pos = end; return false; } - pos = newline + 1; + pos = newline + 1 + pos; } } @@ -281,7 +281,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, return true; case FindNextStartingPositionMode.LeadingAnchor_RightToLeft_EndZ: - if (pos < end - 1 || (pos == end - 1 && text[pos] != '\n')) + if (pos < end - 1 || (pos == end - 1 && textSpan[pos] != '\n')) { pos = beginning; return false; @@ -300,7 +300,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, case FindNextStartingPositionMode.LeadingPrefix_LeftToRight_CaseSensitive: { - int i = text.AsSpan(pos, end - pos).IndexOf(LeadingCaseSensitivePrefix.AsSpan()); + int i = textSpan.Slice(pos, end - pos).IndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos += i; @@ -313,7 +313,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, case FindNextStartingPositionMode.LeadingPrefix_RightToLeft_CaseSensitive: { - int i = text.AsSpan(beginning, pos - beginning).LastIndexOf(LeadingCaseSensitivePrefix.AsSpan()); + int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(LeadingCaseSensitivePrefix.AsSpan()); if (i >= 0) { pos = beginning + i + LeadingCaseSensitivePrefix.Length; @@ -328,7 +328,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, case FindNextStartingPositionMode.LeadingLiteral_RightToLeft_CaseSensitive: { - int i = text.AsSpan(beginning, pos - beginning).LastIndexOf(FixedDistanceLiteral.Literal); + int i = textSpan.Slice(beginning, pos - beginning).LastIndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos = beginning + i + 1; @@ -344,7 +344,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; - ReadOnlySpan span = text.AsSpan(beginning, pos - beginning); + ReadOnlySpan span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (ti.ToLower(span[i]) == ch) @@ -364,7 +364,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, { (char[]? chars, string set, _, _) = FixedDistanceSets![0]; - ReadOnlySpan span = text.AsSpan(pos, end - pos); + ReadOnlySpan span = textSpan.Slice(pos, end - pos); if (chars is not null) { int i = span.IndexOfAny(chars); @@ -397,7 +397,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; - ReadOnlySpan span = text.AsSpan(pos, end - pos); + ReadOnlySpan span = textSpan.Slice(pos, end - pos); for (int i = 0; i < span.Length; i++) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) @@ -416,7 +416,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, ref uint[]? startingAsciiLookup = ref _asciiLookups![0]; string set = FixedDistanceSets![0].Set; - ReadOnlySpan span = text.AsSpan(beginning, pos - beginning); + ReadOnlySpan span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(span[i], set, ref startingAsciiLookup)) @@ -436,7 +436,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, string set = FixedDistanceSets![0].Set; TextInfo ti = _textInfo; - ReadOnlySpan span = text.AsSpan(beginning, pos - beginning); + ReadOnlySpan span = textSpan.Slice(beginning, pos - beginning); for (int i = span.Length - 1; i >= 0; i--) { if (RegexCharClass.CharInClass(ti.ToLower(span[i]), set, ref startingAsciiLookup)) @@ -456,7 +456,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, { Debug.Assert(FixedDistanceLiteral.Distance <= _minRequiredLength); - int i = text.AsSpan(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance).IndexOf(FixedDistanceLiteral.Literal); + int i = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance).IndexOf(FixedDistanceLiteral.Literal); if (i >= 0) { pos += i; @@ -474,7 +474,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, char ch = FixedDistanceLiteral.Literal; TextInfo ti = _textInfo; - ReadOnlySpan span = text.AsSpan(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance); + ReadOnlySpan span = textSpan.Slice(pos + FixedDistanceLiteral.Distance, end - pos - FixedDistanceLiteral.Distance); for (int i = 0; i < span.Length; i++) { if (ti.ToLower(span[i]) == ch) @@ -501,12 +501,14 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { int offset = inputPosition + primaryDistance; - int index = text.IndexOfAny(primaryChars, offset, end - offset); + int index = textSpan.Slice(offset, end - offset).IndexOfAny(primaryChars); if (index < 0) { break; } + index += offset; // The index here will be offset indexed due to the use of span, so we add offset to get + // real position on the string. inputPosition = index - primaryDistance; if (inputPosition > endMinusRequiredLength) { @@ -516,7 +518,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; - char c = text[inputPosition + nextDistance]; + char c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; @@ -535,7 +537,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { - char c = text[inputPosition + primaryDistance]; + char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(c, primarySet, ref startingAsciiLookup)) { goto Bumpalong; @@ -544,7 +546,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; - c = text[inputPosition + nextDistance]; + c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; @@ -573,7 +575,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int inputPosition = pos; inputPosition <= endMinusRequiredLength; inputPosition++) { - char c = text[inputPosition + primaryDistance]; + char c = textSpan[inputPosition + primaryDistance]; if (!RegexCharClass.CharInClass(ti.ToLower(c), primarySet, ref startingAsciiLookup)) { goto Bumpalong; @@ -582,7 +584,7 @@ public bool TryFindNextStartingPosition(string text, ref int pos, int beginning, for (int i = 1; i < sets.Count; i++) { (_, string nextSet, int nextDistance, bool nextCaseInsensitive) = sets[i]; - c = text[inputPosition + nextDistance]; + c = textSpan[inputPosition + nextDistance]; if (!RegexCharClass.CharInClass(nextCaseInsensitive ? _textInfo.ToLower(c) : c, nextSet, ref _asciiLookups![i])) { goto Bumpalong; diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs index 4351473b96fd..5c28f58a168a 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexInterpreter.cs @@ -207,14 +207,14 @@ private void StackPush(int i1, int i2) private int Forwardchars() => _rightToLeft ? runtextpos - runtextbeg : runtextend - runtextpos; - private char Forwardcharnext() + private char Forwardcharnext(ReadOnlySpan runtextSpan) { - char ch = _rightToLeft ? runtext![--runtextpos] : runtext![runtextpos++]; - + int i = _rightToLeft ? --runtextpos : runtextpos++; + char ch = runtextSpan[i]; return _caseInsensitive ? _textInfo.ToLower(ch) : ch; } - private bool MatchString(string str) + private bool MatchString(string str, ReadOnlySpan runtextSpan) { int c = str.Length; int pos; @@ -242,7 +242,7 @@ private bool MatchString(string str) { while (c != 0) { - if (str[--c] != runtext![--pos]) + if (str[--c] != runtextSpan[--pos]) { return false; } @@ -253,7 +253,7 @@ private bool MatchString(string str) TextInfo ti = _textInfo; while (c != 0) { - if (str[--c] != ti.ToLower(runtext![--pos])) + if (str[--c] != ti.ToLower(runtextSpan[--pos])) { return false; } @@ -270,7 +270,7 @@ private bool MatchString(string str) return true; } - private bool MatchRef(int index, int length) + private bool MatchRef(int index, int length, ReadOnlySpan runtextSpan) { int pos; if (!_rightToLeft) @@ -299,7 +299,7 @@ private bool MatchRef(int index, int length) { while (c-- != 0) { - if (runtext![--cmpos] != runtext[--pos]) + if (runtextSpan[--cmpos] != runtextSpan[--pos]) { return false; } @@ -310,7 +310,7 @@ private bool MatchRef(int index, int length) TextInfo ti = _textInfo; while (c-- != 0) { - if (ti.ToLower(runtext![--cmpos]) != ti.ToLower(runtext[--pos])) + if (ti.ToLower(runtextSpan[--cmpos]) != ti.ToLower(runtextSpan[--pos])) { return false; } @@ -337,6 +337,7 @@ protected override void Go() SetOperator(_code.Codes[0]); _codepos = 0; int advance = -1; + ReadOnlySpan runtextSpan = runtext; while (true) { @@ -699,7 +700,7 @@ protected override void Go() break; case RegexCode.Bol: - if (Leftchars() > 0 && runtext![runtextpos - 1] != '\n') + if (Leftchars() > 0 && runtextSpan[runtextpos - 1] != '\n') { break; } @@ -707,7 +708,7 @@ protected override void Go() continue; case RegexCode.Eol: - if (Rightchars() > 0 && runtext![runtextpos] != '\n') + if (Rightchars() > 0 && runtextSpan[runtextpos] != '\n') { break; } @@ -763,7 +764,7 @@ protected override void Go() continue; case RegexCode.EndZ: - if (Rightchars() > 1 || Rightchars() == 1 && runtext![runtextpos] != '\n') + if (Rightchars() > 1 || Rightchars() == 1 && runtextSpan[runtextpos] != '\n') { break; } @@ -779,7 +780,7 @@ protected override void Go() continue; case RegexCode.One: - if (Forwardchars() < 1 || Forwardcharnext() != (char)Operand(0)) + if (Forwardchars() < 1 || Forwardcharnext(runtextSpan) != (char)Operand(0)) { break; } @@ -787,7 +788,7 @@ protected override void Go() continue; case RegexCode.Notone: - if (Forwardchars() < 1 || Forwardcharnext() == (char)Operand(0)) + if (Forwardchars() < 1 || Forwardcharnext(runtextSpan) == (char)Operand(0)) { break; } @@ -802,7 +803,7 @@ protected override void Go() else { int operand = Operand(0); - if (!RegexCharClass.CharInClass(Forwardcharnext(), _code.Strings[operand], ref _code.StringsAsciiLookup[operand])) + if (!RegexCharClass.CharInClass(Forwardcharnext(runtextSpan), _code.Strings[operand], ref _code.StringsAsciiLookup[operand])) { break; } @@ -811,7 +812,7 @@ protected override void Go() continue; case RegexCode.Multi: - if (!MatchString(_code.Strings[Operand(0)])) + if (!MatchString(_code.Strings[Operand(0)], runtextSpan)) { break; } @@ -823,7 +824,7 @@ protected override void Go() int capnum = Operand(0); if (IsMatched(capnum)) { - if (!MatchRef(MatchIndex(capnum), MatchLength(capnum))) + if (!MatchRef(MatchIndex(capnum), MatchLength(capnum), runtextSpan)) { break; } @@ -850,7 +851,7 @@ protected override void Go() char ch = (char)Operand(0); while (c-- > 0) { - if (Forwardcharnext() != ch) + if (Forwardcharnext(runtextSpan) != ch) { goto BreakBackward; } @@ -870,7 +871,7 @@ protected override void Go() char ch = (char)Operand(0); while (c-- > 0) { - if (Forwardcharnext() == ch) + if (Forwardcharnext(runtextSpan) == ch) { goto BreakBackward; } @@ -899,7 +900,7 @@ protected override void Go() CheckTimeout(); } - if (!RegexCharClass.CharInClass(Forwardcharnext(), set, ref setLookup)) + if (!RegexCharClass.CharInClass(Forwardcharnext(runtextSpan), set, ref setLookup)) { goto BreakBackward; } @@ -917,7 +918,7 @@ protected override void Go() for (i = len; i > 0; i--) { - if (Forwardcharnext() != ch) + if (Forwardcharnext(runtextSpan) != ch) { Backwardnext(); break; @@ -943,7 +944,7 @@ protected override void Go() { // We're left-to-right and case-sensitive, so we can employ the vectorized IndexOf // to search for the character. - i = runtext!.AsSpan(runtextpos, len).IndexOf(ch); + i = runtextSpan.Slice(runtextpos, len).IndexOf(ch); if (i == -1) { runtextpos += len; @@ -959,7 +960,7 @@ protected override void Go() { for (i = len; i > 0; i--) { - if (Forwardcharnext() == ch) + if (Forwardcharnext(runtextSpan) == ch) { Backwardnext(); break; @@ -992,7 +993,7 @@ protected override void Go() CheckTimeout(); } - if (!RegexCharClass.CharInClass(Forwardcharnext(), set, ref setLookup)) + if (!RegexCharClass.CharInClass(Forwardcharnext(runtextSpan), set, ref setLookup)) { Backwardnext(); break; @@ -1042,7 +1043,7 @@ protected override void Go() int pos = TrackPeek(1); runtextpos = pos; - if (Forwardcharnext() != (char)Operand(0)) + if (Forwardcharnext(runtextSpan) != (char)Operand(0)) { break; } @@ -1062,7 +1063,7 @@ protected override void Go() int pos = TrackPeek(1); runtextpos = pos; - if (Forwardcharnext() == (char)Operand(0)) + if (Forwardcharnext(runtextSpan) == (char)Operand(0)) { break; } @@ -1083,7 +1084,7 @@ protected override void Go() runtextpos = pos; int operand0 = Operand(0); - if (!RegexCharClass.CharInClass(Forwardcharnext(), _code.Strings[operand0], ref _code.StringsAsciiLookup[operand0])) + if (!RegexCharClass.CharInClass(Forwardcharnext(runtextSpan), _code.Strings[operand0], ref _code.StringsAsciiLookup[operand0])) { break; } diff --git a/src/mono/mono/component/mini-wasm-debugger.c b/src/mono/mono/component/mini-wasm-debugger.c index 5413e1acc707..0cfcd5cce958 100644 --- a/src/mono/mono/component/mini-wasm-debugger.c +++ b/src/mono/mono/component/mini-wasm-debugger.c @@ -362,6 +362,12 @@ extern void mono_wasm_add_dbg_command_received(mono_bool res_ok, int id, void* b EMSCRIPTEN_KEEPALIVE gboolean mono_wasm_send_dbg_command_with_parms (int id, MdbgProtCommandSet command_set, int command, guint8* data, unsigned int size, int valtype, char* newvalue) { + if (!debugger_enabled) { + EM_ASM ({ + MONO.mono_wasm_add_dbg_command_received ($0, $1, $2, $3); + }, 0, id, 0, 0); + return TRUE; + } MdbgProtBuffer bufWithParms; buffer_init (&bufWithParms, 128); m_dbgprot_buffer_add_data (&bufWithParms, data, size); @@ -377,6 +383,12 @@ mono_wasm_send_dbg_command_with_parms (int id, MdbgProtCommandSet command_set, i EMSCRIPTEN_KEEPALIVE gboolean mono_wasm_send_dbg_command (int id, MdbgProtCommandSet command_set, int command, guint8* data, unsigned int size) { + if (!debugger_enabled) { + EM_ASM ({ + MONO.mono_wasm_add_dbg_command_received ($0, $1, $2, $3); + }, 0, id, 0, 0); + return TRUE; + } ss_calculate_framecount (NULL, NULL, TRUE, NULL, NULL); MdbgProtBuffer buf; buffer_init (&buf, 128); diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 84573c71d9c3..0d19ee09a9bb 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -3435,11 +3435,16 @@ emit_gc_safepoint_poll (MonoLLVMModule *module, LLVMModuleRef lmodule, MonoCompi mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND); if (is_aot) { #if TARGET_WIN32 - if (module->static_link) + if (module->static_link) { LLVMSetLinkage (func, LLVMInternalLinkage); - else -#endif + /* Prevent it from being optimized away, leading to asserts inside 'opt' */ + mark_as_used (module, func); + } else { LLVMSetLinkage (func, LLVMWeakODRLinkage); + } +#else + LLVMSetLinkage (func, LLVMWeakODRLinkage); +#endif } else { mono_llvm_add_func_attr (func, LLVM_ATTR_OPTIMIZE_NONE); // no need to waste time here, the function is already optimized and will be inlined. mono_llvm_add_func_attr (func, LLVM_ATTR_NO_INLINE); // optnone attribute requires noinline (but it will be inlined anyway) diff --git a/src/mono/mono/tests/verifier/make_access_test.sh b/src/mono/mono/tests/verifier/make_access_test.sh index 72be8020ee54..d75fa965ce98 100755 --- a/src/mono/mono/tests/verifier/make_access_test.sh +++ b/src/mono/mono/tests/verifier/make_access_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -38,7 +38,7 @@ $SED -e "s/SUPER_TYPE/${TEST_SUPER_TYPE}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" - .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -55,7 +55,7 @@ $SED -e "s/SUPER_TYPE/${TEST_SUPER_TYPE}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -71,7 +71,7 @@ $SED -e "s/SUPER_TYPE/${TEST_SUPER_TYPE}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void SUPER_TYPE::.ctor() ret } diff --git a/src/mono/mono/tests/verifier/make_bad_op_test.sh b/src/mono/mono/tests/verifier/make_bad_op_test.sh index 4356497ea376..59a4ce6bfb37 100755 --- a/src/mono/mono/tests/verifier/make_bad_op_test.sh +++ b/src/mono/mono/tests/verifier/make_bad_op_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -11,7 +11,7 @@ TEST_BYTE_0=$3 TEST_BYTE_1=$4 -if [ "x$TEST_BYTE_1" = "x" ] ; then +if [ "x$TEST_BYTE_1" = "x" ]; then TEST_BYTE_1="0"; fi @@ -19,7 +19,7 @@ TEST_FILE=`echo ${TEST_VALIDITY}_${TEST_NAME} | $SED -e 's/ /_/g' -e 's/\./_/g' echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/BYTE_0/${TEST_BYTE_0}/g" -e "s/BYTE_1/${TEST_BYTE_1}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi TEST_NAME=$1 @@ -26,7 +26,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'` $SED -e "s/INIT/${TEST_INIT}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/TYPE2/${TEST_TYPE2}/g" -e "s/OPCODE/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ echo $TEST_FILE TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/EXTRAS/${TEST_EXTRAS}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -37,7 +37,7 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T .class interface public auto ansi abstract IFace { - .method public virtual hidebysig newslot abstract instance default void Tst () cil managed + .method public virtual hidebysig newslot abstract instance default void Tst () cil managed { } } @@ -46,48 +46,48 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T { .field public int32 fld - .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed + .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::'.ctor'() - ret + ret } } .class public auto ansi beforefieldinit IFaceImpl extends BaseClass implements IFace { - .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed + .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void BaseClass::'.ctor'() - ret + ret } - .method public final virtual hidebysig newslot instance default void Tst () cil managed + .method public final virtual hidebysig newslot instance default void Tst () cil managed { .maxstack 8 - ret + ret } } .class public auto ansi sealed TstDelegate extends [mscorlib]System.MulticastDelegate { - .method public hidebysig specialname rtspecialname instance default void '.ctor' (object 'object', native int 'method') runtime managed + .method public hidebysig specialname rtspecialname instance default void '.ctor' (object 'object', native int 'method') runtime managed { } - .method public virtual hidebysig newslot instance default void Invoke () runtime managed + .method public virtual hidebysig newslot instance default void Invoke () runtime managed { } - .method public virtual hidebysig newslot instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed + .method public virtual hidebysig newslot instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } - .method public virtual hidebysig newslot - instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed + .method public virtual hidebysig newslot + instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed { } } @@ -97,16 +97,16 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T .field !T t .field ${TEST_CONSTRAINT_TYPE} ifField - .method public hidebysig specialname rtspecialname instance default void .ctor (!T A_0) cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor (!T A_0) cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ldarg.0 ldarg.1 stfld !0 class DriverClass::t - ret + ret } .method public void Driver () @@ -134,7 +134,7 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T TARGET: leave END END: - ret + ret } } @@ -152,7 +152,7 @@ END: call instance void class DriverClass::Driver() ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_branch_test.sh b/src/mono/mono/tests/verifier/make_branch_test.sh index 9ea87a414cfe..459a32589bba 100755 --- a/src/mono/mono/tests/verifier/make_branch_test.sh +++ b/src/mono/mono/tests/verifier/make_branch_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -23,7 +23,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/FINALLY/${TEST_FIN}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -29,7 +29,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/LOAD_ARGS/${TEST_LOAD_ARGS}/g" -e "s/MEMBER_OP/${MEMBER_TEST_OP}/g" -e "s/MEMBER_LD_ARGS/${MEMBER_TEST_LOAD_ARGS}/g" -e "s/EXTRA_STUFF/${TEST_EXTRA_STUFF}/g" -e "s/EXTRA/${MEMBER_TEST_EXTRA_STUFF}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -18,7 +18,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" -e "s/LOAD/${TEST_LOAD}/g" -e "s/OP/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -49,12 +49,12 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T { .field public int32 valid - .method public hidebysig specialname rtspecialname instance default void .ctor (int32&) cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor (int32&) cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtTest (ClassA& arg) @@ -120,7 +120,7 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T leave END END: ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_constrained_test.sh b/src/mono/mono/tests/verifier/make_constrained_test.sh index 12154b1f12df..d45d2e9c0211 100755 --- a/src/mono/mono/tests/verifier/make_constrained_test.sh +++ b/src/mono/mono/tests/verifier/make_constrained_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -19,7 +19,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CONSTRAINED_TYPE/${TEST_CONSTRAINED_TYPE}/g" -e "s/ARG_TYPE/${TEST_ARG_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/LOAD_OP/${TEST_LOAD_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -107,7 +107,7 @@ $SED -e "s/EXTRA_OPS/${TEST_EXTRA_OPS}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VAL ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_cross_nested_access_test.sh b/src/mono/mono/tests/verifier/make_cross_nested_access_test.sh index b94b7e960bf3..f57e0ce01603 100755 --- a/src/mono/mono/tests/verifier/make_cross_nested_access_test.sh +++ b/src/mono/mono/tests/verifier/make_cross_nested_access_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -39,7 +39,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -60,7 +60,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -73,7 +73,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -82,8 +82,8 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU { .maxstack 8 ldc.i4.0 - ret - } + ret + } } .class nested public Test EXTENDS @@ -91,7 +91,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 CONSTRUCTOR ret } @@ -103,7 +103,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU OPCODE // VALIDITY. pop ret - } + } } } diff --git a/src/mono/mono/tests/verifier/make_ctor_test.sh b/src/mono/mono/tests/verifier/make_ctor_test.sh index 6325f6167971..9078b809c093 100755 --- a/src/mono/mono/tests/verifier/make_ctor_test.sh +++ b/src/mono/mono/tests/verifier/make_ctor_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -36,35 +36,35 @@ $SED -e "s/CODE/${TEST_CODE}/g" -e "s/OTHER/${TEST_OTHER_CODE}/g" -e "s/VALIDITY .module delegate_test.exe .class ansi beforefieldinit TestClass extends [mscorlib]System.Object { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void object::'.ctor'() - ret + ret } - .method public hidebysig specialname rtspecialname instance default void .ctor (object V_1) cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor (object V_1) cil managed { .maxstack 8 ldarg.0 call instance void object::'.ctor'() - ret + ret } } .module delegate_test.exe .class ansi beforefieldinit TestSubClass extends TestClass { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 OTHER - + leave END END: - ret + ret } } @@ -76,29 +76,29 @@ END: .field int32 val .field object obj - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 .locals init (Test V_0) ldarg.0 CODE - + leave END END: - ret + ret } - .method public hidebysig static default void StaticMethod (object A_0) cil managed + .method public hidebysig static default void StaticMethod (object A_0) cil managed { .maxstack 8 - ret + ret } - .method public hidebysig instance default void InstanceMethod () cil managed + .method public hidebysig instance default void InstanceMethod () cil managed { .maxstack 8 - ret + ret } } @@ -107,13 +107,13 @@ END: .class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void object::'.ctor'() - ret + ret } .method public static int32 Main () @@ -124,7 +124,7 @@ END: newobj instance void ${TARGET_TYPE}::.ctor() pop ldc.i4.0 - ret + ret } } diff --git a/src/mono/mono/tests/verifier/make_delegate_compat_test.sh b/src/mono/mono/tests/verifier/make_delegate_compat_test.sh index 31b8581fbe7f..31a38082276e 100755 --- a/src/mono/mono/tests/verifier/make_delegate_compat_test.sh +++ b/src/mono/mono/tests/verifier/make_delegate_compat_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -18,7 +18,7 @@ TEST_USE_NATIVE=$9 TCONV_1="default" TCONV_2="" -if [ "$TEST_CCONV1" != "" ]; then +if [ -z "$TEST_CCONV1" ]; then TCONV_1=$TEST_CCONV1 TCONV_2=$TEST_CCONV2 fi @@ -63,7 +63,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/RET_1/${TEST_RET_TYPE1}/g" -e "s/RET_2/${TEST_RET_TYPE2}/g" -e "s/PARAM_1/${TEST_PARAM_TYPE1}/g" -e "s/PARAM_2/${TEST_PARAM_TYPE2}/g"> $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -38,99 +38,99 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/DELEGAT { .field private int32 dd - .method public virtual hidebysig instance default string ToString () cil managed + .method public virtual hidebysig instance default string ToString () cil managed { .maxstack 8 ldstr "test" - ret + ret } - .method public hidebysig instance default void NonVirtMethod () cil managed + .method public hidebysig instance default void NonVirtMethod () cil managed { .maxstack 8 - ret + ret } } .class public auto ansi sealed ToStringDelegate extends [mscorlib]System.MulticastDelegate { - .method public hidebysig specialname rtspecialname - instance default void .ctor (object 'object', native int 'method') runtime managed + .method public hidebysig specialname rtspecialname + instance default void .ctor (object 'object', native int 'method') runtime managed { } .method public virtual hidebysig newslot - instance default string Invoke () runtime managed + instance default string Invoke () runtime managed { } - .method public virtual hidebysig newslot - instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed + .method public virtual hidebysig newslot + instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } - .method public virtual hidebysig newslot - instance default string EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed + .method public virtual hidebysig newslot + instance default string EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed { } } .class public auto ansi sealed DelegateNoArg extends [mscorlib]System.MulticastDelegate { - .method public hidebysig specialname rtspecialname - instance default void .ctor (object 'object', native int 'method') runtime managed + .method public hidebysig specialname rtspecialname + instance default void .ctor (object 'object', native int 'method') runtime managed { } .method public virtual hidebysig newslot - instance default void Invoke () runtime managed + instance default void Invoke () runtime managed { } - .method public virtual hidebysig newslot - instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed + .method public virtual hidebysig newslot + instance default class [mscorlib]System.IAsyncResult BeginInvoke (class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } - .method public virtual hidebysig newslot - instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed + .method public virtual hidebysig newslot + instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed { } -} +} .class public auto ansi sealed DelegateIntArg extends [mscorlib]System.MulticastDelegate { - .method public hidebysig specialname rtspecialname - instance default void .ctor (object 'object', native int 'method') runtime managed + .method public hidebysig specialname rtspecialname + instance default void .ctor (object 'object', native int 'method') runtime managed { } .method public virtual hidebysig newslot - instance default void Invoke (int32 d) runtime managed + instance default void Invoke (int32 d) runtime managed { } - .method public virtual hidebysig newslot - instance default class [mscorlib]System.IAsyncResult BeginInvoke (int32 d, class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed + .method public virtual hidebysig newslot + instance default class [mscorlib]System.IAsyncResult BeginInvoke (int32 d, class [mscorlib]System.AsyncCallback callback, object 'object') runtime managed { } - .method public virtual hidebysig newslot - instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed + .method public virtual hidebysig newslot + instance default void EndInvoke (class [mscorlib]System.IAsyncResult result) runtime managed { } -} +} .class public Parent extends [mscorlib]System.Object { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtMethod () @@ -163,12 +163,12 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/DELEGAT .class public auto ansi beforefieldinit Driver extends Parent { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void Parent::.ctor() - ret + ret } .method public static void Method () @@ -210,7 +210,7 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/DELEGAT { .maxstack 8 .locals init (MyValueType V_0) - + OPCODE LDFTN_OP DELEGATE_OP: @@ -234,11 +234,11 @@ DELEGATE_OP: { pop leave END - + } END: ldc.i4.0 - ret + ret } } diff --git a/src/mono/mono/tests/verifier/make_double_nesting_test.sh b/src/mono/mono/tests/verifier/make_double_nesting_test.sh index f6271e2fb959..2fc11c759cb8 100755 --- a/src/mono/mono/tests/verifier/make_double_nesting_test.sh +++ b/src/mono/mono/tests/verifier/make_double_nesting_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -50,7 +50,7 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -71,7 +71,7 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -84,7 +84,7 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -93,8 +93,8 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE { .maxstack 8 ldc.i4.0 - ret - } + ret + } } } @@ -112,7 +112,7 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 ROOT_CONSTRUCTOR ret } @@ -123,13 +123,13 @@ $SED -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/NESTED_ACCESS/${TEST_NESTE { .maxstack 8 ldc.i4.0 - ret + ret } .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 NESTED_CONSTRUCTOR ret } diff --git a/src/mono/mono/tests/verifier/make_endfilter_test.sh b/src/mono/mono/tests/verifier/make_endfilter_test.sh index 5f6c53871d23..24c38e9a9760 100755 --- a/src/mono/mono/tests/verifier/make_endfilter_test.sh +++ b/src/mono/mono/tests/verifier/make_endfilter_test.sh @@ -1,6 +1,6 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -42,11 +42,11 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/FILTER_EXTRAS/${TEST_FILTER_EXTRAS .try { nop - nop + nop ${LEAVE_2} } - catch [mscorlib]System.Exception + catch [mscorlib]System.Exception { pop ${LEAVE_3} @@ -73,14 +73,14 @@ TRY_2: leave END - } catch [mscorlib]System.Exception + } catch [mscorlib]System.Exception { pop leave END } NEXT_4: - .try + .try { nop nop diff --git a/src/mono/mono/tests/verifier/make_endfinally_test.sh b/src/mono/mono/tests/verifier/make_endfinally_test.sh index 1038536faec8..2234131faa1a 100755 --- a/src/mono/mono/tests/verifier/make_endfinally_test.sh +++ b/src/mono/mono/tests/verifier/make_endfinally_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -39,7 +39,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" -e "s/BLOC ${OPCODE_2} leave TRY_2 } - catch [mscorlib]System.NullReferenceException + catch [mscorlib]System.NullReferenceException { pop ${OPCODE_3} @@ -70,7 +70,7 @@ TRY_3: nop leave TRY_4 } - catch [mscorlib]System.NullReferenceException + catch [mscorlib]System.NullReferenceException { pop ${OPCODE_5} @@ -86,7 +86,7 @@ TRY_3: TRY_4: - .try + .try { nop leave END diff --git a/src/mono/mono/tests/verifier/make_exception_branch_test.sh b/src/mono/mono/tests/verifier/make_exception_branch_test.sh index c46d8820ccdf..88111a2033be 100755 --- a/src/mono/mono/tests/verifier/make_exception_branch_test.sh +++ b/src/mono/mono/tests/verifier/make_exception_branch_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -18,7 +18,7 @@ TEST_OP5=$7 TEST_FILE=${TEST_VALIDITY}_exception_branch_${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/OPCODE1/${TEST_OP1}/g" -e "s/OPCODE2/${TEST_OP2}/g" -e "s/OPCODE3/${TEST_OP3}/g" -e "s/OPCODE4/${TEST_OP4}/g" -e "s/OPCODE5/${TEST_OP5}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -25,7 +25,7 @@ AFTER_PREFIX_3: pop FILTER_BLOCK_3_A: - stloc.0 + stloc.0 nop nop ldc.i4.0 @@ -48,7 +48,7 @@ AFTER_PREFIX_6: pop FINALLY_BLOCK_1_A: - stloc.0 + stloc.0 nop nop ldc.i4.0 @@ -76,7 +76,7 @@ $SED -e "s/EXCEPTION_BLOCK_1/${TEST_BLOCK_1}/g" -e "s/EXCEPTION_BLOCK_2/${TEST_B .entrypoint .maxstack 8 .locals init (object _X0, int32 V0) - + ldloca 1 volatile. AFTER_PREFIX_1: @@ -84,7 +84,7 @@ AFTER_PREFIX_1: ldind.i4 pop - + TRY_BLOCK_1: nop TRY_BLOCK_1_A: @@ -111,7 +111,7 @@ ${FINALLY_BLOCK} CATCH_BLOCK_1: nop CATCH_BLOCK_1_A: - stloc.0 + stloc.0 nop ldloca 1 @@ -147,7 +147,7 @@ TRY_BLOCK_2_END: CATCH_BLOCK_2: nop CATCH_BLOCK_2_A: - stloc.0 + stloc.0 nop nop leave END diff --git a/src/mono/mono/tests/verifier/make_field_store_test.sh b/src/mono/mono/tests/verifier/make_field_store_test.sh index 8d72117ffc29..b605bbd0edcf 100755 --- a/src/mono/mono/tests/verifier/make_field_store_test.sh +++ b/src/mono/mono/tests/verifier/make_field_store_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -30,7 +30,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -60,7 +60,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -76,7 +76,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -90,7 +90,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void ClassA::.ctor() ret } @@ -109,7 +109,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -122,7 +122,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CSTOR/${TEST_CSTOR}/g" -e "s/OPC .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void Overlapped::.ctor() ret } diff --git a/src/mono/mono/tests/verifier/make_field_valuetype_test.sh b/src/mono/mono/tests/verifier/make_field_valuetype_test.sh index ccc55e1e644e..c62ba7b4dca6 100755 --- a/src/mono/mono/tests/verifier/make_field_valuetype_test.sh +++ b/src/mono/mono/tests/verifier/make_field_valuetype_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -21,7 +21,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOAD/${TEST_LOAD}/g" -e "s/OPCOD .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib diff --git a/src/mono/mono/tests/verifier/make_generic_argument_constraints_test.sh b/src/mono/mono/tests/verifier/make_generic_argument_constraints_test.sh index 0f0769ef5d51..c75795fb6cbc 100755 --- a/src/mono/mono/tests/verifier/make_generic_argument_constraints_test.sh +++ b/src/mono/mono/tests/verifier/make_generic_argument_constraints_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -12,18 +12,16 @@ TEST_DEST=$4 TEST_INST_TYPE=$5 INST_TYPE="DefaultArgument"; -if [ "$TEST_INST_TYPE" != "" ]; then +if [ -n "$TEST_INST_TYPE" ]; then INST_TYPE="$TEST_INST_TYPE"; fi - - TEST_NAME=${TEST_VALIDITY}_${TEST_NAME} TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/INIT/${TEST_INIT}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TARGET_CONSTRAINT/${TEST_DEST}/g" -e "s/SOURCE_CONSTRAINT/${TEST_SRC}/g" > $TEST_FILE < () @@ -110,7 +108,7 @@ $SED -e "s/INIT/${TEST_INIT}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TARGET_ call void class Test2< $INST_TYPE >::Method() ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_il_overflow_test.sh b/src/mono/mono/tests/verifier/make_il_overflow_test.sh index 8bc47a91bee1..55f52e4bd8fd 100755 --- a/src/mono/mono/tests/verifier/make_il_overflow_test.sh +++ b/src/mono/mono/tests/verifier/make_il_overflow_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -14,23 +14,23 @@ TEST_BYTE_3=$6 TEST_BYTE_4=$7 -if [ "$TEST_BYTE_1" != "" ] ; then +if [ -n "$TEST_BYTE_1" ]; then EMIT_BYTE_1=".emitbyte $TEST_BYTE_1"; fi -if [ "$TEST_BYTE_2" != "" ] ; then +if [ -n "$TEST_BYTE_2" ]; then EMIT_BYTE_2=".emitbyte $TEST_BYTE_2"; fi -if [ "$TEST_BYTE_3" != "" ] ; then +if [ -n "$TEST_BYTE_3" ]; then EMIT_BYTE_3=".emitbyte $TEST_BYTE_3"; fi -if [ "$TEST_BYTE_4" != "" ] ; then +if [ -n "$TEST_BYTE_4" ]; then EMIT_BYTE_4=".emitbyte $TEST_BYTE_4"; fi -if [ "$TEST_BYTE_5" != "" ] ; then +if [ -n "$TEST_BYTE_5" ]; then EMIT_BYTE_5=".emitbyte $TEST_BYTE_5"; fi @@ -38,7 +38,7 @@ TEST_FILE=`echo ${TEST_VALIDITY}_${TEST_NAME} | $SED -e 's/ /_/g' -e 's/\./_/g' echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/BYTE_0/${TEST_BYTE_0}/g" -e "s/BYTE_1/${TEST_BYTE_1}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -86,7 +86,7 @@ $SED -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE2 initobj TYPE2 // VALIDITY ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_invalid_ret_type.sh b/src/mono/mono/tests/verifier/make_invalid_ret_type.sh index 3b68b51ae89a..0dbcd9f0927f 100755 --- a/src/mono/mono/tests/verifier/make_invalid_ret_type.sh +++ b/src/mono/mono/tests/verifier/make_invalid_ret_type.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -16,7 +16,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE/${TEST_TYPE}/g" > $TEST_FILE < $TEST_FILE .class public auto ansi beforefieldinit Driver extends [mscorlib]System.Object { - .method public static hidebysig default TYPE Foo () cil managed + .method public static hidebysig default TYPE Foo () cil managed { .maxstack 8 .locals init (TYPE V_0) - ldloc.0 - ret + ldloc.0 + ret } - .method public static hidebysig default int32 Main () cil managed + .method public static hidebysig default int32 Main () cil managed { .entrypoint .maxstack 2 @@ -43,7 +43,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE/${TEST_TYPE}/g" > $TEST_FILE call TYPE class Driver::Foo() pop ldc.i4.0 - ret + ret } } diff --git a/src/mono/mono/tests/verifier/make_ldelem_test.sh b/src/mono/mono/tests/verifier/make_ldelem_test.sh index 8f1f48f8b72b..a86e92e492c8 100755 --- a/src/mono/mono/tests/verifier/make_ldelem_test.sh +++ b/src/mono/mono/tests/verifier/make_ldelem_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/ARR/${TEST_ARR}/g" -e "s/IDX/${TEST_IDX}/g" -e "s/LD/${TEST_LD}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/ARR/${TEST_ARR}/g" -e "s/IDX/${TEST_IDX}/g" -e "s/TOKEN/${TEST_TOKEN}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -30,12 +30,12 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LDFTN_O .class public Test extends [mscorlib]System.Object { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtMethod () @@ -77,7 +77,7 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LDFTN_O LDFTN_OP pop ldc.i4.0 - ret + ret } } //EOF diff --git a/src/mono/mono/tests/verifier/make_ldlen_test.sh b/src/mono/mono/tests/verifier/make_ldlen_test.sh index d0a967d236a8..8357303db71b 100755 --- a/src/mono/mono/tests/verifier/make_ldlen_test.sh +++ b/src/mono/mono/tests/verifier/make_ldlen_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -14,7 +14,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE/${TEST_TYPE}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -84,7 +84,7 @@ $SED -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE2 ldobj TYPE2 // VALIDITY pop ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_ldtoken_test.sh b/src/mono/mono/tests/verifier/make_ldtoken_test.sh index 3c570f4880ba..1b9267a109b6 100755 --- a/src/mono/mono/tests/verifier/make_ldtoken_test.sh +++ b/src/mono/mono/tests/verifier/make_ldtoken_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -45,13 +45,13 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CALL_OP CALL_OP pop ldc.i4.0 - ret + ret } } - + //EOF diff --git a/src/mono/mono/tests/verifier/make_ldvirtftn_test.sh b/src/mono/mono/tests/verifier/make_ldvirtftn_test.sh index 5eefd91ef20f..735d1268e591 100755 --- a/src/mono/mono/tests/verifier/make_ldvirtftn_test.sh +++ b/src/mono/mono/tests/verifier/make_ldvirtftn_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -30,12 +30,12 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LDFTN_O .class public Test extends [mscorlib]System.Object { - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtMethod () @@ -89,7 +89,7 @@ $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LDFTN_O pop ldc.i4.0 - ret + ret } } //EOF diff --git a/src/mono/mono/tests/verifier/make_leave_test.sh b/src/mono/mono/tests/verifier/make_leave_test.sh index 33a4efaa0425..9fb62b37a6f4 100755 --- a/src/mono/mono/tests/verifier/make_leave_test.sh +++ b/src/mono/mono/tests/verifier/make_leave_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -42,7 +42,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE_EXTRA_1/${OPCODE_EXTRA_1}/g throw leave END } - catch [mscorlib]System.Exception + catch [mscorlib]System.Exception { pop leave END @@ -51,7 +51,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE_EXTRA_1/${OPCODE_EXTRA_1}/g .try { newobj instance void class [mscorlib]System.Exception::.ctor() - throw + throw leave END } finally @@ -63,10 +63,10 @@ END_2: endfinally } - .try + .try { newobj instance void class [mscorlib]System.Exception::.ctor() - throw + throw leave END } filter diff --git a/src/mono/mono/tests/verifier/make_load_indirect_test.sh b/src/mono/mono/tests/verifier/make_load_indirect_test.sh index b6637ca7b991..3c4c44a3e056 100755 --- a/src/mono/mono/tests/verifier/make_load_indirect_test.sh +++ b/src/mono/mono/tests/verifier/make_load_indirect_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -55,7 +55,7 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OP/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -20,7 +20,7 @@ TEST_PARAMS=`echo $TEST_PARAMS | $SED -s 's/&/\\\&/'` TEST_LOCALS=`echo $TEST_LOCALS | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/PARAMS/${TEST_PARAMS}/g" -e "s/LOCALS/${TEST_LOCALS}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/ARGS/${TEST_ARGS}/g" -e "s/SIG/${TEST_SIG}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -68,7 +68,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/INIT/${TEST_INIT}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/INSTANTIATION/${TEST_INSTANTIATION}/g" -e "s/CONSTRAINTS/${TEST_CONSTRAINTS}/g" -e "s/EXTRA_CODE/${TEST_EXTRA_CODE}/g" > $TEST_FILE < () cil managed diff --git a/src/mono/mono/tests/verifier/make_mkrefany.sh b/src/mono/mono/tests/verifier/make_mkrefany.sh index 3e3f6a88377d..1e3e7c612587 100755 --- a/src/mono/mono/tests/verifier/make_mkrefany.sh +++ b/src/mono/mono/tests/verifier/make_mkrefany.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -80,7 +80,7 @@ $SED -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/TYPE2/${TEST_TYPE2}/g" -e "s/VALIDITY/${ pop ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_nested_access_test.sh b/src/mono/mono/tests/verifier/make_nested_access_test.sh index 5fd41668a68d..b721cfb69a67 100755 --- a/src/mono/mono/tests/verifier/make_nested_access_test.sh +++ b/src/mono/mono/tests/verifier/make_nested_access_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -31,7 +31,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -52,7 +52,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -65,7 +65,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -74,8 +74,8 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU { .maxstack 8 ldc.i4.0 - ret - } + ret + } } } @@ -93,7 +93,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CONSTRU .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 CONSTRUCTOR ret } diff --git a/src/mono/mono/tests/verifier/make_newarr_test.sh b/src/mono/mono/tests/verifier/make_newarr_test.sh index 464695ba6a39..b97d3bdcbb12 100755 --- a/src/mono/mono/tests/verifier/make_newarr_test.sh +++ b/src/mono/mono/tests/verifier/make_newarr_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -49,7 +49,7 @@ $SED -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE2 POST_OP pop ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_newobj_test.sh b/src/mono/mono/tests/verifier/make_newobj_test.sh index d8e4a6272052..e7925cee1e21 100755 --- a/src/mono/mono/tests/verifier/make_newobj_test.sh +++ b/src/mono/mono/tests/verifier/make_newobj_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -16,7 +16,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST1_TYPE}/g" -e "s/TYPE2/${TEST2_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -32,7 +32,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CLASS_FIELDS/${CLASS_FIELDS}/g" -e .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -69,7 +69,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/CLASS_FIELDS/${CLASS_FIELDS}/g" -e .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } diff --git a/src/mono/mono/tests/verifier/make_overlapped_test.sh b/src/mono/mono/tests/verifier/make_overlapped_test.sh index 239e27dc3b94..0bc9aa3378f8 100755 --- a/src/mono/mono/tests/verifier/make_overlapped_test.sh +++ b/src/mono/mono/tests/verifier/make_overlapped_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -12,7 +12,7 @@ TEST_POS_1=$4 TEST_POS_2=$5 TEST_TYPE_0=$6 -if [ "x$TEST_TYPE_0" = "x" ] ; then +if [ "x$TEST_TYPE_0" = "x" ]; then TEST_TYPE_0="int32"; fi @@ -21,7 +21,7 @@ echo $TEST_FILE TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE_0/${TEST_TYPE_0}/g"> $TEST_FILE < $TEST_FI .field [${TEST_POS_1}] public object objVal .field [${TEST_POS_2}] public int32 intVal2 - .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed + .method public hidebysig specialname rtspecialname instance default void '.ctor' () cil managed { .maxstack 8 - ret + ret } } diff --git a/src/mono/mono/tests/verifier/make_prefix_test.sh b/src/mono/mono/tests/verifier/make_prefix_test.sh index f6e311cb13eb..05f24b9537eb 100755 --- a/src/mono/mono/tests/verifier/make_prefix_test.sh +++ b/src/mono/mono/tests/verifier/make_prefix_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -34,12 +34,12 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T { .field public int32 valid - .method public hidebysig specialname rtspecialname instance default void .ctor (int32&) cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor (int32&) cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtTest (ClassA& arg) @@ -103,7 +103,7 @@ $SED -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/BEFORE_OP/${T leave END END: ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_ret_test.sh b/src/mono/mono/tests/verifier/make_ret_test.sh index 1f512fd12674..3ff878868c6f 100755 --- a/src/mono/mono/tests/verifier/make_ret_test.sh +++ b/src/mono/mono/tests/verifier/make_ret_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/TYPE2/${TEST_TYPE2}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -37,7 +37,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" > $TEST_FIL ${OPCODE_2} leave END } - catch [mscorlib]System.NullReferenceException + catch [mscorlib]System.NullReferenceException { pop ${OPCODE_3} @@ -47,7 +47,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" > $TEST_FIL ${OPCODE_4} leave END } - catch [mscorlib]System.NullReferenceException + catch [mscorlib]System.NullReferenceException { pop ${OPCODE_5} @@ -55,7 +55,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" > $TEST_FIL } - .try + .try { nop leave END @@ -87,7 +87,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" > $TEST_FIL endfinally } - .try + .try { nop leave END diff --git a/src/mono/mono/tests/verifier/make_self_nested_test.sh b/src/mono/mono/tests/verifier/make_self_nested_test.sh index c6521173ebe3..763ed67f3b34 100755 --- a/src/mono/mono/tests/verifier/make_self_nested_test.sh +++ b/src/mono/mono/tests/verifier/make_self_nested_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -22,7 +22,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CLASS_A .ver 0:0:0:0 } -// VALIDITY CIL which breaks the ECMA-335 rules. +// VALIDITY CIL which breaks the ECMA-335 rules. // this CIL should fail verification by a conforming CLI verifier. .assembly extern mscorlib @@ -36,7 +36,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CLASS_A .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -49,7 +49,7 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CLASS_A .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() ret } @@ -58,8 +58,8 @@ $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CLASS_A { .maxstack 8 ldc.i4.0 - ret - } + ret + } } .method public void Method () diff --git a/src/mono/mono/tests/verifier/make_sizeof_test.sh b/src/mono/mono/tests/verifier/make_sizeof_test.sh index 135b21e90ecf..a8d2edb05432 100755 --- a/src/mono/mono/tests/verifier/make_sizeof_test.sh +++ b/src/mono/mono/tests/verifier/make_sizeof_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -15,7 +15,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -11,7 +11,7 @@ TEST_OP_SHORT=`echo $TEST_OP | cut -d " " -f 1` TEST_FILE=`echo invalid_stack_0_${TEST_OP_SHORT} | $SED -e "s/ /_/g" -e "s/\./_/g" -e "s/&/mp/g"`_generated.il echo $TEST_FILE $SED -e "s/OPCODE/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -12,7 +12,7 @@ TEST_OP_SHORT=`echo $TEST_OP | cut -d " " -f 1` TEST_FILE=`echo ${TEST_VALIDITY}_stack_0_${TEST_OP_SHORT} | $SED -e "s/ /_/g" -e "s/\./_/g" -e "s/&/mp/g"`_generated.il echo $TEST_FILE $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi diff --git a/src/mono/mono/tests/verifier/make_stack_merge_test.sh b/src/mono/mono/tests/verifier/make_stack_merge_test.sh index 5ffeb8300b13..81a6178d07af 100755 --- a/src/mono/mono/tests/verifier/make_stack_merge_test.sh +++ b/src/mono/mono/tests/verifier/make_stack_merge_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/TYPE2/${TEST_TYPE2}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -18,7 +18,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/ARR/${TEST_ARR}/g" -e "s/IDX/${TEST_IDX}/g" -e "s/VAL/${TEST_VAL}/g" -e "s/LD/${TEST_LD}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -94,7 +94,7 @@ $SED -e "s/EXTRA_OPS/${TEST_EXTRA_OPS}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VAL ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_store_indirect_test.sh b/src/mono/mono/tests/verifier/make_store_indirect_test.sh index 6ff4f9076e33..f0c21d28fc90 100755 --- a/src/mono/mono/tests/verifier/make_store_indirect_test.sh +++ b/src/mono/mono/tests/verifier/make_store_indirect_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -60,7 +60,7 @@ $SED -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/T1_VAL/${T1_VAL}/g" -e "s/TYPE2/${TEST_T ldloc.1 OP ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_store_test.sh b/src/mono/mono/tests/verifier/make_store_test.sh index 78e6081721ae..40ebd0b0f706 100755 --- a/src/mono/mono/tests/verifier/make_store_test.sh +++ b/src/mono/mono/tests/verifier/make_store_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -18,7 +18,7 @@ TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` TEST_TYPE2=`echo $TEST_TYPE2 | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/TYPE2/${TEST_TYPE2}/g" -e "s/OPCODE/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -25,7 +25,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/FINALLY/${TEST_FIN}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -41,12 +41,12 @@ $SED -e "s/RET_TYPE/${TEST_RET_TYPE}/g" -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE { .field public int32 valid - .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed + .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed { .maxstack 8 - ldarg.0 + ldarg.0 call instance void object::.ctor() - ret + ret } .method public virtual void VirtTest () @@ -121,7 +121,7 @@ AFTER: leave END END: $LD_RET_CODE - ret + ret } @@ -136,7 +136,7 @@ END: leave END END: ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_tests.sh b/src/mono/mono/tests/verifier/make_tests.sh index 5674f821b0aa..b614b5dbf9a2 100755 --- a/src/mono/mono/tests/verifier/make_tests.sh +++ b/src/mono/mono/tests/verifier/make_tests.sh @@ -30,7 +30,7 @@ do else INIT="no"; fi - + ./make_bin_test.sh bin_num_op_32_${I} valid $OP int32 int32 "ldc.i4.1" "${INIT}" ./make_bin_test.sh bin_num_op_33_${I} valid $OP int32 'native int' "ldc.i4.1" "${INIT}" ./make_bin_test.sh bin_num_op_34_${I} valid $OP int64 int64 "ldc.i8 1" "${INIT}" @@ -40,7 +40,7 @@ do ./make_bin_test.sh bin_num_op_38_${I} valid $OP float32 float64 "ldc.r8 0" "${INIT}" ./make_bin_test.sh bin_num_op_39_${I} valid $OP float64 float32 "ldc.r4 0" "${INIT}" ./make_bin_test.sh bin_num_op_40_${I} valid $OP float32 float32 "ldc.r4 0" "${INIT}" - + ./make_bin_test.sh bin_num_op_1_${I} unverifiable $OP int32 int64 "ldc.i8 1" "${INIT}" ./make_bin_test.sh bin_num_op_2_${I} unverifiable $OP int32 float64 "ldc.r8 0" "${INIT}" ./make_bin_test.sh bin_num_op_3_${I} unverifiable $OP int32 object "ldnull" "${INIT}" @@ -184,7 +184,7 @@ do done -for TYPE in int32 float32 int64 "int32&" "native int" +for TYPE in int32 float32 int64 "int32&" "native int" do ./make_bin_test.sh bin_cgt_un_a_${I} unverifiable 'cgt.un' "${TYPE}" 'object' ./make_bin_test.sh bin_cgt_un_b_${I} unverifiable 'cgt.un' 'object' "${TYPE}" @@ -313,7 +313,7 @@ done # Table 8: Conversion Operations I=1 J=1 -for OP in "conv.i1\n\tpop" "conv.i2\n\tpop" "conv.i4\n\tpop" "conv.i8\n\tpop" "conv.r4\n\tpop" "conv.r8\n\tpop" "conv.u1\n\tpop" "conv.u2\n\tpop" "conv.u4\n\tpop" "conv.u8\n\tpop" "conv.i\n\tpop" "conv.u\n\tpop" "conv.r.un\n\tpop" "conv.ovf.i1\n\tpop" "conv.ovf.i2\n\tpop" "conv.ovf.i4\n\tpop" "conv.ovf.i8\n\tpop" "conv.ovf.u1\n\tpop" "conv.ovf.u2\n\tpop" "conv.ovf.u4\n\tpop" "conv.ovf.u8\n\tpop" "conv.ovf.i\n\tpop" "conv.ovf.u\n\tpop" "conv.ovf.i1.un\n\tpop" "conv.ovf.i2.un\n\tpop" "conv.ovf.i4.un\n\tpop" "conv.ovf.i8.un\n\tpop" "conv.ovf.u1.un\n\tpop" "conv.ovf.u2.un\n\tpop" "conv.ovf.u4.un\n\tpop" "conv.ovf.u8.un\n\tpop" "conv.ovf.i.un\n\tpop" "conv.ovf.u.un\n\tpop" +for OP in "conv.i1\n\tpop" "conv.i2\n\tpop" "conv.i4\n\tpop" "conv.i8\n\tpop" "conv.r4\n\tpop" "conv.r8\n\tpop" "conv.u1\n\tpop" "conv.u2\n\tpop" "conv.u4\n\tpop" "conv.u8\n\tpop" "conv.i\n\tpop" "conv.u\n\tpop" "conv.r.un\n\tpop" "conv.ovf.i1\n\tpop" "conv.ovf.i2\n\tpop" "conv.ovf.i4\n\tpop" "conv.ovf.i8\n\tpop" "conv.ovf.u1\n\tpop" "conv.ovf.u2\n\tpop" "conv.ovf.u4\n\tpop" "conv.ovf.u8\n\tpop" "conv.ovf.i\n\tpop" "conv.ovf.u\n\tpop" "conv.ovf.i1.un\n\tpop" "conv.ovf.i2.un\n\tpop" "conv.ovf.i4.un\n\tpop" "conv.ovf.i8.un\n\tpop" "conv.ovf.u1.un\n\tpop" "conv.ovf.u2.un\n\tpop" "conv.ovf.u4.un\n\tpop" "conv.ovf.u8.un\n\tpop" "conv.ovf.i.un\n\tpop" "conv.ovf.u.un\n\tpop" do for TYPE in 'int8' 'bool' 'unsigned int8' 'int16' 'char' 'unsigned int16' 'int32' 'unsigned int32' 'int64' 'unsigned int64' 'float32' 'float64' 'native int' 'native unsigned int' do @@ -357,55 +357,55 @@ do ./make_store_test.sh coercion_14_${I} unverifiable "$OP" int16 float64 ./make_store_test.sh coercion_15_${I} unverifiable "$OP" int16 'int16&' ./make_store_test.sh coercion_16_${I} unverifiable "$OP" int16 object - + ./make_store_test.sh coercion_17_${I} unverifiable "$OP" 'unsigned int16' int64 ./make_store_test.sh coercion_18_${I} unverifiable "$OP" 'unsigned int16' float64 ./make_store_test.sh coercion_19_${I} unverifiable "$OP" 'unsigned int16' 'unsigned int16&' ./make_store_test.sh coercion_20_${I} unverifiable "$OP" 'unsigned int16' object - + ./make_store_test.sh coercion_21_${I} unverifiable "$OP" char int64 ./make_store_test.sh coercion_22_${I} unverifiable "$OP" char float64 ./make_store_test.sh coercion_23_${I} unverifiable "$OP" char 'char&' ./make_store_test.sh coercion_24_${I} unverifiable "$OP" char object - + ./make_store_test.sh coercion_25_${I} unverifiable "$OP" int32 int64 ./make_store_test.sh coercion_26_${I} unverifiable "$OP" int32 float64 ./make_store_test.sh coercion_27_${I} unverifiable "$OP" int32 'int32&' ./make_store_test.sh coercion_28_${I} unverifiable "$OP" int32 object - + ./make_store_test.sh coercion_29_${I} unverifiable "$OP" 'unsigned int32' int64 ./make_store_test.sh coercion_30_${I} unverifiable "$OP" 'unsigned int32' float64 ./make_store_test.sh coercion_31_${I} unverifiable "$OP" 'unsigned int32' 'unsigned int32&' ./make_store_test.sh coercion_32_${I} unverifiable "$OP" 'unsigned int32' object - + ./make_store_test.sh coercion_33_${I} unverifiable "$OP" int64 int32 ./make_store_test.sh coercion_34_${I} unverifiable "$OP" int64 'native int' ./make_store_test.sh coercion_35_${I} unverifiable "$OP" int64 float64 ./make_store_test.sh coercion_36_${I} unverifiable "$OP" int64 'int64&' ./make_store_test.sh coercion_37_${I} unverifiable "$OP" int64 object - + ./make_store_test.sh coercion_38_${I} unverifiable "$OP" 'unsigned int64' int32 ./make_store_test.sh coercion_39_${I} unverifiable "$OP" 'unsigned int64' 'native int' ./make_store_test.sh coercion_40_${I} unverifiable "$OP" 'unsigned int64' float64 ./make_store_test.sh coercion_41_${I} unverifiable "$OP" 'unsigned int64' 'unsigned int64&' ./make_store_test.sh coercion_42_${I} unverifiable "$OP" 'unsigned int64' object - + ./make_store_test.sh coercion_43_${I} unverifiable "$OP" 'native int' int64 ./make_store_test.sh coercion_44_${I} unverifiable "$OP" 'native int' float64 ./make_store_test.sh coercion_45_${I} unverifiable "$OP" 'native int' 'native int&' ./make_store_test.sh coercion_46_${I} unverifiable "$OP" 'native int' object - + ./make_store_test.sh coercion_47_${I} unverifiable "$OP" 'native unsigned int' int64 ./make_store_test.sh coercion_48_${I} unverifiable "$OP" 'native unsigned int' float64 ./make_store_test.sh coercion_49_${I} unverifiable "$OP" 'native unsigned int' 'native unsigned int&' ./make_store_test.sh coercion_50_${I} unverifiable "$OP" 'native unsigned int' object - + ./make_store_test.sh coercion_51_${I} unverifiable "$OP" float32 int32 ./make_store_test.sh coercion_52_${I} unverifiable "$OP" float32 'native int' ./make_store_test.sh coercion_53_${I} unverifiable "$OP" float32 int64 ./make_store_test.sh coercion_54_${I} unverifiable "$OP" float32 'float32&' ./make_store_test.sh coercion_55_${I} unverifiable "$OP" float32 object - + ./make_store_test.sh coercion_56_${I} unverifiable "$OP" float64 int32 ./make_store_test.sh coercion_57_${I} unverifiable "$OP" float64 'native int' ./make_store_test.sh coercion_58_${I} unverifiable "$OP" float64 int64 @@ -417,20 +417,20 @@ do ./make_store_test.sh coercion_63_${I} unverifiable "$OP" object int64 ./make_store_test.sh coercion_64_${I} unverifiable "$OP" object float64 ./make_store_test.sh coercion_65_${I} unverifiable "$OP" object 'object&' - + ./make_store_test.sh coercion_66_${I} unverifiable "$OP" 'class ValueType' int32 ./make_store_test.sh coercion_67_${I} unverifiable "$OP" 'class ValueType' 'native int' ./make_store_test.sh coercion_68_${I} unverifiable "$OP" 'class ValueType' int64 ./make_store_test.sh coercion_69_${I} unverifiable "$OP" 'class ValueType' float64 ./make_store_test.sh coercion_70_${I} unverifiable "$OP" 'class ValueType' 'class ValueType&' ./make_store_test.sh coercion_71_${I} unverifiable "$OP" 'class ValueType' object - + ./make_store_test.sh coercion_72_${I} unverifiable "$OP" 'int32&' int32 ./make_store_test.sh coercion_73_${I} unverifiable "$OP" 'int32&' 'native int' ./make_store_test.sh coercion_74_${I} unverifiable "$OP" 'int32&' int64 ./make_store_test.sh coercion_75_${I} unverifiable "$OP" 'int32&' float64 ./make_store_test.sh coercion_76_${I} unverifiable "$OP" 'int32&' object - + ./make_store_test.sh coercion_77_${I} unverifiable "$OP" typedref int32 ./make_store_test.sh coercion_78_${I} unverifiable "$OP" typedref 'native int' ./make_store_test.sh coercion_89_${I} unverifiable "$OP" typedref int64 @@ -442,7 +442,7 @@ done #valid coercion between native int and int32 I=1 -for OP in stloc.0 "starg 0" +for OP in stloc.0 "starg 0" do ./make_store_test.sh coercion_83_${I} valid "$OP" int32 "native int" ./make_store_test.sh coercion_84_${I} valid "$OP" "native int" int32 @@ -495,9 +495,9 @@ done function fix () { - if [ "$3" != "" ]; then + if [ -n "$3" ]; then A=$3; - elif [ "$2" != "" ]; then + elif [ -n "$2" ]; then A=$2; else A=$1; @@ -595,55 +595,55 @@ do ./make_obj_store_test.sh obj_coercion_14_${I} unverifiable "$OP" int16 float64 ./make_obj_store_test.sh obj_coercion_15_${I} unverifiable "$OP" int16 'int16&' ./make_obj_store_test.sh obj_coercion_16_${I} unverifiable "$OP" int16 object - + ./make_obj_store_test.sh obj_coercion_17_${I} unverifiable "$OP" 'unsigned int16' int64 ./make_obj_store_test.sh obj_coercion_18_${I} unverifiable "$OP" 'unsigned int16' float64 ./make_obj_store_test.sh obj_coercion_19_${I} unverifiable "$OP" 'unsigned int16' 'unsigned int16&' ./make_obj_store_test.sh obj_coercion_20_${I} unverifiable "$OP" 'unsigned int16' object - + ./make_obj_store_test.sh obj_coercion_21_${I} unverifiable "$OP" char int64 ./make_obj_store_test.sh obj_coercion_22_${I} unverifiable "$OP" char float64 ./make_obj_store_test.sh obj_coercion_23_${I} unverifiable "$OP" char 'char&' ./make_obj_store_test.sh obj_coercion_24_${I} unverifiable "$OP" char object - + ./make_obj_store_test.sh obj_coercion_25_${I} unverifiable "$OP" int32 int64 ./make_obj_store_test.sh obj_coercion_26_${I} unverifiable "$OP" int32 float64 ./make_obj_store_test.sh obj_coercion_27_${I} unverifiable "$OP" int32 'int32&' ./make_obj_store_test.sh obj_coercion_28_${I} unverifiable "$OP" int32 object - + ./make_obj_store_test.sh obj_coercion_29_${I} unverifiable "$OP" 'unsigned int32' int64 ./make_obj_store_test.sh obj_coercion_30_${I} unverifiable "$OP" 'unsigned int32' float64 ./make_obj_store_test.sh obj_coercion_31_${I} unverifiable "$OP" 'unsigned int32' 'unsigned int32&' ./make_obj_store_test.sh obj_coercion_32_${I} unverifiable "$OP" 'unsigned int32' object - + ./make_obj_store_test.sh obj_coercion_33_${I} unverifiable "$OP" int64 int32 ./make_obj_store_test.sh obj_coercion_34_${I} unverifiable "$OP" int64 'native int' ./make_obj_store_test.sh obj_coercion_35_${I} unverifiable "$OP" int64 float64 ./make_obj_store_test.sh obj_coercion_36_${I} unverifiable "$OP" int64 'int64&' ./make_obj_store_test.sh obj_coercion_37_${I} unverifiable "$OP" int64 object - + ./make_obj_store_test.sh obj_coercion_38_${I} unverifiable "$OP" 'unsigned int64' int32 ./make_obj_store_test.sh obj_coercion_39_${I} unverifiable "$OP" 'unsigned int64' 'native int' ./make_obj_store_test.sh obj_coercion_40_${I} unverifiable "$OP" 'unsigned int64' float64 ./make_obj_store_test.sh obj_coercion_41_${I} unverifiable "$OP" 'unsigned int64' 'unsigned int64&' ./make_obj_store_test.sh obj_coercion_42_${I} unverifiable "$OP" 'unsigned int64' object - + ./make_obj_store_test.sh obj_coercion_43_${I} unverifiable "$OP" 'native int' int64 ./make_obj_store_test.sh obj_coercion_44_${I} unverifiable "$OP" 'native int' float64 ./make_obj_store_test.sh obj_coercion_45_${I} unverifiable "$OP" 'native int' 'native int&' ./make_obj_store_test.sh obj_coercion_46_${I} unverifiable "$OP" 'native int' object - + ./make_obj_store_test.sh obj_coercion_47_${I} unverifiable "$OP" 'native unsigned int' int64 ./make_obj_store_test.sh obj_coercion_48_${I} unverifiable "$OP" 'native unsigned int' float64 ./make_obj_store_test.sh obj_coercion_49_${I} unverifiable "$OP" 'native unsigned int' 'native unsigned int&' ./make_obj_store_test.sh obj_coercion_50_${I} unverifiable "$OP" 'native unsigned int' object - + ./make_obj_store_test.sh obj_coercion_51_${I} unverifiable "$OP" float32 int32 ./make_obj_store_test.sh obj_coercion_52_${I} unverifiable "$OP" float32 'native int' ./make_obj_store_test.sh obj_coercion_53_${I} unverifiable "$OP" float32 int64 ./make_obj_store_test.sh obj_coercion_54_${I} unverifiable "$OP" float32 'float32&' ./make_obj_store_test.sh obj_coercion_55_${I} unverifiable "$OP" float32 object - + ./make_obj_store_test.sh obj_coercion_56_${I} unverifiable "$OP" float64 int32 ./make_obj_store_test.sh obj_coercion_57_${I} unverifiable "$OP" float64 'native int' ./make_obj_store_test.sh obj_coercion_58_${I} unverifiable "$OP" float64 int64 @@ -655,15 +655,15 @@ do ./make_obj_store_test.sh obj_coercion_63_${I} unverifiable "$OP" object int64 ./make_obj_store_test.sh obj_coercion_64_${I} unverifiable "$OP" object float64 ./make_obj_store_test.sh obj_coercion_65_${I} unverifiable "$OP" object 'object&' - + ./make_obj_store_test.sh obj_coercion_66_${I} unverifiable "$OP" 'class ValueType' int32 ./make_obj_store_test.sh obj_coercion_67_${I} unverifiable "$OP" 'class ValueType' 'native int' ./make_obj_store_test.sh obj_coercion_68_${I} unverifiable "$OP" 'class ValueType' int64 ./make_obj_store_test.sh obj_coercion_69_${I} unverifiable "$OP" 'class ValueType' float64 ./make_obj_store_test.sh obj_coercion_70_${I} unverifiable "$OP" 'class ValueType' 'class ValueType&' ./make_obj_store_test.sh obj_coercion_71_${I} unverifiable "$OP" 'class ValueType' object - - + + #These tests don't test store error since one cannot have an 'int32&' field #They should exist in the structural tests session #./make_obj_store_test.sh obj_coercion_72_${I} invalid "$OP" 'int32&' int32 @@ -671,17 +671,17 @@ do #./make_obj_store_test.sh obj_coercion_74_${I} invalid "$OP" 'int32&' int64 #./make_obj_store_test.sh obj_coercion_75_${I} invalid "$OP" 'int32&' float64 #./make_obj_store_test.sh obj_coercion_76_${I} invalid "$OP" 'int32&' object - + ./make_obj_store_test.sh obj_coercion_83_${I} valid "$OP" int32 "native int" ./make_obj_store_test.sh obj_coercion_84_${I} valid "$OP" "native int" int32 - + ./make_obj_store_test.sh obj_coercion_85_${I} valid "$OP" "unsigned int32" "native int" ./make_obj_store_test.sh obj_coercion_86_${I} valid "$OP" "native int" "unsigned int32" - + ./make_obj_store_test.sh obj_coercion_87_${I} valid "$OP" int32 "native unsigned int" ./make_obj_store_test.sh obj_coercion_88_${I} valid "$OP" "native unsigned int" int32 - + ./make_obj_store_test.sh obj_coercion_89_${I} valid "$OP" "unsigned int32" "native int" ./make_obj_store_test.sh obj_coercion_90_${I} valid "$OP" "native unsigned int" "unsigned int32" I=`expr $I + 1` @@ -708,7 +708,7 @@ do # ClassA not interface type. # FIXME: what was the purpoise of this test? on it's current for it is valid and not unverifiable ./make_store_test.sh assign_compat_3_${I} valid "$OP" object 'class ClassA' - + # Implementation of InterfaceB does not require the implementation of InterfaceA ./make_store_test.sh assign_compat_4_${I} unverifiable "$OP" 'class InterfaceA' 'class InterfaceB' @@ -749,7 +749,7 @@ do # ClassA not interface type. #FIXME: this test is valid, you can store type ClassA in a object field ./make_obj_store_test.sh assign_compat_3_${I} valid "$OP" object 'class ClassA' - + # Implementation of InterfaceB does not require the implementation of InterfaceA ./make_obj_store_test.sh assign_compat_4_${I} unverifiable "$OP" 'class InterfaceA' 'class InterfaceB' @@ -770,13 +770,13 @@ do # Method pointers with different calling conventions. ./make_obj_store_test.sh assign_compat_10_${I} unverifiable "$OP" 'method vararg int32 *(int32)' 'method int32 *(int32)' - + # Method pointers with different calling conventions. (2) ./make_obj_store_test.sh assign_compat_11_${I} unverifiable "$OP" 'method unmanaged fastcall int32 *(int32)' 'method int32 *(int32)' - + # Method pointers with different calling conventions. (3) ./make_obj_store_test.sh assign_compat_12_${I} unverifiable "$OP" 'method unmanaged fastcall int32 *(int32)' 'method unmanaged stdcall int32 *(int32)' - + I=`expr $I + 1` done @@ -790,7 +790,7 @@ do T1_PTR=$? ZZ=`echo $TYPE2 | grep "*";` T2_PTR=$? - + if [ $T1_PTR -eq 0 ] || [ $T2_PTR -eq 0 ]; then ./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2" elif [ "$TYPE1" = "$TYPE2" ]; then @@ -813,9 +813,9 @@ done # Unverifiable array stack merges # These are verifiable, the merged type is 'object' or 'Array' -#for TYPE1 in 'string []' 'string [,]' 'string [,,]' +#for TYPE1 in 'string []' 'string [,]' 'string [,,]' #do -# for TYPE2 in 'string []' 'string [,]' 'string [,,]' +# for TYPE2 in 'string []' 'string [,]' 'string [,,]' # do # if [ "$TYPE1" != "$TYPE2" ]; then # ./make_stack_merge_test.sh stack_merge_${I} unverifiable "$TYPE1" "$TYPE2" @@ -974,55 +974,55 @@ done ./make_ret_test.sh ret_coercion_14 unverifiable int16 float64 ./make_ret_test.sh ret_coercion_15 unverifiable int16 'int16&' ./make_ret_test.sh ret_coercion_16 unverifiable int16 object - + ./make_ret_test.sh ret_coercion_17 unverifiable 'unsigned int16' int64 ./make_ret_test.sh ret_coercion_18 unverifiable 'unsigned int16' float64 ./make_ret_test.sh ret_coercion_19 unverifiable 'unsigned int16' 'unsigned int16&' ./make_ret_test.sh ret_coercion_20 unverifiable 'unsigned int16' object - + ./make_ret_test.sh ret_coercion_21 unverifiable char int64 ./make_ret_test.sh ret_coercion_22 unverifiable char float64 ./make_ret_test.sh ret_coercion_23 unverifiable char 'char&' ./make_ret_test.sh ret_coercion_24 unverifiable char object - + ./make_ret_test.sh ret_coercion_25 unverifiable int32 int64 ./make_ret_test.sh ret_coercion_26 unverifiable int32 float64 ./make_ret_test.sh ret_coercion_27 unverifiable int32 'int32&' ./make_ret_test.sh ret_coercion_28 unverifiable int32 object - + ./make_ret_test.sh ret_coercion_29 unverifiable 'unsigned int32' int64 ./make_ret_test.sh ret_coercion_30 unverifiable 'unsigned int32' float64 ./make_ret_test.sh ret_coercion_31 unverifiable 'unsigned int32' 'unsigned int32&' ./make_ret_test.sh ret_coercion_32 unverifiable 'unsigned int32' object - + ./make_ret_test.sh ret_coercion_33 unverifiable int64 int32 ./make_ret_test.sh ret_coercion_34 unverifiable int64 'native int' ./make_ret_test.sh ret_coercion_35 unverifiable int64 float64 ./make_ret_test.sh ret_coercion_36 unverifiable int64 'int64&' ./make_ret_test.sh ret_coercion_37 unverifiable int64 object - + ./make_ret_test.sh ret_coercion_38 unverifiable 'unsigned int64' int32 ./make_ret_test.sh ret_coercion_39 unverifiable 'unsigned int64' 'native int' ./make_ret_test.sh ret_coercion_40 unverifiable 'unsigned int64' float64 ./make_ret_test.sh ret_coercion_41 unverifiable 'unsigned int64' 'unsigned int64&' ./make_ret_test.sh ret_coercion_42 unverifiable 'unsigned int64' object - + ./make_ret_test.sh ret_coercion_43 unverifiable 'native int' int64 ./make_ret_test.sh ret_coercion_44 unverifiable 'native int' float64 ./make_ret_test.sh ret_coercion_45 unverifiable 'native int' 'native int&' ./make_ret_test.sh ret_coercion_46 unverifiable 'native int' object - + ./make_ret_test.sh ret_coercion_47 unverifiable 'native unsigned int' int64 ./make_ret_test.sh ret_coercion_48 unverifiable 'native unsigned int' float64 ./make_ret_test.sh ret_coercion_49 unverifiable 'native unsigned int' 'native unsigned int&' ./make_ret_test.sh ret_coercion_50 unverifiable 'native unsigned int' object - + ./make_ret_test.sh ret_coercion_51 unverifiable float32 int32 ./make_ret_test.sh ret_coercion_52 unverifiable float32 'native int' ./make_ret_test.sh ret_coercion_53 unverifiable float32 int64 ./make_ret_test.sh ret_coercion_54 unverifiable float32 'float32&' ./make_ret_test.sh ret_coercion_55 unverifiable float32 object - + ./make_ret_test.sh ret_coercion_56 unverifiable float64 int32 ./make_ret_test.sh ret_coercion_57 unverifiable float64 'native int' ./make_ret_test.sh ret_coercion_58 unverifiable float64 int64 @@ -1034,20 +1034,20 @@ done ./make_ret_test.sh ret_coercion_63 unverifiable object int64 ./make_ret_test.sh ret_coercion_64 unverifiable object float64 ./make_ret_test.sh ret_coercion_65 unverifiable object 'object&' - + ./make_ret_test.sh ret_coercion_66 unverifiable 'class MyValueType' int32 ./make_ret_test.sh ret_coercion_67 unverifiable 'class MyValueType' 'native int' ./make_ret_test.sh ret_coercion_68 unverifiable 'class MyValueType' int64 ./make_ret_test.sh ret_coercion_69 unverifiable 'class MyValueType' float64 ./make_ret_test.sh ret_coercion_70 unverifiable 'class MyValueType' 'class MyValueType&' ./make_ret_test.sh ret_coercion_71 unverifiable 'class MyValueType' object - + ./make_ret_test.sh ret_coercion_72 unverifiable 'int32&' int32 ./make_ret_test.sh ret_coercion_73 unverifiable 'int32&' 'native int' ./make_ret_test.sh ret_coercion_74 unverifiable 'int32&' int64 ./make_ret_test.sh ret_coercion_75 unverifiable 'int32&' float64 ./make_ret_test.sh ret_coercion_76 unverifiable 'int32&' object - + ./make_ret_test.sh ret_coercion_77 unverifiable typedref int32 ./make_ret_test.sh ret_coercion_78 unverifiable typedref 'native int' ./make_ret_test.sh ret_coercion_79 unverifiable typedref int64 @@ -1317,24 +1317,24 @@ do LOCALS_1='' CALL_1='ldc.i4.0' SIG_1='int32' - + ARGS_2='int32 V, int32 V1' LOCALS_2='' CALL_2='ldc.i4.0\n\tldc.i4.0' SIG_2='int32, int32' - + ARGS_3='int32 V, int32 V1, int32 V1' LOCALS_3='' CALL_3='ldc.i4.0\n\tldc.i4.0\n\tldc.i4.0' SIG_3='int32, int32, int32' - + ARGS_4='int32 V, int32 V1, int32 V1, int32 V1' LOCALS_4='' CALL_4='ldc.i4.0\n\tldc.i4.0\n\tldc.i4.0\n\tldc.i4.0' SIG_4='int32, int32, int32, int32' MAX_PARAM_RESULT="unverifiable" POPS="pop\npop\npop\npop\npop\npop\npop\npop\n" - + if [ "$OP" = "ldloc" ]; then MAX_PARAM_RESULT="invalid" @@ -1358,26 +1358,26 @@ do CALL_4='' SIG_4='' fi; - + ./make_load_test.sh ${OP}0_max_params "${MAX_PARAM_RESULT}" "${OP}.0" '' '' '' '' ./make_load_test.sh ${OP}1_max_params "${MAX_PARAM_RESULT}" "${OP}.1" '' '' '' '' ./make_load_test.sh ${OP}2_max_params "${MAX_PARAM_RESULT}" "${OP}.2" '' '' '' '' ./make_load_test.sh ${OP}3_max_params "${MAX_PARAM_RESULT}" "${OP}.3" '' '' '' '' - + ./make_load_test.sh ${OP}1_1_max_params "${MAX_PARAM_RESULT}" "${OP}.1" "${ARGS_1}" "${LOCALS_1}" "${CALL_1}" "${SIG_1}" ./make_load_test.sh ${OP}2_1_max_params "${MAX_PARAM_RESULT}" "${OP}.2" "${ARGS_1}" "${LOCALS_1}" "${CALL_1}" "${SIG_1}" ./make_load_test.sh ${OP}3_1_max_params "${MAX_PARAM_RESULT}" "${OP}.3" "${ARGS_1}" "${LOCALS_1}" "${CALL_1}" "${SIG_1}" - + ./make_load_test.sh ${OP}2_2_max_params "${MAX_PARAM_RESULT}" "${OP}.2" "${ARGS_2}" "${LOCALS_2}" "${CALL_2}" "${SIG_2}" ./make_load_test.sh ${OP}3_2_max_params "${MAX_PARAM_RESULT}" "${OP}.3" "${ARGS_2}" "${LOCALS_2}" "${CALL_2}" "${SIG_2}" - + ./make_load_test.sh ${OP}3_3_max_params "${MAX_PARAM_RESULT}" "${OP}.3" "${ARGS_3}" "${LOCALS_3}" "${CALL_3}" "${SIG_3}" - + ./make_load_test.sh ${OP}0_max_params valid "${OP}.0" "${ARGS_1}" "${LOCALS_1}" "${CALL_1}" "${SIG_1}" ./make_load_test.sh ${OP}1_max_params valid "${OP}.1" "${ARGS_2}" "${LOCALS_2}" "${CALL_2}" "${SIG_2}" ./make_load_test.sh ${OP}2_max_params valid "${OP}.2" "${ARGS_3}" "${LOCALS_3}" "${CALL_3}" "${SIG_3}" ./make_load_test.sh ${OP}3_max_params valid "${OP}.3" "${ARGS_4}" "${LOCALS_4}" "${CALL_4}" "${SIG_4}" - + ./make_load_test.sh ${OP}0_stack_overflow invalid "${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${OP}.0\n${POPS}" "${ARGS_4}" "${LOCALS_4}" "${CALL_4}" "${SIG_4}" ./make_load_test.sh ${OP}1_stack_overflow invalid "${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${OP}.1\n${POPS}" "${ARGS_4}" "${LOCALS_4}" "${CALL_4}" "${SIG_4}" ./make_load_test.sh ${OP}2_stack_overflow invalid "${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${OP}.2\n${POPS}" "${ARGS_4}" "${LOCALS_4}" "${CALL_4}" "${SIG_4}" @@ -1393,7 +1393,7 @@ do ./make_bool_branch_test.sh boolean_branch_${I}_3 valid ${OP} int32 ./make_bool_branch_test.sh boolean_branch_${I}_4 valid ${OP} int64 ./make_bool_branch_test.sh boolean_branch_${I}_5 valid ${OP} 'native int' - + #unmanaged pointers are not veriable types, all ops on unmanaged pointers are unverifiable ./make_bool_branch_test.sh boolean_branch_${I}_6 unverifiable ${OP} 'int32*' ./make_bool_branch_test.sh boolean_branch_${I}_8 unverifiable ${OP} 'method int32 *(int32)' @@ -1407,7 +1407,7 @@ do ./make_bool_branch_test.sh boolean_branch_${I}_14 valid ${OP} 'class Template`1' ./make_bool_branch_test.sh boolean_branch_${I}_15 valid ${OP} 'class Template`1[]' ./make_bool_branch_test.sh boolean_branch_${I}_16 valid ${OP} 'class Template`1[,,]' - + ./make_bool_branch_test.sh boolean_branch_${I}_17 unverifiable ${OP} float32 ./make_bool_branch_test.sh boolean_branch_${I}_18 unverifiable ${OP} float64 ./make_bool_branch_test.sh boolean_branch_${I}_19 unverifiable ${OP} 'class MyValueType' @@ -1846,7 +1846,7 @@ done #static members are different from instance members I=1 -for OP in "ldc.i4.0\n\t\tstsfld int32 Class::sfld" "ldsfld int32 Class::sfld\n\n\tpop" "ldsflda int32 Class::sfld\n\n\tpop" +for OP in "ldc.i4.0\n\t\tstsfld int32 Class::sfld" "ldsfld int32 Class::sfld\n\n\tpop" "ldsflda int32 Class::sfld\n\n\tpop" do ./make_access_test.sh access_check_41_${I} valid "$OP" public family yes ./make_access_test.sh access_check_42_${I} valid "$OP" public famandassem yes @@ -2180,12 +2180,12 @@ done #ldobj tests function fix_ldobj () { - if [ "$3" != "" ]; then - A=$3; - elif [ "$2" != "" ]; then - A=$2; + if [ -n "$3" ]; then + A="$3"; + elif [ -n "$2" ]; then + A="$2"; else - A=$1; + A="$1"; fi if [ "$A" = "bool" ]; then @@ -2207,7 +2207,7 @@ do do TYPE1="$(fix_ldobj $T1)" TYPE2="$(fix_ldobj $T2)" - if [ "$TYPE1" = "$TYPE2" ] ; then + if [ "$TYPE1" = "$TYPE2" ]; then ./make_ldobj_test.sh ldobj_${I} valid "${T1}\&" "${T2}" else ./make_ldobj_test.sh ldobj_${I} unverifiable "${T1}\&" "${T2}" @@ -2220,16 +2220,16 @@ done #unverifiable #for T1 in "int8" "int64" "float64" "object" "string" "class Class" "int32[]" "int32[,]" "valuetype MyStruct" "valuetype MyStruct2" "int32 *" "valuetype MyStruct *" "method int32 *(int32)" -for T1 in "native int" "int8*" "typedref" +for T1 in "native int" "int8*" "typedref" do for T2 in "int8" "int64" "float64" "object" "string" "class Class" "int32[]" "int32[,]" "valuetype MyStruct" "valuetype MyStruct2" "int32 *" "valuetype MyStruct *" "method int32 *(int32)" "native int" "typedref" "class Template\`1" "valuetype StructTemplate\`1" "valuetype StructTemplate2\`1" - do + do ./make_ldobj_test.sh ldobj_${I} unverifiable "${T1}" "${T2}" I=`expr $I + 1` done done -for T1 in "native int" "int8*" "typedref" +for T1 in "native int" "int8*" "typedref" do ./make_ldobj_test.sh ldobj_${I} invalid "${T1}" "typedref\&" I=`expr $I + 1` @@ -2240,9 +2240,9 @@ done #invalid #for T1 in "int8" "int64" "float64" "object" "string" "class Class" "int32[]" "int32[,]" "valuetype MyStruct" "valuetype MyStruct2" "int32 *" "valuetype MyStruct *" "method int32 *(int32)" for T1 in 'int8' 'native int' -do +do for T2 in "int8\&" "int64\&" "float64\&" "object\&" "string\&" "class Class\&" "valuetype MyStruct\&" "native int\&" "class Template\`1\&" "valuetype StructTemplate\`1\&" "valuetype StructTemplate2\`1\&" "class [mscorlib]ExampleMM" "class [mscorlib]ExampleMM\&" - do + do ./make_ldobj_test.sh ldobj_${I} invalid "${T1}" "${T2}" I=`expr $I + 1` done @@ -2427,7 +2427,7 @@ done I=1 -for TYPE in "int32" "unsigned int32" "native int" "native unsigned int" +for TYPE in "int32" "unsigned int32" "native int" "native unsigned int" do ./make_load_indirect_test.sh indirect_load_i_${I} valid "ldind.i" "${TYPE}" I=`expr $I + 1` @@ -2523,14 +2523,14 @@ I=1 for TYPE1 in "int8" "bool" "int32" "native int" do ./make_store_indirect_test.sh indirect_store_bad_addr_i2_${I} unverifiable "stind.i2" "${TYPE1}\&" "int16" - ./make_store_indirect_test.sh indirect_store_good_val_i2_${I} valid "stind.i2" "int16\&" "${TYPE1}" + ./make_store_indirect_test.sh indirect_store_good_val_i2_${I} valid "stind.i2" "int16\&" "${TYPE1}" I=`expr $I + 1` done for TYPE1 in "int64" "float32" "float64" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1" do ./make_store_indirect_test.sh indirect_store_bad_addr_i2_${I} unverifiable "stind.i2" "${TYPE1}\&" "int16" - ./make_store_indirect_test.sh indirect_store_bad_val_i2_${I} unverifiable "stind.i2" "int16\&" "${TYPE1}" + ./make_store_indirect_test.sh indirect_store_bad_val_i2_${I} unverifiable "stind.i2" "int16\&" "${TYPE1}" I=`expr $I + 1` done @@ -2589,14 +2589,14 @@ done I=1 for TYPE1 in "int8" "bool" "int16" "char" do - ./make_store_indirect_test.sh indirect_store_bad_addr_i_${I} unverifiable "stind.i" "${TYPE1}\&" "native int" + ./make_store_indirect_test.sh indirect_store_bad_addr_i_${I} unverifiable "stind.i" "${TYPE1}\&" "native int" ./make_store_indirect_test.sh indirect_store_good_val_i_${I} valid "stind.i" "native int\&" "${TYPE1}" I=`expr $I + 1` done for TYPE1 in "int64" "float32" "float64" "object" "string" "class Class" "valuetype MyStruct" "int32[]" "int32[,]" "int32*" "method int32 *(int32)" "class Template\`1" do - ./make_store_indirect_test.sh indirect_store_bad_addr_i_${I} unverifiable "stind.i" "${TYPE1}\&" "native int" + ./make_store_indirect_test.sh indirect_store_bad_addr_i_${I} unverifiable "stind.i" "${TYPE1}\&" "native int" ./make_store_indirect_test.sh indirect_store_bad_val_i_${I} unverifiable "stind.i" "native int\&" "${TYPE1}" I=`expr $I + 1` done @@ -2701,7 +2701,7 @@ done ./make_ldelema_test.sh ldelema_empty_stack_3 invalid "pop" "ldc.i4.0" "int32" I=1 -for ARR in "int8" "int16" "int32" +for ARR in "int8" "int16" "int32" do ./make_ldelema_test.sh ldelema_size_compat_${I} valid "newarr ${ARR}" "ldc.i4.0" "unsigned ${ARR}" I=`expr $I + 1` @@ -2722,12 +2722,12 @@ done ./make_ldelema_test.sh ldelema_misc_size_compat_3 valid "newarr native int" "ldc.i4.0" "int32" ./make_ldelema_test.sh ldelema_misc_size_compat_4 valid "newarr native unsigned int" "ldc.i4.0" "int32" -./make_ldelema_test.sh ldelema_misc_size_compat_5 valid "newarr int8" "ldc.i4.0" "bool" +./make_ldelema_test.sh ldelema_misc_size_compat_5 valid "newarr int8" "ldc.i4.0" "bool" ./make_ldelema_test.sh ldelema_misc_size_compat_6 valid "newarr int16" "ldc.i4.0" "char" ./make_ldelema_test.sh ldelema_misc_size_compat_7 valid "newarr int32" "ldc.i4.0" "native int" ./make_ldelema_test.sh ldelema_misc_size_compat_8 valid "newarr int32" "ldc.i4.0" "native unsigned int" -./make_ldelema_test.sh ldelema_misc_size_compat_9 valid "newarr unsigned int8" "ldc.i4.0" "bool" +./make_ldelema_test.sh ldelema_misc_size_compat_9 valid "newarr unsigned int8" "ldc.i4.0" "bool" ./make_ldelema_test.sh ldelema_misc_size_compat_10 valid "newarr unsigned int16" "ldc.i4.0" "char" ./make_ldelema_test.sh ldelema_misc_size_compat_11 valid "newarr unsigned int32" "ldc.i4.0" "native int" ./make_ldelema_test.sh ldelema_misc_size_compat_12 valid "newarr unsigned int32" "ldc.i4.0" "native unsigned int" @@ -2804,7 +2804,7 @@ do I=`expr $I + 1` done -for ARR in "int32" "unsigned int32" "IntEnum" +for ARR in "int32" "unsigned int32" "IntEnum" do ./make_ldelem_test.sh ldelem_base_types_i_${I} valid "newarr ${ARR}" "ldc.i4.0" "ldelem.i4" ./make_ldelem_test.sh ldelem_base_types_u_${I} valid "newarr ${ARR}" "ldc.i4.0" "ldelem.u4" @@ -2876,7 +2876,7 @@ do I=`expr $I + 1` done -for ARR in "valuetype MyStruct" "int8" "bool" "unsigned int8" "int16" "char" "unsigned int16" "int32" "unsigned int32" "native int" "native unsigned int" "int64" "unsigned int64" "float32" "float64" +for ARR in "valuetype MyStruct" "int8" "bool" "unsigned int8" "int16" "char" "unsigned int16" "int32" "unsigned int32" "native int" "native unsigned int" "int64" "unsigned int64" "float32" "float64" do ./make_ldelem_test.sh ldelem_base_types_o_${I} unverifiable "newarr ${ARR}" "ldc.i4.0" "ldelem.ref" I=`expr $I + 1` @@ -3187,7 +3187,7 @@ done #object I=1 -for LOAD in "ldloc.0" "ldnull" +for LOAD in "ldloc.0" "ldnull" do ./make_cast_test.sh cast_good_obj_${I} valid "object" "$LOAD" "castclass object" ./make_cast_test.sh isinst_good_obj_${I} valid "object" "$LOAD" "isinst object" @@ -3349,7 +3349,7 @@ done #branching in the middle of an instruction ./make_branch_test.sh branch_middle_of_instruction invalid 1 "br 2"; -#branching in between prefix and instruction +#branching in between prefix and instruction ./make_branch_test.sh branch_middle_of_instruction_prefix_1 invalid 1 "br AFTER_FIRST_PREFIX"; ./make_branch_test.sh branch_middle_of_instruction_prefix_2 invalid 1 "br AFTER_SECOND_PREFIX"; @@ -3408,7 +3408,7 @@ done #regions must not overlap with each other ./make_exception_overlap_test.sh exception_entry_overlap_separate_1 valid ".try TRY_BLOCK_1 to TRY_BLOCK_1_END catch [mscorlib]System.Exception handler CATCH_BLOCK_1 to CATCH_BLOCK_1_END" ".try TRY_BLOCK_2 to TRY_BLOCK_2_END catch [mscorlib]System.Exception handler CATCH_BLOCK_2 to CATCH_BLOCK_2_END" -./make_exception_overlap_test.sh exception_entry_overlap_separate_2 valid ".try TRY_BLOCK_2 to TRY_BLOCK_2_END catch [mscorlib]System.Exception handler CATCH_BLOCK_2 to CATCH_BLOCK_2_END" ".try TRY_BLOCK_1 to TRY_BLOCK_1_END catch [mscorlib]System.Exception handler CATCH_BLOCK_1 to CATCH_BLOCK_1_END" +./make_exception_overlap_test.sh exception_entry_overlap_separate_2 valid ".try TRY_BLOCK_2 to TRY_BLOCK_2_END catch [mscorlib]System.Exception handler CATCH_BLOCK_2 to CATCH_BLOCK_2_END" ".try TRY_BLOCK_1 to TRY_BLOCK_1_END catch [mscorlib]System.Exception handler CATCH_BLOCK_1 to CATCH_BLOCK_1_END" ./make_exception_overlap_test.sh exception_entry_overlap_try_over_catch invalid ".try TRY_BLOCK_1 to CATCH_BLOCK_1_A catch [mscorlib]System.Exception handler CATCH_BLOCK_1 to CATCH_BLOCK_1_END" ".try TRY_BLOCK_2 to TRY_BLOCK_2_END catch [mscorlib]System.Exception handler CATCH_BLOCK_2 to CATCH_BLOCK_2_END" @@ -3590,7 +3590,7 @@ done #tests for ovf opcodes I=1 -for OP in "add.ovf" "add.ovf.un" "mul.ovf" "mul.ovf.un" "sub.ovf" "sub.ovf.un" +for OP in "add.ovf" "add.ovf.un" "mul.ovf" "mul.ovf.un" "sub.ovf" "sub.ovf.un" do for TYPE in "object" "string" "float32" "float64" "int32*" "typedref" "int32[]" "int32[,]" "method int32 *(int32)" do @@ -3613,8 +3613,8 @@ do I=`expr $I + 1` done done - -for OP in "add.ovf.un" "sub.ovf.un" + +for OP in "add.ovf.un" "sub.ovf.un" do for TYPE in "int32" "native int" "int32&" do @@ -3682,20 +3682,20 @@ done I=1 for TYPE in "int32" "int64" "float32" "float64" Class MyStruct string object "int32[]" "int32[,]" "native int" do - ./make_stobj_test.sh stobj_simple_${I} valid "$TYPE" "$TYPE\&" "$TYPE" + ./make_stobj_test.sh stobj_simple_${I} valid "$TYPE" "$TYPE\&" "$TYPE" I=`expr $I + 1` done for TYPE in "int32*" "method int32 *(int32)" do - ./make_stobj_test.sh stobj_simple_${I} unverifiable "$TYPE" "$TYPE\&" "$TYPE" + ./make_stobj_test.sh stobj_simple_${I} unverifiable "$TYPE" "$TYPE\&" "$TYPE" I=`expr $I + 1` done for TYPE in "int32\&" "void" "typedref" do - ./make_stobj_test.sh stobj_simple_${I} invalid "$TYPE" "$TYPE\&" "$TYPE" + ./make_stobj_test.sh stobj_simple_${I} invalid "$TYPE" "$TYPE\&" "$TYPE" I=`expr $I + 1` done @@ -3703,7 +3703,7 @@ done I=1 for TYPE in "int32\&" "int32*" "typedref" do - ./make_stobj_test.sh stobj_bad_src_${I} unverifiable "$TYPE" "int32\&" "int32" + ./make_stobj_test.sh stobj_bad_src_${I} unverifiable "$TYPE" "int32\&" "int32" I=`expr $I + 1` done @@ -3711,27 +3711,27 @@ done I=1 for TYPE in "int32" "int64" "float32" "float64" Class MyStruct string object "int32[]" "int32[,]" "native int" do - ./make_stobj_test.sh stobj_dest_not_managed_pointer_${I} unverifiable "$TYPE" "$TYPE" "$TYPE" + ./make_stobj_test.sh stobj_dest_not_managed_pointer_${I} unverifiable "$TYPE" "$TYPE" "$TYPE" I=`expr $I + 1` done #src is compat to dest I=1 for TYPE in "int8" "unsigned int8" "bool" "int16" "unsigned int16" "char" "int32" "unsigned int32" "native int" "native unsigned int" -do - ./make_stobj_test.sh stobj_src_compat_to_token_${I} valid "$TYPE" "int32\&" "int32" +do + ./make_stobj_test.sh stobj_src_compat_to_token_${I} valid "$TYPE" "int32\&" "int32" I=`expr $I + 1` done for TYPE in "int64" "unsigned int64" "float32" "float64" string object -do - ./make_stobj_test.sh stobj_src_compat_to_token_${I} unverifiable "$TYPE" "int32\&" "int32" +do + ./make_stobj_test.sh stobj_src_compat_to_token_${I} unverifiable "$TYPE" "int32\&" "int32" I=`expr $I + 1` done for TYPE in string object Class -do - ./make_stobj_test.sh stobj_src_compat_to_token_${I} valid "$TYPE" "object\&" "object" +do + ./make_stobj_test.sh stobj_src_compat_to_token_${I} valid "$TYPE" "object\&" "object" I=`expr $I + 1` done @@ -3741,8 +3741,8 @@ done #token type subtype of dest_type for TYPE in string object Class "int32[]" "int32[,]" -do - ./make_stobj_test.sh stobj_token_subtype_of_dest_${I} valid "$TYPE" "object\&" "$TYPE" +do + ./make_stobj_test.sh stobj_token_subtype_of_dest_${I} valid "$TYPE" "object\&" "$TYPE" I=`expr $I + 1` done @@ -3930,7 +3930,7 @@ done #valid types I=1 -for INIT in "ldc.i4.1" "ldc.i4.1\n\tconv.i" +for INIT in "ldc.i4.1" "ldc.i4.1\n\tconv.i" do ./make_localloc_test.sh localloc_stack_type_$I unverifiable "$INIT" I=`expr $I + 1` @@ -3944,7 +3944,7 @@ do done #stack underflow -./make_localloc_test.sh localloc_empty_stack invalid +./make_localloc_test.sh localloc_empty_stack invalid ./make_localloc_test.sh localloc_stack_with_more_than_2_items invalid "ldc.i4.1\n\tldc.i4.1" #inside exception blocks @@ -3964,7 +3964,7 @@ done #call test #invalid method token #valid -#validate the this pointer for signatures with HASTHIS. +#validate the this pointer for signatures with HASTHIS. #this ptr: reference types must be a value, value type can be a MP or a BT. #number of args #args are compatible @@ -4006,7 +4006,7 @@ done ./make_call_test.sh call_final_virtual_method_2 unverifiable "call instance void ClassC::VirtMethod()" "newobj instance void ClassA::.ctor()" ./make_call_test.sh call_final_virtual_method_3 unverifiable "call instance void ClassA::VirtMethod()" "newobj instance void ClassA::.ctor()" -./make_call_test.sh call_virtual_method_3 unverifiable "call instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" +./make_call_test.sh call_virtual_method_3 unverifiable "call instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" ./make_call_test.sh call_virtual_method_4 unverifiable "call instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarga 0\n\t\tpop" #value type (we can call non final virtual on boxed VT) @@ -4030,7 +4030,7 @@ done ./make_call_test.sh callvirt_final_virtual_method_2 unverifiable "callvirt instance void ClassC::VirtMethod()" "newobj instance void ClassA::.ctor()" ./make_call_test.sh callvirt_final_virtual_method_3 valid "callvirt instance void ClassA::VirtMethod()" "newobj instance void ClassA::.ctor()" -./make_call_test.sh callvirt_virtual_method_3 valid "callvirt instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" +./make_call_test.sh callvirt_virtual_method_3 valid "callvirt instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" ./make_call_test.sh callvirt_virtual_method_4 valid "callvirt instance void BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarga 0\n\t\tpop" #value type (we can call non final virtual on boxed VT) @@ -4227,7 +4227,7 @@ done ./make_delegate_compat_test.sh delegate_pointers_ret_1 unverifiable "object*" "string*" int32 int32 ./make_delegate_compat_test.sh delegate_pointers_ret_2 unverifiable "InterfaceA*" "ImplA*" int32 int32 -./make_delegate_compat_test.sh delegate_pointers_ret_3 unverifiable "string*" "object*" int32 int32 +./make_delegate_compat_test.sh delegate_pointers_ret_3 unverifiable "string*" "object*" int32 int32 ./make_delegate_compat_test.sh delegate_pointers_ret_4 unverifiable "int32*" "int32*" int32 int32 @@ -4278,8 +4278,8 @@ done I=1 for TYPE in "ldind.i1 int8" "ldind.u1 int8" "ldind.i2 int16" "ldind.u2 int16" "ldind.i4 int32" "ldind.u4 int32" "ldind.i8 int64" "ldind.u8 int64" "ldind.i native int" "ldind.r4 float32" "ldind.r8 float64" do - LOAD=`echo $TYPE | cut -d' ' -f 1` - TYPE=`echo $TYPE | cut -d' ' -f 2-` + LOAD=`echo $TYPE | cut -d' ' -f 1` + TYPE=`echo $TYPE | cut -d' ' -f 2-` ./make_cmmp_test.sh cmmp_basic_test_ro_$I valid "readonly. ldelema $TYPE" "$LOAD" "$TYPE" ./make_cmmp_test.sh cmmp_basic_test_ub_$I valid "unbox $TYPE" "$LOAD" "$TYPE" I=`expr $I + 1` @@ -4333,8 +4333,8 @@ done I=1 for TYPE in "stind.i1 int8" "stind.i2 int16" "stind.i4 int32" "stind.i8 int64" "stind.r4 float32" "stind.r8 float64" "stind.i native int" do - STORE=`echo $TYPE | cut -d' ' -f 1` - TYPE=`echo $TYPE | cut -d' ' -f 2-` + STORE=`echo $TYPE | cut -d' ' -f 1` + TYPE=`echo $TYPE | cut -d' ' -f 2-` ./make_cmmp_test.sh cmmp_bad_ops_test_ro_$I unverifiable "readonly. ldelema $TYPE" "ldloc.0\n\t$STORE" "$TYPE" ./make_cmmp_test.sh cmmp_bad_ops_test_ub_$I unverifiable "unbox $TYPE" "ldloc.0\n\t$STORE" "$TYPE" I=`expr $I + 1` @@ -4667,7 +4667,7 @@ do I=`expr $I + 1` done -for TYPE in object ClassNoDefaultCtor AbstractClass ClassWithDefaultCtorNotVisible ClassWithDefaultCtor "valuetype MyValueType" "valuetype [mscorlib]System.Nullable\`1" "[mscorlib]System.ValueType" "[mscorlib]System.Enum" IFace IFaceImpl +for TYPE in object ClassNoDefaultCtor AbstractClass ClassWithDefaultCtorNotVisible ClassWithDefaultCtor "valuetype MyValueType" "valuetype [mscorlib]System.Nullable\`1" "[mscorlib]System.ValueType" "[mscorlib]System.Enum" IFace IFaceImpl do ./make_type_constraint_test.sh type_constraint_system_enum_ctor_ct_$I invalid "$TYPE" ".ctor (class [mscorlib]System.Enum)" ./make_type_constraint_test.sh type_constraint_system_enum_vt_ct_$I invalid "$TYPE" "valuetype (class [mscorlib]System.Enum)" @@ -4761,8 +4761,8 @@ done I=1 for TYPE in "stind.i1 int8" "stind.i2 int16" "stind.i4 int32" "stind.i8 int64" "stind.r4 float32" "stind.r8 float64" "stind.i native int" do - STORE=`echo $TYPE | cut -d' ' -f 1` - TYPE=`echo $TYPE | cut -d' ' -f 2-` + STORE=`echo $TYPE | cut -d' ' -f 1` + TYPE=`echo $TYPE | cut -d' ' -f 2-` ./make_prefix_test.sh "prefix_test_stind_volatile_$I" valid "volatile. $STORE" "ldloca 0\n\tldloc.0" "$TYPE" ./make_prefix_test.sh "prefix_test_stind_unaligned_$I" valid "unaligned. 1 $STORE" "ldloca 0\n\tldloc.0" "$TYPE" I=`expr $I + 1` @@ -4776,8 +4776,8 @@ done I=1 for TYPE in "ldind.i1 int8" "ldind.u1 unsigned int8" "ldind.i2 int16" "ldind.u2 unsigned int16" "ldind.i4 int32" "ldind.u4 unsigned int32" "ldind.i8 int64" "ldind.u8 unsigned int64" "ldind.r4 float32" "ldind.r8 float64" "ldind.i native int" do - STORE=`echo $TYPE | cut -d' ' -f 1` - TYPE=`echo $TYPE | cut -d' ' -f 2-` + STORE=`echo $TYPE | cut -d' ' -f 1` + TYPE=`echo $TYPE | cut -d' ' -f 2-` ./make_prefix_test.sh "prefix_test_ldind_volatile_$I" valid "volatile. $STORE" "ldloca 0" "$TYPE" ./make_prefix_test.sh "prefix_test_ldind_unaligned_$I" valid "unaligned. 1 $STORE" "ldloca 0" "$TYPE" I=`expr $I + 1` @@ -5133,7 +5133,7 @@ done ./make_generic_argument_constraints_test.sh no_constraints valid "" "" I=1 -for SRC in "(IfaceA)" "(IfaceB)" "(IfaceA, IfaceB)" ".ctor" "class" +for SRC in "(IfaceA)" "(IfaceB)" "(IfaceA, IfaceB)" ".ctor" "class" do ./make_generic_argument_constraints_test.sh src_ctrs_only_${I} unverifiable "$SRC" "" I=`expr $I + 1` diff --git a/src/mono/mono/tests/verifier/make_throw_test.sh b/src/mono/mono/tests/verifier/make_throw_test.sh index fb39d08fec29..d4d6eb466a1f 100755 --- a/src/mono/mono/tests/verifier/make_throw_test.sh +++ b/src/mono/mono/tests/verifier/make_throw_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -16,7 +16,7 @@ TEST_FILE=${TEST_NAME}_generated.il echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/LOCAL/${TEST_LOCAL}/g" -e "s/OP/${TEST_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -17,7 +17,7 @@ echo $TEST_FILE $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/INSTANTIATION/${TEST_INSTANTIATION}/g" -e "s/CONSTRAINTS/${TEST_CONSTRAINTS}/g" -e "s/EXTRA_CODE/${TEST_EXTRA_CODE}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -12,7 +12,7 @@ TEST_INIT=$4 TEST_EXTRA_LOC=$5 -if [ "$TEST_EXTRA_LOC" != "" ]; then +if [ -n "$TEST_EXTRA_LOC" ]; then EXTRA_LOC=", $TEST_EXTRA_LOC V_1" fi @@ -22,7 +22,7 @@ echo $TEST_FILE TEST_TYPE=`echo $TEST_TYPE | $SED -s 's/&/\\\&/'` $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE/${TEST_TYPE}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/INIT/${TEST_INIT}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -15,7 +15,7 @@ echo $TEST_FILE TEST_TYPE1=`echo $TEST_TYPE1 | $SED -s 's/&/\\\&/'` $SED -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/LOAD_OPCODE/${TEST_LOAD_OP}/g" > $TEST_FILE < /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -91,7 +91,7 @@ $SED -e "s/INIT_OP/${TEST_INIT}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VALIDITY/ END: ldc.i4.0 - ret + ret } //EOF diff --git a/src/mono/mono/tests/verifier/make_unbox_test.sh b/src/mono/mono/tests/verifier/make_unbox_test.sh index 744e931a2a9a..9d48d4920807 100755 --- a/src/mono/mono/tests/verifier/make_unbox_test.sh +++ b/src/mono/mono/tests/verifier/make_unbox_test.sh @@ -1,7 +1,7 @@ #! /bin/sh SED="sed" -if [ `which gsed 2> /dev/null` ] ; then +if [ `which gsed 2> /dev/null` ]; then SED="gsed" fi @@ -84,7 +84,7 @@ $SED -e "s/BOX_OP/${TEST_BOX}/g" -e "s/TYPE1/${TEST_TYPE1}/g" -e "s/VALIDITY/${ POST_OP pop ldc.i4.0 - ret + ret } //EOF diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.sh b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.sh index 66f889350dd4..7965b1023017 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.sh +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/data/RunScriptTemplate.sh @@ -4,13 +4,13 @@ EXECUTION_DIR=$(dirname $0) cd $EXECUTION_DIR -if [ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]; then +if [[ -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then XHARNESS_OUT="$EXECUTION_DIR/xharness-output" else XHARNESS_OUT="$HELIX_WORKITEM_UPLOAD_ROOT/xharness-output" fi -if [ ! -z "$XHARNESS_CLI_PATH" ]; then +if [[ -n "$XHARNESS_CLI_PATH" ]]; then # When running in CI, we only have the .NET runtime available # We need to call the XHarness CLI DLL directly via dotnet exec HARNESS_RUNNER="dotnet exec $XHARNESS_CLI_PATH" @@ -25,7 +25,7 @@ function set_env_vars() export SDK_HAS_WORKLOAD_INSTALLED=true export SDK_FOR_WORKLOAD_TESTING_PATH=$BASE_DIR/dotnet-workload export AppRefDir=$BASE_DIR/microsoft.netcore.app.ref - elif [ ! -z "$HELIX_WORKITEM_UPLOAD_ROOT" ]; then + elif [[ -n "$HELIX_WORKITEM_UPLOAD_ROOT" ]]; then export WasmBuildSupportDir=$BASE_DIR/build else export PATH=$BASE_DIR/sdk-no-workload:$PATH diff --git a/src/tests/Common/Directory.Build.targets b/src/tests/Common/Directory.Build.targets index 90af5047694e..6a76e5f958d2 100644 --- a/src/tests/Common/Directory.Build.targets +++ b/src/tests/Common/Directory.Build.targets @@ -172,7 +172,12 @@ - + + + <_FixedRuntimeCopyLocalItems Include="@(RuntimeCopyLocalItems)" /> + <_FixedRuntimeCopyLocalItems Remove="@(_FixedRuntimeCopyLocalItems)" Condition="'%(Filename)' == 'Microsoft.Interop.DllImportGenerator'" /> + + : Runs the tests with COMPlus_JitStress=n' echo ' --jitstressregs= : Runs the tests with COMPlus_JitStressRegs=n' echo ' --jitminopts : Runs the tests with COMPlus_JITMinOpts=1' @@ -173,11 +173,11 @@ function xunit_output_add_test { line="${line} type=\"${testDir}\"" line="${line} method=\"${testName}\"" line="${line} result=\"${testResult}\"" - if [ -n "$testRunningTime" ] && [ "$testResult" != "Skip" ]; then + if [[ -n "$testRunningTime" && "$testResult" != "Skip" ]]; then line="${line} time=\"${testRunningTime}\"" fi - if [ "$testResult" == "Pass" ]; then + if [[ "$testResult" == "Pass" ]]; then line="${line}/>" echo "$line" >>"$xunitTestOutputPath" return @@ -187,7 +187,7 @@ function xunit_output_add_test { echo "$line" >>"$xunitTestOutputPath" line=" " - if [ "$testResult" == "Skip" ]; then + if [[ "$testResult" == "Skip" ]]; then line="${line}" echo "$line" >>"$xunitTestOutputPath" else @@ -341,9 +341,9 @@ function text_file_output_add_test { local scriptFilePath=$1 local testResult=$2 # Pass, Fail, or Skip - if [ "$testResult" == "Pass" ]; then + if [[ "$testResult" == "Pass" ]]; then echo "$scriptFilePath" >>"$testsPassOutputPath" - elif [ "$testResult" == "Skip" ]; then + elif [[ "$testResult" == "Skip" ]]; then echo "$scriptFilePath" >>"$testsSkipOutputPath" else echo "$scriptFilePath" >>"$testsFailOutputPath" @@ -438,7 +438,7 @@ declare -a skipCrossGenFiles function is_skip_crossgen_test { for skip in "${skipCrossGenFiles[@]}"; do - if [ "$1" == "$skip" ]; then + if [[ "$1" == "$skip" ]]; then return 0 fi done @@ -448,17 +448,17 @@ function is_skip_crossgen_test { function precompile_overlay_assemblies { skipCrossGenFiles=($(read_array "$(dirname "$0")/skipCrossGenFiles.$ARCH.txt")) - if [ $doCrossgen == 1 ]; then + if [[ "$doCrossgen" == 1 ]]; then local overlayDir=$CORE_ROOT filesToPrecompile=$(find -L $overlayDir -iname \*.dll -not -iname \*.ni.dll -not -iname \*-ms-win-\* -type f ) for fileToPrecompile in ${filesToPrecompile} do local filename=${fileToPrecompile} - if [ $jitdisasm == 1 ]; then + if [[ "$jitdisasm" == 1 ]]; then $overlayDir/corerun $overlayDir/jit-dasm.dll --crossgen $overlayDir/crossgen --platform $overlayDir --output $testRootDir/dasm $filename local exitCode=$? - if [ $exitCode != 0 ]; then + if [[ "$exitCode" != 0 ]]; then echo Unable to generate dasm for $filename fi else @@ -551,7 +551,7 @@ function load_playlist_tests { function is_unsupported_test { for unsupportedTest in "${unsupportedTests[@]}"; do - if [ "$1" == "$unsupportedTest" ]; then + if [[ "$1" == "$unsupportedTest" ]]; then return 0 fi done @@ -560,7 +560,7 @@ function is_unsupported_test { function is_failing_test { for failingTest in "${failingTests[@]}"; do - if [ "$1" == "$failingTest" ]; then + if [[ "$1" == "$failingTest" ]]; then return 0 fi done @@ -569,7 +569,7 @@ function is_failing_test { function is_playlist_test { for playlistTest in "${playlistTests[@]}"; do - if [ "$1" == "$playlistTest" ]; then + if [[ "$1" == "$playlistTest" ]]; then return 0 fi done @@ -625,7 +625,7 @@ function set_up_core_dump_generation { # Allow dump generation ulimit -c unlimited - if [ "$(uname -s)" == "Linux" ]; then + if [[ "$(uname -s)" == "Linux" ]]; then if [ -e /proc/self/coredump_filter ]; then # Include memory in private and shared file-backed mappings in the dump. # This ensures that we can see disassembly from our shared libraries when @@ -638,7 +638,7 @@ function set_up_core_dump_generation { function print_info_from_core_file { #### temporary - if [ "$ARCH" == "arm64" ]; then + if [[ "$ARCH" == "arm64" ]]; then echo "Not inspecting core dumps on arm64 at the moment." return fi @@ -675,19 +675,19 @@ function print_info_from_core_file { function inspect_and_delete_core_files { # This function prints some basic information from core files in the current # directory and deletes them immediately. - + # Depending on distro/configuration, the core files may either be named "core" - # or "core." by default. We will read /proc/sys/kernel/core_uses_pid to + # or "core." by default. We will read /proc/sys/kernel/core_uses_pid to # determine which one it is. # On OS X/macOS, we checked the kern.corefile value before enabling core dump # generation, so we know it always includes the PID. local core_name_uses_pid=0 - if [[ (( -e /proc/sys/kernel/core_uses_pid ) && ( "1" == $(cat /proc/sys/kernel/core_uses_pid) )) + if [[ (( -e /proc/sys/kernel/core_uses_pid ) && ( "1" == $(cat /proc/sys/kernel/core_uses_pid) )) || ( "$(uname -s)" == "Darwin" ) ]]; then core_name_uses_pid=1 fi - if [ $core_name_uses_pid == "1" ]; then + if [[ "$core_name_uses_pid" == "1" ]]; then # We don't know what the PID of the process was, so let's look at all core # files whose name matches core.NUMBER for f in core.*; do @@ -711,7 +711,7 @@ function run_test { local scriptFileName=$(basename "$scriptFilePath") local outputFileName=$(basename "$outputFilePath") - if [ "$limitedCoreDumps" == "ON" ]; then + if [[ "$limitedCoreDumps" == "ON" ]]; then set_up_core_dump_generation fi @@ -720,7 +720,7 @@ function run_test { # We will try to print some information from generated core dumps if a debugger # is available, and possibly store a dump in a non-transient location. - if [ "$limitedCoreDumps" == "ON" ]; then + if [[ "$limitedCoreDumps" == "ON" ]]; then inspect_and_delete_core_files fi @@ -757,7 +757,7 @@ function waitany { while true; do for (( i=0; i<$maxProcesses; i++ )); do pid=${processIds[$i]} - if [ -z "$pid" ] || [ "$pid" == "$pidNone" ]; then + if [[ -z "$pid" || "$pid" == "$pidNone" ]]; then continue fi if ! kill -0 $pid 2>/dev/null; then @@ -777,7 +777,7 @@ function get_available_process_index { local i=0 for (( i=0; i<$maxProcesses; i++ )); do pid=${processIds[$i]} - if [ -z "$pid" ] || [ "$pid" == "$pidNone" ]; then + if [[ -z "$pid" || "$pid" == "$pidNone" ]]; then break fi done @@ -802,7 +802,7 @@ function finish_test { header=$(printf "[%4d]" $countTotalTests) fi - if [ "$showTime" == "ON" ]; then + if [[ "$showTime" == "ON" ]]; then testEndTime=$(date +%s) testRunningTime=$(( $testEndTime - ${testStartTimes[$finishedProcessIndex]} )) header=$header$(printf "[%4ds]" $testRunningTime) @@ -853,13 +853,13 @@ function prep_test { local scriptFilePath=$1 local scriptFileDir=$(dirname "$scriptFilePath") - test "$verbose" == 1 && echo "Preparing $scriptFilePath" + test "$verbose" = 1 && echo "Preparing $scriptFilePath" - if [ ! "$noLFConversion" == "ON" ]; then + if [[ "$noLFConversion" != "ON" ]]; then # Convert DOS line endings to Unix if needed perl -pi -e 's/\r\n|\n|\r/\n/g' "$scriptFilePath" fi - + # Add executable file mode bit if needed chmod +x "$scriptFilePath" @@ -891,11 +891,11 @@ function start_test { local outputFilePath=$(dirname "$scriptFilePath")/${scriptFileName}.out outputFilePaths[$nextProcessIndex]=$outputFilePath - if [ "$showTime" == "ON" ]; then + if [[ "$showTime" == "ON" ]]; then testStartTimes[$nextProcessIndex]=$(date +%s) fi - test "$verbose" == 1 && echo "Starting $scriptFilePath" + test "$verbose" = 1 && echo "Starting $scriptFilePath" if is_unsupported_test "$scriptFilePath"; then skip_unsupported_test "$scriptFilePath" "$outputFilePath" & elif ((runFailingTestsOnly == 0)) && is_failing_test "$scriptFilePath"; then @@ -1136,10 +1136,10 @@ do ;; --test-env=*) testEnv=${i#*=} - ;; + ;; --gcstresslevel=*) export COMPlus_GCStress=${i#*=} - ;; + ;; --gcname=*) export COMPlus_GCName=${i#*=} ;; @@ -1166,7 +1166,7 @@ do esac done -if [ -n "$coreOverlayDir" ] && [ "$buildOverlayOnly" == "ON" ]; then +if [[ -n "$coreOverlayDir" && "$buildOverlayOnly" == "ON" ]]; then echo "Can not use \'--coreOverlayDir=\' and \'--build-overlay-only\' at the same time." exit $EXIT_CODE_EXCEPTION fi @@ -1189,36 +1189,36 @@ fi # Copy native interop test libraries over to the mscorlib path in # order for interop tests to run on linux. -if [ -z "$mscorlibDir" ]; then +if [[ -z "$mscorlibDir" ]]; then mscorlibDir=$coreClrBinDir fi -if [ ! -z "$longgc" ]; then +if [[ -n "$longgc" ]]; then echo "Running Long GC tests" export RunningLongGCTests=1 fi -if [ ! -z "$gcsimulator" ]; then +if [[ -n "$gcsimulator" ]]; then echo "Running GC simulator tests" export RunningGCSimulatorTests=1 fi -if [[ ! "$jitdisasm" -eq 0 ]]; then +if [[ "$jitdisasm" -ne 0 ]]; then echo "Running jit disasm" export RunningJitDisasm=1 fi -if [ ! -z "$ilasmroundtrip" ]; then +if [[ -n "$ilasmroundtrip" ]]; then echo "Running Ilasm round trip" export RunningIlasmRoundTrip=1 fi # If this is a coverage run, make sure the appropriate args have been passed -if [ "$CoreClrCoverage" == "ON" ] +if [[ "$CoreClrCoverage" == "ON" ]] then echo "Code coverage is enabled for this run" echo "" - if [ ! "$OSName" == "Darwin" ] && [ ! "$OSName" == "Linux" ] + if [[ "$OSName" != "Darwin" && "$OSName" != "Linux" ]] then echo "Code Coverage not supported on $OS" exit 1 @@ -1251,7 +1251,7 @@ text_file_output_begin create_core_overlay precompile_overlay_assemblies -if [ "$buildOverlayOnly" == "ON" ]; +if [[ "$buildOverlayOnly" == "ON" ]]; then echo "Build overlay directory '$coreOverlayDir' complete." exit 0 @@ -1302,7 +1302,7 @@ echo "$(($time_diff / 60)) minutes and $(($time_diff % 60)) seconds taken to run xunit_output_end -if [ "$CoreClrCoverage" == "ON" ] +if [[ "$CoreClrCoverage" == "ON" ]] then coreclr_code_coverage fi diff --git a/src/tests/Common/scripts/build_illink.sh b/src/tests/Common/scripts/build_illink.sh index 26fae14bc7a2..ec24b72c3b27 100755 --- a/src/tests/Common/scripts/build_illink.sh +++ b/src/tests/Common/scripts/build_illink.sh @@ -25,19 +25,19 @@ do print_usage exit $EXIT_CODE_SUCCESS ;; - + --clone) clone=1 ;; - + --arch=*) arch=${i#*=} ;; - + --os=*) os=${i#*=} ;; - + *) echo "Unknown switch: $i" print_usage @@ -48,7 +48,7 @@ done rid="$os-$arch" -if [ ! -z "$clone" ]; then +if [[ -n "$clone" ]]; then git clone --recursive https://github.com/mono/linker fi diff --git a/src/tests/Common/scripts/run-corefx-tests.sh b/src/tests/Common/scripts/run-corefx-tests.sh index 39a87d03834d..13c274599b35 100755 --- a/src/tests/Common/scripts/run-corefx-tests.sh +++ b/src/tests/Common/scripts/run-corefx-tests.sh @@ -95,7 +95,7 @@ esac CPUName=$(uname -p) # Some Linux platforms report unknown for platform, but the arch for machine. -if [ "$CPUName" == "unknown" ]; then +if [[ "$CPUName" == "unknown" ]]; then CPUName=$(uname -m) fi @@ -147,7 +147,7 @@ function waitany { while true; do for (( i=0; i<$maxProcesses; i++ )); do pid=${processIds[$i]} - if [ -z "$pid" ] || [ "$pid" == "$pidNone" ]; then + if [[ -z "$pid" || "$pid" == "$pidNone" ]]; then continue fi if ! kill -0 $pid 2>/dev/null; then @@ -167,7 +167,7 @@ function get_available_process_index { local i=0 for (( i=0; i<$maxProcesses; i++ )); do pid=${processIds[$i]} - if [ -z "$pid" ] || [ "$pid" == "$pidNone" ]; then + if [[ -z "$pid" || "$pid" == "$pidNone" ]]; then break fi done @@ -189,7 +189,7 @@ function finish_test { cat ${outputFilePath} echo "<<<<<" - if [ $testScriptExitCode -ne 0 ] ; then + if [ $testScriptExitCode -ne 0 ]; then failedTests[$countFailedTests]=$testProject countFailedTests=$(($countFailedTests+1)) else @@ -266,7 +266,7 @@ function summarize_test_run { echo "# Failed : $countFailedTests" echo "=======================" - if [ $countFailedTests -gt 0 ] ; then + if [ $countFailedTests -gt 0 ]; then echo echo "===== Failed tests:" for (( i=0; i<$countFailedTests; i++ )); do @@ -336,7 +336,7 @@ run_test() ${TimeoutTool}./RunTests.sh --runtime-path "$Runtime" --rsp-file "$ExclusionRspFile" exitCode=$? - if [ $exitCode -ne 0 ] ; then + if [ $exitCode -ne 0 ]; then echo "error: One or more tests failed while running tests from '$fileNameWithoutExtension'. Exit code $exitCode." fi @@ -346,12 +346,12 @@ run_test() coreclr_code_coverage() { - if [ "$OS" != "FreeBSD" ] && [ "$OS" != "Linux" ] && [ "$OS" != "NetBSD" ] && [ "$OS" != "OSX" ] && [ "$OS" != "SunOS" ] ; then + if [[ "$OS" != "FreeBSD" && "$OS" != "Linux" && "$OS" != "NetBSD" && "$OS" != "OSX" && "$OS" != "SunOS" ]]; then echo "error: Code Coverage not supported on $OS" exit 1 fi - if [ "$CoreClrSrc" == "" ] ; then + if [[ -z "$CoreClrSrc" ]]; then echo "error: Coreclr source files are required to generate code coverage reports" echo "Coreclr source files root path can be passed using '--coreclr-src' argument" exit 1 @@ -487,26 +487,22 @@ done # Compute paths to the binaries if they haven't already been computed -if [ "$Runtime" == "" ] -then +if [[ -z "$Runtime" ]]; then Runtime="$ProjectRoot/bin/testhost/netcoreapp-$OS-$Configuration-$__Arch" fi -if [ "$CoreFxTests" == "" ] -then +if [[ -z "$CoreFxTests" ]]; then CoreFxTests="$ProjectRoot/bin" fi # Check parameters up front for valid values: -if [ ! "$Configuration" == "Debug" ] && [ ! "$Configuration" == "Release" ] -then +if [[ "$Configuration" != "Debug" && "$Configuration" != "Release" ]]; then echo "error: Configuration should be Debug or Release" exit 1 fi -if [ "$OS" != "FreeBSD" ] && [ "$OS" != "Linux" ] && [ "$OS" != "NetBSD" ] && [ "$OS" != "OSX" ] && [ "$OS" != "SunOS" ] -then +if [[ "$OS" != "FreeBSD" && "$OS" != "Linux" && "$OS" != "NetBSD" && "$OS" != "OSX" && "$OS" != "SunOS" ]]; then echo "error: OS should be FreeBSD, Linux, NetBSD, OSX or SunOS" exit 1 fi @@ -514,8 +510,7 @@ fi export CORECLR_SERVER_GC="$serverGC" export PAL_OUTPUTDEBUGSTRING="1" -if [ "$LANG" == "" ] -then +if [[ -z "$LANG" ]]; then export LANG="en_US.UTF-8" fi @@ -551,15 +546,13 @@ if [ $RunTestSequential -eq 1 ]; then maxProcesses=1 fi -if [ -n "$TestDirFile" ] || [ -n "$TestDir" ] -then +if [[ -n "$TestDirFile" || -n "$TestDir" ]]; then run_selected_tests else run_all_tests "$CoreFxTests/tests/"*.Tests fi -if [ "$CoreClrCoverage" == "ON" ] -then +if [[ "$CoreClrCoverage" == "ON" ]]; then coreclr_code_coverage fi diff --git a/src/tests/Common/scripts/run-gc-reliability-framework.sh b/src/tests/Common/scripts/run-gc-reliability-framework.sh index c136c1561ec9..c634fbbb1142 100755 --- a/src/tests/Common/scripts/run-gc-reliability-framework.sh +++ b/src/tests/Common/scripts/run-gc-reliability-framework.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash OSName=$(uname -s) case $OSName in diff --git a/src/tests/Common/scripts/runincontext.sh b/src/tests/Common/scripts/runincontext.sh index 8e36564e0db8..991d1805ed2d 100755 --- a/src/tests/Common/scripts/runincontext.sh +++ b/src/tests/Common/scripts/runincontext.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + # This script is a bridge that allows .cmd files of individual tests to run the respective test executables # in an unloadable AssemblyLoadContext. # diff --git a/src/tests/Common/scripts/tieringtest.sh b/src/tests/Common/scripts/tieringtest.sh index c6f6a3f27682..f43221313249 100644 --- a/src/tests/Common/scripts/tieringtest.sh +++ b/src/tests/Common/scripts/tieringtest.sh @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + # This script is a bridge that allows .cmd files of individual tests to run the respective test executables # repeatedly so that more methods get rejitted at Tier1 # diff --git a/src/tests/Common/scripts/x86_ci_script.sh b/src/tests/Common/scripts/x86_ci_script.sh index fa39c530bde1..1a6832d894ae 100755 --- a/src/tests/Common/scripts/x86_ci_script.sh +++ b/src/tests/Common/scripts/x86_ci_script.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash #Parse command line arguments __buildConfig= @@ -17,7 +17,7 @@ do done #Check if there are any uncommited changes in the source directory as git adds and removes patches -if [[ $(git status -s) != "" ]]; then +if [[ -n $(git status -s) ]]; then echo 'ERROR: There are some uncommited changes. To avoid losing these changes commit them and try again.' echo '' git status diff --git a/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.cs b/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.cs new file mode 100644 index 000000000000..981e310f1a9b --- /dev/null +++ b/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.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. +// +// Note: This test case is found by Antigen. It catches a scenario where we were not accounting +// for total loop candidates to align. +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +public class TestClass_Loops +{ + public struct S1 + { + public struct S1_D1_F1 + { + public decimal decimal_0; + } + public long long_1; + } + public struct S2 + { + public decimal decimal_2; + } + static byte s_byte_4 = 1; + static decimal s_decimal_6 = 5.1428571428571428571428571429m; + static short s_short_8 = 5; + static sbyte s_sbyte_11 = -1; + static ulong s_ulong_16 = 2; + static S1.S1_D1_F1 s_s1_s1_d1_f1_17 = new S1.S1_D1_F1(); + static S1 s_s1_18 = new S1(); + static S2 s_s2_19 = new S2(); + byte byte_21 = 5; + decimal decimal_23 = -1.987654320987654320987654321m; + short short_25 = 0; + long long_27 = 5; + float float_29 = -0.9423077f; + S1 s1_35 = new S1(); + S2 s2_36 = new S2(); + + [MethodImpl(MethodImplOptions.NoInlining)] + public decimal LeafMethod3() + { + return 0.5m; + } + + public float LeafMethod9() + { + return 0.5f; + } + + public uint LeafMethod12() + { + return 1; + } + + public ulong Method18(S2 p_s2_492, ref decimal p_decimal_493, out uint p_uint_494, ref float p_float_495, ref int p_int_496, short p_short_497, out uint p_uint_498, ref S1 p_s1_499) + { + p_uint_498 = (uint)10; + p_uint_494=0; + return 5; + } + + public float Method21(ref S1 p_s1_565, ref byte p_byte_566, S2 p_s2_567, ref S1 p_s1_568, ref S1.S1_D1_F1 p_s1_s1_d1_f1_569, S1 p_s1_570, out S1.S1_D1_F1 p_s1_s1_d1_f1_571, ref S2 p_s2_572) + { + p_s1_s1_d1_f1_571 = s_s1_s1_d1_f1_17; + return -4.928571f; + } + + public S2 Method35(ref S1 p_s1_952, ref sbyte p_sbyte_953, ref S1.S1_D1_F1 p_s1_s1_d1_f1_954) + { + unchecked + { + S2 s2_971 = new S2(); + return s2_36; + } + } + + public S1 Method60(ref decimal p_decimal_1639, out float p_float_1640, ref byte p_byte_1641, out S2 p_s2_1642, S1.S1_D1_F1 p_s1_s1_d1_f1_1643, ref S1 p_s1_1644, out S2 p_s2_1645, S2 p_s2_1646, ref ulong p_ulong_1647, out ulong p_ulong_1648, ref S2 p_s2_1649, out S2 p_s2_1650) + { + unchecked + { + char char_1653 = '5'; + decimal decimal_1654 = 5.0333333333333333333333333333m; + double double_1655 = 1; + short short_1656 = 1; + int int_1657 = -1; + float float_1660 = 5.090909f; + uint uint_1663 = 5; + S1.S1_D1_F1 s1_s1_d1_f1_1665 = new S1.S1_D1_F1(); + S1 s1_1666 = new S1(); + S2 s2_1667 = new S2(); + S2 s2_1668 = s2_1667; + p_float_1640 = ((float)(((float)(float_1660 /= ((float)((((float)(float_29 - ((float)(LeafMethod9() * float_1660))))) + 89)))) % ((float)((Method21(ref s1_35, ref s_byte_4, s_s2_19, ref s1_35, ref p_s1_s1_d1_f1_1643, s_s1_18, out s_s1_s1_d1_f1_17, ref s2_1667)) + 45)))); + p_s2_1642 = s2_36; + p_s2_1645 = s_s2_19; + p_ulong_1648 = Method18(s2_36, ref decimal_23, out uint_1663, ref p_float_1640, ref int_1657, ((short)(short_1656 % ((short)((((short)(short_25 - s_short_8))) + 35)))), out uint_1663, ref s_s1_18); + p_s2_1650 = s2_36; + switch (((char)(char_1653 = 'M'))) + { + case 'Y': + { + S1 s1_1669 = s_s1_18; + break; + } + case 'I': + { + break; + } + case 'J': + { + long_27 >>= int_1657; + s1_s1_d1_f1_1665.decimal_0 %= ((decimal)((((decimal)(((decimal)(s_s2_19.decimal_2 += ((decimal)(((decimal)(decimal_1654 - -1.9841269841269841269841269841m)) + ((decimal)(s_decimal_6 *= s2_1668.decimal_2)))))) * ((decimal)(s_s2_19.decimal_2 *= ((decimal)(s2_36.decimal_2 += ((decimal)(LeafMethod3() + LeafMethod3()))))))))) + 40)); + break; + } + default: + { + Method35(ref s1_35, ref s_sbyte_11, ref s_s1_s1_d1_f1_17); + break; + } + } + return p_s1_1644; + } + } + + public void Method0() + { + unchecked + { + ulong ulong_2733 = 37; + S1.S1_D1_F1 s1_s1_d1_f1_2734 = new S1.S1_D1_F1(); + S1 s1_2735 = new S1(); + S1 s1_2736 = s1_2735; + S2 s2_2737 = new S2(); + s_s1_18 = Method60(ref s2_2737.decimal_2, out float_29, ref byte_21, out s_s2_19, s1_s1_d1_f1_2734, ref s_s1_18, out s_s2_19, s2_2737, ref ulong_2733, out s_ulong_16, ref s2_2737, out s2_2737); + return; + } + } + public static void Main(string[] args) + { + new TestClass_Loops().Method0(); + } +} \ No newline at end of file diff --git a/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.csproj b/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.csproj new file mode 100644 index 000000000000..827af187c657 --- /dev/null +++ b/src/tests/JIT/Directed/LoopAlignment/LoopsToProcess.csproj @@ -0,0 +1,22 @@ + + + Exe + 1 + + + True + + + + + + + + + diff --git a/src/tests/JIT/Directed/debugging/debuginfo/tester.cs b/src/tests/JIT/Directed/debugging/debuginfo/tester.cs index 6f501c96f002..b784fd4a6f56 100644 --- a/src/tests/JIT/Directed/debugging/debuginfo/tester.cs +++ b/src/tests/JIT/Directed/debugging/debuginfo/tester.cs @@ -64,6 +64,9 @@ private static Func ValidateMappings(EventPipeEventSource source) source.Clr.MethodLoadVerbose += e => methodTier[e.MethodID] = e.OptimizationTier; source.Clr.MethodILToNativeMap += e => { + if (e.MethodID == 0) + return; + var mappings = new (int, int)[e.CountOfMapEntries]; for (int i = 0; i < mappings.Length; i++) mappings[i] = (e.ILOffset(i), e.NativeOffset(i)); diff --git a/src/tests/JIT/Directed/debugging/debuginfo/tester.csproj b/src/tests/JIT/Directed/debugging/debuginfo/tester.csproj index f3501e7c7987..2545e6ceb3c2 100644 --- a/src/tests/JIT/Directed/debugging/debuginfo/tester.csproj +++ b/src/tests/JIT/Directed/debugging/debuginfo/tester.csproj @@ -4,6 +4,8 @@ PdbOnly True True + true + true diff --git a/src/tests/JIT/Directed/debugging/debuginfo/tests.il b/src/tests/JIT/Directed/debugging/debuginfo/tests.il index 3af18c10d2ae..9f6dbfa8a582 100644 --- a/src/tests/JIT/Directed/debugging/debuginfo/tests.il +++ b/src/tests/JIT/Directed/debugging/debuginfo/tests.il @@ -57,7 +57,7 @@ { .custom instance void [attribute]ExpectedILMappings::.ctor() = { property int32[] Debug = int32[2]( 0 6 ) - // property int32[] Opts = int32[2]( 0 6 ) // Currently the 6 will not get a mapping due to a bug + property int32[] Opts = int32[2]( 0 6 ) } .maxstack 2 .locals init (int32 V_0) @@ -97,8 +97,7 @@ // as this is used for the managed-ret-val feature, but the debugger filters out these mappings and does not // report them in the ETW event. We should probably change this, those mappings should be useful in any case. property int32[] Debug = int32[10]( 0x0 0x6 0xe 0x12 0x1a 0x1c 0x24 0x28 0x2c 0x34 ) - // some entries commented due to a bug with some failing inline candidates - property int32[] Opts = int32[3]( 0x0 0x6 /* 0x12 */ 0x1c /* 0x2c */ ) + property int32[] Opts = int32[5]( 0x0 0x6 0x12 0x1c 0x2c ) } .maxstack 2 .locals init (int32 V_0) diff --git a/src/tests/JIT/superpmi/collect_alltests.sh b/src/tests/JIT/superpmi/collect_alltests.sh index 581b1e45b057..72a839b1849e 100644 --- a/src/tests/JIT/superpmi/collect_alltests.sh +++ b/src/tests/JIT/superpmi/collect_alltests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash CORECLRROOT=~/src/coreclr TESTROOT=~/test diff --git a/src/tests/JIT/superpmi/runtests.sh b/src/tests/JIT/superpmi/runtests.sh index 35cb82432cc7..81ea1713e6f9 100644 --- a/src/tests/JIT/superpmi/runtests.sh +++ b/src/tests/JIT/superpmi/runtests.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Run CoreCLR OSS tests on Linux or Mac # Use the instructions here: diff --git a/src/tests/run.sh b/src/tests/run.sh index 0c95c4084ac6..ea6bff6fcb77 100755 --- a/src/tests/run.sh +++ b/src/tests/run.sh @@ -185,10 +185,10 @@ do ;; --test-env=*) testEnv=${i#*=} - ;; + ;; --gcstresslevel=*) export COMPlus_GCStress=${i#*=} - ;; + ;; --gcname=*) export COMPlus_GCName=${i#*=} ;; @@ -240,30 +240,30 @@ fi if [ "$buildOS" = "Android" ]; then runtestPyArguments+=("-os" "Android") fi - -if [ ! -z "$testRootDir" ]; then + +if [[ -n "$testRootDir" ]]; then runtestPyArguments+=("-test_location" "$testRootDir") echo "Test Location : ${testRootDir}" fi -if [ ! -z "${testEnv}" ]; then +if [[ -n "${testEnv}" ]]; then runtestPyArguments+=("-test_env" "${testEnv}") echo "Test Env : ${testEnv}" fi echo "" -if [ ! -z "$longgc" ]; then +if [[ -n "$longgc" ]]; then echo "Running Long GC tests" runtestPyArguments+=("--long_gc") fi -if [ ! -z "$gcsimulator" ]; then +if [[ -n "$gcsimulator" ]]; then echo "Running GC simulator tests" runtestPyArguments+=("--gcsimulator") fi -if [ ! -z "$ilasmroundtrip" ]; then +if [[ -n "$ilasmroundtrip" ]]; then echo "Running Ilasm round trip" runtestPyArguments+=("--ilasmroundtrip") fi @@ -272,33 +272,33 @@ if (($verbose!=0)); then runtestPyArguments+=("--verbose") fi -if [ ! "$runSequential" -eq 0 ]; then +if [ "$runSequential" -ne 0 ]; then echo "Run tests sequentially." runtestPyArguments+=("--sequential") fi -if [ ! -z "$printLastResultsOnly" ]; then +if [[ -n "$printLastResultsOnly" ]]; then runtestPyArguments+=("--analyze_results_only") fi -if [ ! -z "$RunCrossGen2" ]; then +if [[ -n "$RunCrossGen2" ]]; then runtestPyArguments+=("--run_crossgen2_tests") fi -if [ ! -z "$RunNativeAot" ]; then +if [[ -n "$RunNativeAot" ]]; then runtestPyArguments+=("--run_nativeaot_tests") fi -if [ "$limitedCoreDumps" == "ON" ]; then +if [[ "$limitedCoreDumps" == "ON" ]]; then runtestPyArguments+=("--limited_core_dumps") fi -if [[ ! "$runincontext" -eq 0 ]]; then +if [[ "$runincontext" -ne 0 ]]; then echo "Running in an unloadable AssemblyLoadContext" runtestPyArguments+=("--run_in_context") fi -if [[ ! "$tieringtest" -eq 0 ]]; then +if [[ "$tieringtest" -ne 0 ]]; then echo "Running to encourage tier1 rejitting" runtestPyArguments+=("--tieringtest") fi diff --git a/src/tests/runparallel.sh b/src/tests/runparallel.sh index 0949d4a51946..0c0112f8baf4 100755 --- a/src/tests/runparallel.sh +++ b/src/tests/runparallel.sh @@ -156,7 +156,7 @@ if [ ! -d "$testRootDir" ]; then exit $EXIT_CODE_EXCEPTION fi -if [ ! -z "$testEnv" ] && [ ! -e "$testEnv" ]; then +if [[ -n "$testEnv" && ! -e "$testEnv" ]]; then echo "File specified by --playlist does not exist: $testEnv" exit $EXIT_CODE_EXCEPTION fi