platform/upstream/dotnet/runtime.git
2 years ago[mono] Do not generate impossible instantiations for constrained generics in Mono...
Ivan Povazan [Tue, 21 Jun 2022 15:28:40 +0000 (17:28 +0200)]
[mono] Do not generate impossible instantiations for constrained generics in Mono AOT (#70838)

This change improves the AOTed code size by reducing the number of generated methods for generics.
Fixes https://github.com/dotnet/runtime/issues/54850

2 years agoFix typo in GC_FORBID doc (#71050)
Huo Yaoyuan [Tue, 21 Jun 2022 12:11:10 +0000 (20:11 +0800)]
Fix typo in GC_FORBID doc (#71050)

2 years agoFix IPAddress equality comparison in MsQuicListener (#70979)
Radek Zikmund [Tue, 21 Jun 2022 12:04:51 +0000 (14:04 +0200)]
Fix IPAddress equality comparison in MsQuicListener (#70979)

* Fix IPAddress equality comparison in MsQuicListener

* Modify test

* Adjust comment

* Update src/libraries/System.Net.Quic/tests/FunctionalTests/QuicListenerTests.cs

Co-authored-by: Anton Firszov <antonfir@gmail.com>
Co-authored-by: Anton Firszov <antonfir@gmail.com>
2 years agoImplement NegotiateAuthentication API (#70720)
Filip Navara [Tue, 21 Jun 2022 11:38:18 +0000 (13:38 +0200)]
Implement NegotiateAuthentication API (#70720)

* WIP: Add implementation of NegotiateAuthentication

Switch System.Net.Http to use NegotiateAuthentication
Fix IsCompleted in managed NTLM implementation

* WIP: Update error code mapping

* Spanify input of GetOutgoingBlob

* Update comments

* Move NegotiateStreamPal.Encrypt/Decrypt to shared sources. Unix implementation already had them and they get trimmed anyway.

* Revert accidental change

* Build fixes.

* Fix error handling condition

* Update error mapping based on HttpListener usage.

* WIP: HttpListener test

* Move workaround from HttpListener to low-level SSPI code

* Fix build

* Clean up

* Revert "WIP: HttpListener test"

This reverts commit 18d7d93f04c93e048efcaca0f3c55c3f1f73516a.

* Convert System.Net.Http.FunctionalTests to use NegotiateAuthentication instead of NTAuthentication

* Dispose the identity along NegotiateAuthentication

* Modify unit tests to use the new API

* Add exceptions for invalid inputs/states

* Remove tvOS unsupported marker, managed NTLM is used on tvOS

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix typo

* Remove reference equality checks from IsNTLM/IsKerberos

* Remove NTAuthentication.AssociatedName to make it more obvious which exceptions are thrown

* Add comment

* Add more tests, handle unsupported protocols

* Handle NotSupportedException from NTAuthentication constructor

* Add workaround for linker issue

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoEnsure consistent reflectability for generic methods (#70977)
Michal Strehovský [Tue, 21 Jun 2022 11:32:43 +0000 (20:32 +0900)]
Ensure consistent reflectability for generic methods (#70977)

If we have a method body for `SomeMethod<Foo>` and `SomeMethod<T>` was decided to be reflection-visible, ensure `SomeMethod<Foo>` is also reflection-visible.

2 years agoset red zone size 512 for powerpc64. (#70885)
Vikas Gupta [Tue, 21 Jun 2022 09:23:13 +0000 (14:53 +0530)]
set red zone size 512 for powerpc64. (#70885)

2 years agoAdd markdown readme for System.Reflection.MetadataLoadContext (#70610)
MSDN.WhiteKnight [Tue, 21 Jun 2022 06:07:15 +0000 (11:07 +0500)]
Add markdown readme for System.Reflection.MetadataLoadContext (#70610)

* Create README.md

2 years agoMove allocation of command line argument array to C# (#71021)
Jan Kotas [Tue, 21 Jun 2022 05:43:40 +0000 (22:43 -0700)]
Move allocation of command line argument array to C# (#71021)

Also, avoid redundant allocation of managed string for each command line argument.

2 years agoFix Ordinal Ignore Case string compare (#71022)
Tarek Mahmoud Sayed [Tue, 21 Jun 2022 05:35:41 +0000 (22:35 -0700)]
Fix Ordinal Ignore Case string compare (#71022)

2 years agoAvoid unnecessary allocations in SanitizeEntryFilePath (#71034)
Stephen Toub [Tue, 21 Jun 2022 04:39:55 +0000 (00:39 -0400)]
Avoid unnecessary allocations in SanitizeEntryFilePath (#71034)

2 years agoUse LastIndexOfAny in GetFileName_Windows (#71032)
Stephen Toub [Tue, 21 Jun 2022 03:41:14 +0000 (23:41 -0400)]
Use LastIndexOfAny in GetFileName_Windows (#71032)

2 years ago[Android] Make sure AdditionalTimeZoneChecks trait is added to xunit-excludes (#70974)
Steve Pfister [Tue, 21 Jun 2022 02:34:11 +0000 (22:34 -0400)]
[Android] Make sure AdditionalTimeZoneChecks trait is added to xunit-excludes (#70974)

The trait is supposed to be included in System.Runtime tests by default, but wasn't because the _withoutCategories property was in tests.props. As a result, the property was resolved before the .csproj properties. This fix moves the property definition to tests.targets.

Fixes #70482

2 years agoRemove allocation in ImmutableArray Builder Sort (#70850)
Gregory Bell [Tue, 21 Jun 2022 02:27:34 +0000 (19:27 -0700)]
Remove allocation in ImmutableArray Builder Sort (#70850)

* Remove allocation in ImmutableArray Builder Sort

`ImmutableArray<T>.Builder.Sort(Comparison<T> comparison)` allocates a new instance of `Comparer<T>` using `comparison`. Then `ArraySort` allocates a new delegate from `comparer.Compare`. Both allocations can be eliminated by calling `Array.Sort<T>(T[] array, Comparison<T> comparison)` directly.

* Sort only valid range of array

* Use MemoryExtensions.Sort where available.

* Update src/libraries/System.Collections.Immutable/src/System/Collections/Immutable/ImmutableArray_1.Builder.cs

Fix spelling mistake.

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2 years ago[wasm] Wasm.Build.Tests: disable tests failing on CI (#71020)
Ankit Jain [Tue, 21 Jun 2022 02:18:21 +0000 (22:18 -0400)]
[wasm] Wasm.Build.Tests: disable tests failing on CI (#71020)

* [wasm] Wasm.Build.Tests: disable tests failing on CI

.. due to being oomkill'ed.

* [wasm] Don't fail the job when firefox tests fail, as they are known to be unstable

2 years agoAdd TarEntry conversion constructors (#70325)
Carlos Sanchez [Tue, 21 Jun 2022 00:59:52 +0000 (17:59 -0700)]
Add TarEntry conversion constructors (#70325)

* ref: Conversion constructors

* src: Conversion constructors

* tests: Conversion constructors

2 years agoExposing IRootFunctions.Hypot and IRootFunctions.Root (#71010)
Tanner Gooding [Mon, 20 Jun 2022 23:14:52 +0000 (16:14 -0700)]
Exposing IRootFunctions.Hypot and IRootFunctions.Root (#71010)

* Exposing IRootFunctions.Hypot and IRootFunctions.Root

* Adding tests for IRootFunctions.Hypot and IRootFunctions.Root

2 years agoAdd ZipArchiveEntry.IsEncrypted for password-protection detection (#70036)
Jeff Handley [Mon, 20 Jun 2022 22:58:52 +0000 (15:58 -0700)]
Add ZipArchiveEntry.IsEncrypted for password-protection detection (#70036)

* Add ZipArchiveEntry.IsEncrypted for password-protection detection

* Apply suggestions from code review

Co-authored-by: David Cantú <dacantu@microsoft.com>
* Run GenerateReferenceAssemblySource for System.IO.Compression

* Revert WriteAsync default parameter value removal

* Update DeflateStream.WriteAsync to include the default param value

* Revert unrelated change from GenerateReferenceAssemblySource

* Revert unrelated change after syncing with GenerateReferenceAssemblySource

Co-authored-by: David Cantú <dacantu@microsoft.com>
2 years agoWindows/Arm64: Use 8.1 atomic instructions if they are available (#70921)
Kunal Pathak [Mon, 20 Jun 2022 22:13:13 +0000 (15:13 -0700)]
Windows/Arm64: Use 8.1 atomic instructions if they are available (#70921)

* Use Fast compareexchange, acquire/release

* working windows version

* remove printf

* some more #ifdef

* fix some #ifdef

* optimize EnterObjMonitorHelperSpin

* Remove FastInterlockedCompareExchange64 for now

2 years ago[main] Update dependencies from dotnet/runtime dotnet/xharness dotnet/icu dotnet...
dotnet-maestro[bot] [Mon, 20 Jun 2022 22:06:10 +0000 (18:06 -0400)]
[main] Update dependencies from dotnet/runtime dotnet/xharness dotnet/icu dotnet/emsdk (#70991)

* Update dependencies from https://github.com/dotnet/runtime build 20220619.5

Microsoft.NET.Sdk.IL , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHost , Microsoft.NETCore.DotNetHostPolicy , Microsoft.NETCore.ILAsm , runtime.native.System.IO.Ports , System.Text.Json
 From Version 7.0.0-preview.6.22312.5 -> To Version 7.0.0-preview.6.22319.5

* Update dependencies from https://github.com/dotnet/xharness build 20220620.1

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 1.0.0-prerelease.22314.1 -> To Version 1.0.0-prerelease.22320.1

* Update dependencies from https://github.com/dotnet/icu build 20220620.2

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 7.0.0-preview.6.22313.1 -> To Version 7.0.0-preview.6.22320.2

* Update dependencies from https://github.com/dotnet/emsdk build 20220620.1

Microsoft.NET.Workload.Emscripten.Manifest-7.0.100
 From Version 7.0.0-preview.6.22313.1 -> To Version 7.0.0-preview.6.22320.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoAdd AddSystemd() and AddWindowsService() IServiceCollection extension methods (#68580)
Stephen Halter [Mon, 20 Jun 2022 21:40:30 +0000 (14:40 -0700)]
Add AddSystemd() and AddWindowsService() IServiceCollection extension methods (#68580)

* Add AddSystemd() IServiceCollection extension method

* Add AddWindowsService() IServiceCollection extension method

* Don't default to CWD if in C:\Windows\system32
- instead, when CWD is C:\Windows\system32 Hosting will use AppContext.BaseDirectory. This way Windows apps and services that are launched will work by default. HostApplicationBuilder.ContentRootPath can't be changed after construction, so setting it to a workable default for Windows apps.

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
* Use RemoteExecutor

* Update src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs

* Skip test on Windows nano server

* Respond to PR feedback

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Martin Costello <martin@martincostello.com>
2 years ago[wasm][debugger] Fix side effect on Firefox of getting bytes from loaded_files using...
Thays Grazia [Mon, 20 Jun 2022 19:45:04 +0000 (16:45 -0300)]
[wasm][debugger] Fix side effect on Firefox of getting bytes from loaded_files using debugger protocol (#70990)

* Fix 70983

* fix typo

* Fix compilation

2 years ago[wasm] Enabled WasmTestOnBrowser run on Windows for Browser. (#70890)
Ilona Tomkowicz [Mon, 20 Jun 2022 19:40:16 +0000 (21:40 +0200)]
[wasm] Enabled WasmTestOnBrowser run on Windows for Browser. (#70890)

* Enabled tests - no timeout with new ems. Keeping disabled tests failing from other reasons.

* Added @radical's suggestion.

* Test CI- enable test that are throwing in Debug.

2 years agoConvert fallback path of GetCommandLineArgs to managed (#70608)
Huo Yaoyuan [Mon, 20 Jun 2022 18:35:18 +0000 (02:35 +0800)]
Convert fallback path of GetCommandLineArgs to managed (#70608)

* P/Invoke definition

* Use P/Invoke in managed code

* Update managed call site

* Add test using private reflection

* Native command line should be superset of managed

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoUse `gtEffectiveVal` for `GT_ADD` op1 in `optCreateAssertion` (#70228)
Will Smith [Mon, 20 Jun 2022 18:32:36 +0000 (11:32 -0700)]
Use `gtEffectiveVal` for `GT_ADD` op1 in `optCreateAssertion` (#70228)

* Initial work for comma hoisting in cse

* Formatting

* Adding more ops to comma hoisting

* Set regnum

* Update optcse.cpp

* Using effectiveval instead

2 years agoImplement Vector128 version of System.Buffers.Text.Base64 DecodeFromUtf8 and EncodeTo...
Alan Hayward [Mon, 20 Jun 2022 18:02:56 +0000 (19:02 +0100)]
Implement Vector128 version of System.Buffers.Text.Base64 DecodeFromUtf8 and EncodeToUtf8 (#70654)

* Implement Vector128 version of System.Buffers.Text.Base64.DecodeFromUtf8

Rework the SS3 into a Vector128 version, and add Arm64 support.

* SSE3 improvements

* Remove superfluous bitwise And

* Add comment to SimdShuffle

* Inline SimdShuffle

* Implement Vector128 version of System.Buffers.Text.Base64.EncodeToUtf8

* Ensure masking on SSE3

Change-Id: I319f94cfc51d0542ae4eb11a8d48b3eb8180553f
CustomizedGitHooks: yes

* Restore asserts and move zero inside the loop

* Neater C# code

Change-Id: I2cbe14f4228f8035e7d213b5b58815c4eee35563
CustomizedGitHooks: yes

* Make SimdShuffle consistent across X64 and Arm64

* Better looking multiply

2 years agoAdd support for cross module inlining and cross module generic compilation to Crossge...
David Wrighton [Mon, 20 Jun 2022 17:51:41 +0000 (10:51 -0700)]
Add support for cross module inlining and cross module generic compilation to Crossgen2 (#68919)

* Add support for cross module inlining and cross module generic compilation to Crossgen2
- Refactor Module into ModuleBase and Module
  - The goal is to have allow a subset version of Module which can only hold refs, this is to be used by the manifest module in an R2R image to allow for version resilient cross module references.
  - Update handling of ModuleBase so that its used everywhere that tokens are parsed from R2R
  - Remove ENCODE_MODULE_ID_FOR_STATICS and ENCODE_ACTIVE_DEPENDENCY
    - These were only used for NGEN, and conflict with easy impelmentation for the ModuleBase concept
  - Remove locking in ENCODE_STRING_HANDLE processing, and tweak comments. Comments applied to the removed ngen based code, and the lock was only necessary for the old ngen thing.
  - Adjust ComputeLoaderModuleWorker for locating loader module
    - Follow comment more accurately, to avoid putting every generic into its definition module. This will make R2R function lookup able to find compiled instantiations in some cases. This may be what we want long term, it may not.
  - Remove MemberRefToDesc map and replace with LookupMap like the other token types. We no longer make use of the hot table, so this is more efficient
    - Also reduces complexity of implementation of ModuleBase

- Build fixup to describe a single method as a standalone blob of data
  - There are parallel implementations in Crossgen2 and in the runtime
  - They produce binary identical output
  - Basic R2RDump support for new fixup

- Adjust module indices used within the R2R format to support a module index which refers to the R2R manifest metadata. This requires bumping the R2R version to 6.2
  - Add a module index between the set of assembly refs in the index 0 module and the set of assembly refs in the R2R manifest metadata

- Adjust compilation dependency rules to include a few critical AsyncStateMachineBox methods

- Remove PEImage handling of native metadata which was duplicative

- Do not enable any more devirtualization than was already in use, even in the cross module compilation scenario. In particular, do not enable devirtualization of methods where the decl method isn't within the version bubble, even if the decl method could be represented with a cross-module reference token. (This could be fixed, but is out of scope for this initial investigation)

Make the compilation deterministic in this new model, even though we are generating new tokens on demand
  - Implement this by detecting when we need new tokens during a compile, and recompiling with new tokens when necessary
  - This may result in compiling the same code as much as twice

Compile the right set of methods with cross module inlining enabled
- Add support for compiling the called virtual methods on generic types
  - This catches the List<T> and Dictionary<TKey,TValue> scenarios

- Add command line switches to enable/disable the new behavior
  - By default the new behavior is not enabled

2 years agoJIT: Model string literal objects as invariant and non-GLOB_REF (#70986)
Jakob Botsch Nielsen [Mon, 20 Jun 2022 17:40:25 +0000 (19:40 +0200)]
JIT: Model string literal objects as invariant and non-GLOB_REF (#70986)

* Model string literals as invariant/non GLOB_REF

* String literals are never null

2 years agoFix default log color behavior when console is redirected (#70504)
Maryam Ariyan [Mon, 20 Jun 2022 17:08:47 +0000 (13:08 -0400)]
Fix default log color behavior when console is redirected (#70504)

2 years agoFix arm64 funclet frame type 5 (#70922)
Bruce Forstall [Mon, 20 Jun 2022 16:55:17 +0000 (09:55 -0700)]
Fix arm64 funclet frame type 5 (#70922)

* Fix arm64 funclet frame type 5

* Add code to stress arm64 funclet frame type 5

This can be forced using `COMPlus_JitSaveFpLrWithCalleeSavedRegisters=3`,
or will be enabled under stress.

* Add a regression test

* Fix funclet frame type 5 alignment calculation

* Fix a couple bugs; improve documentation

1. Improve the frame shape pictures, especially for arm64 funclet frames. Include the
MonitorAcquired element and OSR pad.
2. Fix bug for `SP_to_PSP_slot_delta` for funclet frame type 4 for OSR: don't include osrPad.
3. Fix bug with funclet frame type 5 for `SP_to_FPLR_save_delta` using wrong aligned func size;
would be incorrect if one and two SP adjustment full frame aligned sizes are different (e.g.,
if two SP adjustment required two alignment slots and one SP adjustment thus required none).

2 years agoMinor refactoring for `UpgradeToRegexGeneratorAnalyzer` (#70767)
Youssef Victor [Mon, 20 Jun 2022 14:50:37 +0000 (16:50 +0200)]
Minor refactoring for `UpgradeToRegexGeneratorAnalyzer` (#70767)

2 years agoCollections contain stale object IDs (#70924)
Aaron Robinson [Mon, 20 Jun 2022 14:48:37 +0000 (07:48 -0700)]
Collections contain stale object IDs (#70924)

It looks like the collections contain stale
ObjectID values. These collection should
be purged between GCs.

2 years agoUpstream coreclr and pal changes to support powerpc (ppc64le) architecture (#69105)
Vikas Gupta [Mon, 20 Jun 2022 12:28:47 +0000 (17:58 +0530)]
Upstream coreclr and pal changes to support powerpc (ppc64le) architecture  (#69105)

* coreclr pal layer chanegs.

* Updated the system arch for power architecture.

* Fixed the failing PAL SXS exception_handling test case

* replaced gint with gint64 to avoid overflow and this has fixed the segmentation fault issue.

* coreclr pal layer chanegs.

* Fixed the failing PAL SXS exception_handling test case

* coreclr pal layer chanegs.

* Updated the system arch for power architecture.

* Fixed the failing PAL SXS exception_handling test case

* replaced gint with gint64 to avoid overflow and this has fixed the segmentation fault issue.

* coreclr pal layer chanegs.

* Fixed the failing PAL SXS exception_handling test case

* Removing intsafe.h file as main does not have this file now.(Already removed in commit 27195f670937c7e21ab68a806396f9d17c57231a)

Co-authored-by: Alhad Deshpande <Alhad.Deshpande1@ibm.com>
2 years agoStop wrapping SIMD nodes in OBJs (#70888)
SingleAccretion [Mon, 20 Jun 2022 12:07:53 +0000 (15:07 +0300)]
Stop wrapping SIMD nodes in OBJs (#70888)

2 years ago[QUIC] Removes abstract providers and mock from S.N.Quic (#70421)
Marie Píchová [Mon, 20 Jun 2022 10:44:29 +0000 (12:44 +0200)]
[QUIC] Removes abstract providers and mock from S.N.Quic (#70421)

* Removed abstract providers and mock from S.N.Quic

* Removed provider and replaced with statics on Listener and Connection

* Added assert

2 years agoFix nullable annotations on MailAddress.TryCreate (#70943)
Stephen Toub [Mon, 20 Jun 2022 10:16:00 +0000 (06:16 -0400)]
Fix nullable annotations on MailAddress.TryCreate (#70943)

2 years agoEnable IDE0031 (Use null propagation) (#70965)
Stephen Toub [Mon, 20 Jun 2022 09:47:48 +0000 (05:47 -0400)]
Enable IDE0031 (Use null propagation) (#70965)

2 years ago[main] Update dependencies from dotnet/arcade (#70662)
dotnet-maestro[bot] [Mon, 20 Jun 2022 08:00:57 +0000 (10:00 +0200)]
[main] Update dependencies from dotnet/arcade (#70662)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoFixes #64159 - JsonSerializerContext source generation fails with keyword identifiers...
Steve Dunn [Mon, 20 Jun 2022 07:38:23 +0000 (08:38 +0100)]
Fixes #64159 - JsonSerializerContext source generation fails with keyword identifiers (#66876)

* Fixes #64159 - initial implementation

* Tidy up, and add test for ignored reserved-keyword-named property

* PR feedback - use same approach as logging generator

* PR feedback

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Parser.cs

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
* PR feedback - rename ExactNameSpecifiedInSourceCode

* PR feedback - use extracted (and renamed) local variable

* Remove commented code

* Added `IsVerbatimName` as extension method

* Support fields with verbatim names (@)

* Use alternative method for checking for verbatim names

* Uses `SyntaxFacts` to determine if escaping is needed

* Remove extension method

* Modified source generator test to include a verbatim field

* Minor typo

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
2 years agoAdd support for randomized guard stack cookies (#70806)
Michal Strehovský [Mon, 20 Jun 2022 07:27:51 +0000 (16:27 +0900)]
Add support for randomized guard stack cookies (#70806)

The compiler was generating GS cookies, but the cookie was always an ASCII encoding of "Hi, mom!".

Make the cookie properly per-process randomized.

The randomization algorithm is same as in the CoreCLR VM.

Fixes #70071.

2 years agoDisable W^X on macOS under Rosetta emulation (#70912)
Jan Vorlicek [Mon, 20 Jun 2022 07:05:45 +0000 (09:05 +0200)]
Disable W^X on macOS under Rosetta emulation (#70912)

* Disable W^X on macOS under Rosetta emulation

Apple has informed us that double mapping doesn't work properly
on Rosetta emulation. This change disables W^X if Rosetta is detected.

* Reflect PR feedback

2 years agoFix illumos-x64 build (#70956)
Adeel Mujahid [Mon, 20 Jun 2022 01:54:42 +0000 (04:54 +0300)]
Fix illumos-x64 build (#70956)

2 years agoMake SuperPMI more explicit about JIT in error messages (#70938)
Bruce Forstall [Mon, 20 Jun 2022 01:52:49 +0000 (18:52 -0700)]
Make SuperPMI more explicit about JIT in error messages (#70938)

This makes it easier to figure out which JIT failed in asmdiffs scenarios.

e.g.,
```
[10:40:50] ERROR: Method 3673 of size 3107 failed to load and compile correctly by JIT2 (C:\gh\runtime\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit_universal_arm64_x64.dll).
[10:40:50] ERROR: Method 3673 of size 3107 failed to load and compile correctly by JIT1 (C:\gh\runtime2\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\clrjit_universal_arm64_x64.dll).
```

2 years agoEnable `TYP_STRUCT` `LCL_VAR/LCL_FLD` call args on Windows x64 (#70777)
SingleAccretion [Sun, 19 Jun 2022 20:44:36 +0000 (23:44 +0300)]
Enable `TYP_STRUCT` `LCL_VAR/LCL_FLD` call args on Windows x64 (#70777)

* Fix forward sub

* Enable folding in local morph

* Morph: TYP_STRUCT LCL_FLD

2 years agoDo not reuse implicit byrefs for by-value args (#70955)
SingleAccretion [Sun, 19 Jun 2022 20:36:06 +0000 (23:36 +0300)]
Do not reuse implicit byrefs for by-value args (#70955)

* Do not reuse implicit byrefs for by-value args

* Add a test

2 years agoEnable IDE0030 (Use coalesce expression) (#70948)
Stephen Toub [Sun, 19 Jun 2022 13:08:59 +0000 (09:08 -0400)]
Enable IDE0030 (Use coalesce expression) (#70948)

2 years agoAllow ValueListBuilder to work with empty scratch spans (#70917)
Stephen Toub [Sun, 19 Jun 2022 11:55:32 +0000 (07:55 -0400)]
Allow ValueListBuilder to work with empty scratch spans (#70917)

2 years agoUpdate C# compiler (#70947)
Stephen Toub [Sun, 19 Jun 2022 11:52:45 +0000 (07:52 -0400)]
Update C# compiler (#70947)

Brings in support for required members

2 years agoOptimization for full range checks (#70145) (#70222)
Sychev Vadim [Sun, 19 Jun 2022 10:30:09 +0000 (13:30 +0300)]
Optimization for full range checks (#70145) (#70222)

2 years agoEnable IDE0065 (Misplaced using directive) (#70919)
Stephen Toub [Sun, 19 Jun 2022 04:44:31 +0000 (00:44 -0400)]
Enable IDE0065 (Misplaced using directive) (#70919)

2 years agoEnable IDE0100 (Remove redundant equality) (#70896)
Stephen Toub [Sun, 19 Jun 2022 04:43:37 +0000 (00:43 -0400)]
Enable IDE0100 (Remove redundant equality) (#70896)

2 years agoEnable IDE0071 (Simplify interpolation) (#70918)
Stephen Toub [Sun, 19 Jun 2022 04:41:30 +0000 (00:41 -0400)]
Enable IDE0071 (Simplify interpolation) (#70918)

2 years agoEventLogException is missing the original win32 error code (#70629)
Badre BSAILA [Sun, 19 Jun 2022 04:20:37 +0000 (06:20 +0200)]
EventLogException is missing the original win32 error code (#70629)

2 years agosuperpmi.py: Add `-jitoption` for asmdiffs (#70939)
Bruce Forstall [Sat, 18 Jun 2022 19:53:53 +0000 (12:53 -0700)]
superpmi.py: Add `-jitoption` for asmdiffs (#70939)

The new `-jitoption` option passes the argument options to both baseline and diff
compilers. This is a convenience option: there already is `-base_jit_option` and
`-diff_jit_option` to specify passing options to either baseline or diff.

The name of the option is the same as that used for `replay`.

2 years agoRemove some dead code / branches (#70146)
Stephen Toub [Sat, 18 Jun 2022 12:21:09 +0000 (08:21 -0400)]
Remove some dead code / branches (#70146)

* Remove some dead code / branches

Some signal amidst the noise in an lgtm.com report.

* Address PR feedback

2 years agoEnable lib tests that used to fail with GC issues (#70831)
Lakshan Fernando [Sat, 18 Jun 2022 11:49:24 +0000 (04:49 -0700)]
Enable lib tests that used to fail with GC issues (#70831)

* enable lib tests that used to fail with GC issues

* excluding linq parallel test since that doesn't build

* Threading.Thread tests have issues

* Excluding new test failures

2 years agoUse u8 in a few more places (#70894)
Stephen Toub [Sat, 18 Jun 2022 10:48:26 +0000 (06:48 -0400)]
Use u8 in a few more places (#70894)

* Use u8 in a few more places

* A few more u8s

2 years agoHarden for null byrefs (#70317)
Aaron Robinson [Sat, 18 Jun 2022 04:31:25 +0000 (21:31 -0700)]
Harden for null byrefs (#70317)

* Remove enum_flag_Unrestored usage in boxing stubs.

* Add AND instruction (21h) to x86 decoder.

* Update mono for null ref in interpreter paths.

* Disable test on llvmfullaot and wasm

* Handle null destination for intrinsics.

2 years ago[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet...
dotnet-maestro[bot] [Sat, 18 Jun 2022 03:53:03 +0000 (23:53 -0400)]
[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet/runtime-assets dotnet/emsdk dotnet/roslyn-analyzers (#70476)

* Update dependencies from https://github.com/dotnet/runtime-assets build 20220608.1

Microsoft.DotNet.CilStrip.Sources , System.ComponentModel.TypeConverter.TestData , System.Drawing.Common.TestData , System.Formats.Tar.TestData , System.IO.Compression.TestData , System.IO.Packaging.TestData , System.Net.TestData , System.Private.Runtime.UnicodeData , System.Runtime.Numerics.TestData , System.Runtime.TimeZoneData , System.Security.Cryptography.X509Certificates.TestData , System.Text.RegularExpressions.TestData , System.Windows.Extensions.TestData
 From Version 7.0.0-beta.22281.1 -> To Version 7.0.0-beta.22308.1

* Update dependencies from https://github.com/dotnet/emsdk build 20220608.2

Microsoft.NET.Workload.Emscripten.Manifest-7.0.100
 From Version 7.0.0-preview.6.22281.1 -> To Version 7.0.0-preview.6.22308.2

* Update dependencies from https://github.com/dotnet/xharness build 20220610.1

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 1.0.0-prerelease.22305.1 -> To Version 1.0.0-prerelease.22310.1

* Revert "Update dependencies from https://github.com/dotnet/emsdk build 20220608.2"

This reverts commit bbb4e156ddbad8a2cb7b604246214272085b6622.

* Update dependencies from https://github.com/dotnet/icu build 20220609.1

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 7.0.0-preview.6.22306.1 -> To Version 7.0.0-preview.6.22309.1

* Update dependencies from https://github.com/dotnet/emsdk build 20220608.2

Microsoft.NET.Workload.Emscripten.Manifest-7.0.100
 From Version 7.0.0-preview.6.22281.1 -> To Version 7.0.0-preview.6.22308.2

* Update dependencies from https://github.com/dotnet/runtime-assets build 20220610.1

Microsoft.DotNet.CilStrip.Sources , System.ComponentModel.TypeConverter.TestData , System.Drawing.Common.TestData , System.Formats.Tar.TestData , System.IO.Compression.TestData , System.IO.Packaging.TestData , System.Net.TestData , System.Private.Runtime.UnicodeData , System.Runtime.Numerics.TestData , System.Runtime.TimeZoneData , System.Security.Cryptography.X509Certificates.TestData , System.Text.RegularExpressions.TestData , System.Windows.Extensions.TestData
 From Version 7.0.0-beta.22281.1 -> To Version 7.0.0-beta.22310.1

* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20220610.1

Microsoft.CodeAnalysis.NetAnalyzers
 From Version 7.0.0-preview1.22302.1 -> To Version 7.0.0-preview1.22310.1

* Update dependencies from https://github.com/dotnet/runtime build 20220612.5

Microsoft.NET.Sdk.IL , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.DotNetHost , Microsoft.NETCore.DotNetHostPolicy , Microsoft.NETCore.ILAsm , runtime.native.System.IO.Ports , System.Text.Json
 From Version 7.0.0-preview.6.22305.4 -> To Version 7.0.0-preview.6.22312.5

* Update dependencies from https://github.com/dotnet/icu build 20220613.1

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 7.0.0-preview.6.22306.1 -> To Version 7.0.0-preview.6.22313.1

* Update dependencies from https://github.com/dotnet/xharness build 20220613.1

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 1.0.0-prerelease.22310.1 -> To Version 1.0.0-prerelease.22313.1

* Update dependencies from https://github.com/dotnet/runtime-assets build 20220613.1

Microsoft.DotNet.CilStrip.Sources , System.ComponentModel.TypeConverter.TestData , System.Drawing.Common.TestData , System.Formats.Tar.TestData , System.IO.Compression.TestData , System.IO.Packaging.TestData , System.Net.TestData , System.Private.Runtime.UnicodeData , System.Runtime.Numerics.TestData , System.Runtime.TimeZoneData , System.Security.Cryptography.X509Certificates.TestData , System.Text.RegularExpressions.TestData , System.Windows.Extensions.TestData
 From Version 7.0.0-beta.22281.1 -> To Version 7.0.0-beta.22313.1

* Update dependencies from https://github.com/dotnet/emsdk build 20220613.1

Microsoft.NET.Workload.Emscripten.Manifest-7.0.100
 From Version 7.0.0-preview.6.22281.1 -> To Version 7.0.0-preview.6.22313.1

* [wasm] Wasm.Build.Tests: Disable strict version checks for emcc

Due to the way we have to update `dotnet/emsdk`, and get the update PRs
in `runtime`, the emsdk version can be mismatched. For example, if
`dotnet/emsdk` has already updated to `3.1.12`, but `dotnet/runtime` is
still on `3.1.7`. This is an expected scenario while working on updating
to a newer emscripten.

The version mismatch will still show up, but as a warning now.

* Update dependencies from https://github.com/dotnet/xharness build 20220614.1

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 1.0.0-prerelease.22310.1 -> To Version 1.0.0-prerelease.22314.1

* [wasm] Wasm.Build.Tests: Update Skiasharp reference

The skiasharp dependent tests fail with:
`error : undefined symbol: _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv`.

Update the reference to the latest package which added a binary compiled
for `3.1.7`.

* [wasm] Workaround a test failure in WBT

Currently, there is a mismatch between emsdk versions with the workload
emscripten packs using `3.1.12`, and the runtime being built with
`3.1.7`. And that is causing
`Wasm.Build.Tests.NativeLibraryTests.ProjectUsingSkiaSharp` to fail with:

```
EXEC : error : undefined symbol: _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv (referenced by top-level compiled C/C++ code) [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : warning : Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : warning : To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0` [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : warning : __ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : error : undefined symbol: _ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv (referenced by top-level compiled C/C++ code) [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : warning : __ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
EXEC : error : Aborting compilation due to previous errors [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
emcc : error : '/datadisks/disk1/work/B1420981/w/ACC90933/e/dotnet-workload/packs/Microsoft.NET.Runtime.Emscripten.3.1.12.Node.linux-x64/7.0.0-preview.6.22313.1/tools/bin/node /datadisks/disk1/work/B1420981/w/ACC90933/e/dotnet-workload/packs/Microsoft.NET.Runtime.Emscripten.3.1.12.Sdk.linux-x64/7.0.0-preview.6.22313.1/tools/emscripten/src/compiler.js /datadisks/disk1/work/B1420981/t/tmp44tn7y2d.json' failed (returned 1) [/datadisks/disk1/work/B1420981/w/ACC90933/e/blz_nativeref_aot_Debug/blz_nativeref_aot_Debug.csproj]
```

This commit adds a temporary workaround to ignore the undefined symbols
for this specific test. And this should be removed when runtime is
updated to `3.1.12` .

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
2 years agoAppend the function pointer type (#70923)
Aaron Robinson [Sat, 18 Jun 2022 03:05:47 +0000 (20:05 -0700)]
Append the function pointer type (#70923)

The issue here was the recursion into PrettyPrintSigWorkerInternal
that would reset the buffer. Now, we pass in a new buffer and append
it when we return.

2 years agoUse ArgumentNullException.ThrowIfNull in a few more places (#70897)
Stephen Toub [Sat, 18 Jun 2022 00:36:47 +0000 (20:36 -0400)]
Use ArgumentNullException.ThrowIfNull in a few more places (#70897)

2 years agoAdd support for delegate GDV and method-based vtable GDV (#68703)
Jakob Botsch Nielsen [Fri, 17 Jun 2022 23:58:01 +0000 (01:58 +0200)]
Add support for delegate GDV and method-based vtable GDV (#68703)

Add support for instrumenting delegate calls and vtable calls into method handle histograms. Use these histograms to do GDV for delegate calls and also support method-based GDV for vtable calls.

For instrumentation we now support class probes at interface call sites, method probes at delegate call sites and both class probes and method probes at vtable call sites. For vtable calls, when turned on, instrumentation produces both histograms as PGO data so that the JIT can later make the choice about what is the best form of guard to use at that site.

For guarding, there are some things to take into account. Delegate calls currently (practically) always point to precode, so this PR is just guarding on getFunctionFixedEntryPoint which returns the precode address, and this is generally quite cheap (same cost as class-based GDV). That's the case for delegates pointing to instance methods anyway, this PR does not support static methods yet -- those will be more expensive.

For vtable calls the runtime will backpatch the slots when tiering, so the JIT guards the address retrieved from the vtable against an indirection of the slot, which is slightly more expensive than a class-based guard.

Currently the instrumentation is enabled conditionally with COMPlus_JitDelegateProfiling=1 (for delegates) and COMPlus_JitVTableProfiling=1 (for vtable calls). Currently delegate profiling is turned on by default while vtable profiling is off by default.

2 years agoReplace the remaining uses of Marshal.PtrToStructure in core networking (#70900)
Jan Kotas [Fri, 17 Jun 2022 23:51:17 +0000 (16:51 -0700)]
Replace the remaining uses of Marshal.PtrToStructure in core networking (#70900)

* Rename ICMP interop to match Windows SDK names

2 years agoFix ICorDebugFunction2::GetVersionNumber for arm32. (#69901)
Mikhail Kurinnoi [Fri, 17 Jun 2022 23:02:28 +0000 (02:02 +0300)]
Fix ICorDebugFunction2::GetVersionNumber for arm32. (#69901)

2 years agoRemove #define Sleep (#70868)
Aaron Robinson [Fri, 17 Jun 2022 22:38:07 +0000 (15:38 -0700)]
Remove #define Sleep (#70868)

* Remove #define Sleep

2 years agoFix bug in Tar preventing extraction of hardlinks or entries starting with `.\` ...
Carlos Sanchez [Fri, 17 Jun 2022 21:02:07 +0000 (14:02 -0700)]
Fix bug in Tar preventing extraction of hardlinks or entries starting with `.\` (#70853)

* Add PlatformDetection.SupportsHardLinkCreation property.

* Fix how paths are combined/joined and sanitized on extraction, to ensure paths with redundant segments get properly handled.

* Add tests that verify archives with entries whose paths start with .\, including the root folder itself.

* Re-enable the hardlink test, condition it to not run if platform does not support extraction of hardlinks.

* Remove unnecessary test - This same code is already being tested by TarReader_ExtractToFile_Tests.ExtractEntriesWithSlashDotPrefix

* Reuse test code that retrieves memory stream.

* Bump test data package version

* Add missing typeof(PlatformDetection) in ConditionalFact

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
2 years ago[wasm] Add support for per-project customization of helix work items (#70461)
Ankit Jain [Fri, 17 Jun 2022 20:24:28 +0000 (16:24 -0400)]
[wasm] Add support for per-project customization of helix work items (#70461)

* [wasm] Add support for per-project customization of helix work items

Currently, for sending tests to helix:
1. the project binaries are zipped, as part of the project build
2. then separate helix targets files build that adds helix items for
   those zip files.
    - for wasm, we test with multiple 'scenarios' - like v8, browser, and
    nodejs.
    - so, 3 helix work items are submitted per zip file

- If a test project needs to have any customizations, for example, for
  testing crypto with a managed implementation, and subtlecrypto, which
  would require:
  - passing different arguments to xharness, in case of managed, and
    subtlecrypto
  - and this should be done only for the browser case
  - Currently, this would need this would need to be done in
  `sendtohelix-wasm.targets` special casing for the test project, and
  scenario.

- We add support for importing `$(ProjectName).helix.targets`, and
  calling a special target in that to add helix items, as needed.

- This targets file can be set in the test project like:
```xml
<HelixTargetsFile Condition="'$(TargetOS)' == 'Browser'">wasm.helix.targets</HelixTargetsFile>
```
  - it will get deployed next to the zip file, and picked up automatically

```xml
<Project>
  <PropertyGroup>
    <_CryptoProjectName>System.Security.Cryptography.Tests</_CryptoProjectName>
    <System_Security_Cryptography_Tests_TargetName Condition="'$(Scenario))' == 'WasmTestOnBrowser'">System_Security_Cryptography_Tests_Targ
et</System_Security_Cryptography_Tests_TargetName>
  </PropertyGroup>

  <Target Name="System_Security_Cryptography_Tests_Target">
    <ItemGroup>
      <HelixWorkItem Include="$(Scenario)-managed-$(_CryptoProjectName)">
        <PayloadArchive>$(TestArchiveTestsDir)$(_CryptoProjectName).zip</PayloadArchive>
        <Command>$(HelixCommand)</Command>
        <Timeout>$(_workItemTimeout)</Timeout>
      </HelixWorkItem>

      <HelixWorkItem Include="$(Scenario)-subtlecrypto-System.Security.Cryptography.Tests">
        <PayloadArchive>$(TestArchiveTestsDir)$(_CryptoProjectName).zip</PayloadArchive>
        <Command>$(HelixCommand)</Command>
        <Timeout>$(_workItemTimeout)</Timeout>

        <PreCommands Condition="'$(OS)' == 'Windows_NT'">set &quot;WasmXHarnessArgs=--web-server-use-cors&quot;</PreCommands>
        <PreCommands Condition="'$(OS)' != 'Windows_NT'">export &quot;WasmXHarnessArgs=--web-server-use-cors&quot;</PreCommands>
      </HelixWorkItem>
    </ItemGroup>
  </Target>
```

- The targets file *must* have these:
    - a property named like `System_Security_Cryptography_Tests_TargetName`, for a
      test project named `System.Security.Cryptography.Tests`
    - if this property is not set, then the default behavior of adding
      work items will run
    - The target should add any items it needs to to `@(HelixWorkItem)`.
      - Examples of adding these can be seen in `sendtohelix*` project files

- Remember that all these properties, and targets get imported into the
  msbuild *global* namespace, so make sure to use unique names to avoid
  conflicts with other test projects.

Future work: this commit only enables it for wasm/library tests, but it should
be easy to extract it out, but needs some testing.

* [wasm] Helix: test with, and without subtle crypto

* disable non-wasm builds

* address review feedback

* Address review feedback

* Fix typo

* Revert "disable non-wasm builds"

This reverts commit 7ef99e81f82200189dd3f61eeaf00d6ca4ced6d4.

* Update src/libraries/System.Security.Cryptography/tests/wasm.helix.targets

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Address review feedback

* remove debug spew

* Change the way helix extension targets are discovered.

The new approach:

To run a custom project specific target for adding/editing @(HelixWorkItem):

- In the project add:
    `<HelixTargetsFile Condition="'$(TargetOS)' == 'Browser'">wasm.helix.targets</HelixTargetsFile>`

    - This file gets copied next to the test archive as $(MSBuildProjectName).helix.targets

- In this `wasm.helix.targets` file, add to $(HelixExtensionTargets) to run your custom target

```xml
  <PropertyGroup Condition="'$(IsRunningLibraryTests)' == 'true' and '$(Scenario)' == 'WasmTestOnBrowser'">
    <HelixExtensionTargets>$(HelixExtensionTargets);_AddHelixCrypoItems</HelixExtensionTargets>
```

- The extension target will be called after the default items are added
  to `@(HelixWorkItem)`.
- Useful properties to condition on: $(Scenario), $(IsRunningLibraryTests)
- And add to, change, or remove from @(HelixWorkItem)

Example:
```xml
  <Target Name="_AddHelixCrypoItems">
    <ItemGroup>
      <!-- remove the existing item -->
      <HelixWorkItem Remove="@(HelixWorkItem)" Condition="'%(OriginalFileName)' == '$(_CryptoProjectName)'" />

        <!-- add two new ones - managed, and subtylecrypto -->
      <HelixWorkItem Include="$(WorkItemPrefix)managed-$(_CryptoProjectName)">
        <PayloadArchive>$(TestArchiveTestsDir)$(_CryptoProjectName).zip</PayloadArchive>
        <Command>$(HelixCommand)</Command>
        <Timeout>$(_workItemTimeout)</Timeout>
        <OriginalFileName>$(_CryptoProjectName)</OriginalFileName>
      </HelixWorkItem>

      <HelixWorkItem Include="$(WorkItemPrefix)subtlecrypto-$(_CryptoProjectName)">
        <PayloadArchive>$(TestArchiveTestsDir)$(_CryptoProjectName).zip</PayloadArchive>
        <Command>$(HelixCommand)</Command>
        <Timeout>$(_workItemTimeout)</Timeout>
        <OriginalFileName>$(_CryptoProjectName)</OriginalFileName>

        <PreCommands Condition="'$(OS)' == 'Windows_NT'">set &quot;WasmXHarnessArgs=%WasmXHarnessArgs% --web-server-use-cop&quot;</PreCommands>
        <PreCommands Condition="'$(OS)' != 'Windows_NT'">export &quot;WasmXHarnessArgs=$WasmXHarnessArgs --web-server-use-cop&quot;</PreCommands>
      </HelixWorkItem>

      <_CryptoHelixItem Include="@(HelixWorkItem)"
                        Condition="$([System.String]::new('%(HelixWorkItem.Identity)').EndsWith('-$(_CryptoProjectName)'))" />
    </ItemGroup>

    <Error Text="Something went wrong. Expected to have only two work items for $(_CryptoProjectName). But got @(_CryptoHelixItem)"
           Condition="@(_CryptoHelixItem->Count()) != 2" />
  </Target>
```

* cleanup

* Move WBT specific stuff into the target too. This will make it simpler to move it off into a targets file later

* fix build

* fix libtests

* fix wbt

* [wasm] Bump helix timeout to 90mins for debugger tests on windows

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
2 years agoAdd event to capture min/max threads (#70063)
Eduardo Velarde [Fri, 17 Jun 2022 17:56:23 +0000 (10:56 -0700)]
Add event to capture min/max threads (#70063)

Event ThreadPoolMinMaxThreads added.

Parameters are:
            ushort MinWorkerThreads
            ushort MaxWorkerThreads
            ushort MinIOCompletionThreads
            ushort MaxIOCompletionThreads
            ushort ClrInstanceID

It is fired in the ThreadPool constructor and in the SetMinThreads/SetMaxThreads functions.

2 years agoFix for timer scheduling happening on the incorrect thread when wasm threading is...
Katelyn Gadd [Fri, 17 Jun 2022 17:30:12 +0000 (10:30 -0700)]
Fix for timer scheduling happening on the incorrect thread when wasm threading is enabled (#70863)

2 years agoReplace a few instances of PtrToStructure with more efficient marshalling (#70866)
Jan Kotas [Fri, 17 Jun 2022 15:43:13 +0000 (08:43 -0700)]
Replace a few instances of PtrToStructure with more efficient marshalling (#70866)

2 years agoUnpin locals, attempt 2 (#70655)
Joni Aromaa [Fri, 17 Jun 2022 15:00:45 +0000 (18:00 +0300)]
Unpin locals, attempt 2 (#70655)

Contributes to #40553

2 years agoUse hash/hmac one shots in NTLM (#70857)
Kevin Jones [Fri, 17 Jun 2022 14:19:07 +0000 (10:19 -0400)]
Use hash/hmac one shots in NTLM (#70857)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoFix failure building two libraries tests (#70881)
Michal Strehovský [Fri, 17 Jun 2022 12:17:51 +0000 (21:17 +0900)]
Fix failure building two libraries tests (#70881)

Microsoft.CSharp was hitting an issue due to a vararg constructor. We don't support varargs. They shouldn't make it into the dependency graph. We are already checking in many places. We were erroneously thinking a vararg constructor with no mandatory arguments is a default constructor.

Runtime.InteropServices were crashing because we got a MulticastDelegate type into a codepath that expects a MulticastDelegate descendant.

2 years agoEnable IDE0020 (Use pattern matching) (#70523)
Stephen Toub [Fri, 17 Jun 2022 12:11:32 +0000 (08:11 -0400)]
Enable IDE0020 (Use pattern matching) (#70523)

* Enable IDE0020 (Use pattern matching)

* Update src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializationWriter.cs

Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com>
* Update variable naming

Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com>
2 years agoAvoid crashing on unresolved dependencies (#70871)
Michal Strehovský [Fri, 17 Jun 2022 11:50:44 +0000 (20:50 +0900)]
Avoid crashing on unresolved dependencies (#70871)

Fixes #70815.

2 years agoGenerate method bodies for delegate Invoke methods (#70883)
Michal Strehovský [Fri, 17 Jun 2022 11:49:48 +0000 (20:49 +0900)]
Generate method bodies for delegate Invoke methods (#70883)

There is a dataflow warning suppression in System.Linq.Expressions that assumes we'll always have an invocable method body for delegate Invoke method. We need one in IL. We don't in native code.

Emulate what IL Linker does and generate a method body. This is a size regression.

Suppression: https://github.com/dotnet/runtime/blob/3b2883b097a773715ca84056885e0ca1488da36e/src/libraries/System.Linq.Expressions/src/System/Dynamic/Utils/TypeUtils.cs#L906-L912

Fixes #70880.

2 years agoImprove TLS1.3 detection in registry for QUIC (#70730)
Radek Zikmund [Fri, 17 Jun 2022 09:56:33 +0000 (11:56 +0200)]
Improve TLS1.3 detection in registry for QUIC (#70730)

* Improve TLS1.3 detection in registry for QUIC

* Split client and server detection

* Code review feedback

2 years agoUse new byte[] span optimization in a few more places (#70665)
Stephen Toub [Fri, 17 Jun 2022 09:26:20 +0000 (05:26 -0400)]
Use new byte[] span optimization in a few more places (#70665)

* Use new byte[] span optimization in a few more places

Separated out of larger change to use CreateSpan (these don't rely on that).

* Address PR feedback

2 years agoEnable IDE0054 (Use compound assignment) (#70564)
Stephen Toub [Fri, 17 Jun 2022 09:26:03 +0000 (05:26 -0400)]
Enable IDE0054 (Use compound assignment) (#70564)

* Enable IDE0054 (Use compound assignment)

* Update src/libraries/System.Data.Common/src/System/Data/Common/StringStorage.cs

Co-authored-by: Tanner Gooding <tagoo@outlook.com>
Co-authored-by: Tanner Gooding <tagoo@outlook.com>
2 years agoAssign proper VNs to "shared constant" CSE defs (#70852)
SingleAccretion [Fri, 17 Jun 2022 09:23:08 +0000 (12:23 +0300)]
Assign proper VNs to "shared constant" CSE defs (#70852)

* Assign proper VNs to shared CSE defs

They must be those of the original expression, not the "base" constant CSE creates.

* Add a test

2 years agoARM64 - Optimize `i % 2` (#70599)
Will Smith [Fri, 17 Jun 2022 03:57:37 +0000 (20:57 -0700)]
ARM64 - Optimize `i % 2` (#70599)

2 years agoSmall performance cleanups in S.S.Cryptography
Kevin Jones [Fri, 17 Jun 2022 03:07:11 +0000 (23:07 -0400)]
Small performance cleanups in S.S.Cryptography

2 years agoFix GC stress failure in LoaderAllocator::CompareExchangeValueInHandle (#70832)
Jan Kotas [Fri, 17 Jun 2022 02:02:09 +0000 (19:02 -0700)]
Fix GC stress failure in LoaderAllocator::CompareExchangeValueInHandle (#70832)

InterlockedCompareExchangeT has to be called on a raw Object* to make the GC stress infrastructure happy.

2 years agoRestore ArchivingUtils.AttemptSetLastWriteTime (#70617)
Carlos Sanchez [Fri, 17 Jun 2022 01:57:07 +0000 (18:57 -0700)]
Restore ArchivingUtils.AttemptSetLastWriteTime (#70617)

2 years agoDelete StaticallyLinked property from Microsoft.NETCore.Native.Unix.props (#70854)
Jan Kotas [Fri, 17 Jun 2022 01:51:54 +0000 (18:51 -0700)]
Delete StaticallyLinked property from Microsoft.NETCore.Native.Unix.props (#70854)

This option has many issues. Anybody trying to experiment with static linking can add `<LinkerArg Include="-static" />` into the local file.

2 years agoUse `Array.Empty()` in `System.Reflection.Metadata`. (#70862)
Theodore Tsirpanis [Fri, 17 Jun 2022 01:46:59 +0000 (04:46 +0300)]
Use `Array.Empty()` in `System.Reflection.Metadata`. (#70862)

It is now available in all frameworks it targets.

2 years agoJIT: break loop canonicalization into two stages (#70809)
Andy Ayers [Fri, 17 Jun 2022 01:15:26 +0000 (18:15 -0700)]
JIT: break loop canonicalization into two stages (#70809)

For a given loop, we need to separate out the true backedge, any
non-loop backedges, and any inner loop backedges so that they all
target distinct blocks.

Otherwise, we may violate assumptions that the loop entry dominates
all blocks in the loop and that all backedges that reach top come
from within the loop.

This seems simplest to do with two rounds of canonicalization, one
that moves the non-loop edges, and another that moves the true backedge.

Fixes #70802.

2 years agoFixing the handling of Positive NaN in Math.Min for float/double (#70795)
Tanner Gooding [Fri, 17 Jun 2022 00:47:08 +0000 (17:47 -0700)]
Fixing the handling of Positive NaN in Math.Min for float/double (#70795)

* Adding tests validating Positive NaN for Max, MaxMagnitude, Min, and MinMagnitude

* Fixing the handling of Positive NaN in Math.Min for float/double

* Fixing the Max/Min code comments to use greater and lesser

* Adding a code comment clarifying the sign toggling behavior

2 years ago[coop] fix coop suspend timeout cue card (#70828)
Aleksey Kliger (λgeek) [Thu, 16 Jun 2022 23:35:51 +0000 (19:35 -0400)]
[coop] fix coop suspend timeout cue card (#70828)

the BLOCKING_SUSPEND_REQUESTED state is treated as suspend in full
coop mode (the thread keeps running, but by definition it's not
allowed to access managed resources and it will self-suspend if it
tries to enter GC Unsafe mode by calling a runtime API or managed
code).
It is bad in hybrid suspend mode (the thread should be preemptively
suspended, but we timed out before the signal handler had a chance to
run).

The corresponding suspension logic in the code is:

https://github.com/dotnet/runtime/blob/3fc61ebb562afc327a8fc6de5c82d76e86bf6f5d/src/mono/mono/utils/mono-threads.c#L1149-L1158

2 years agoCatch (more) mismatched args in `fgMorphArgs` (#70846)
SingleAccretion [Thu, 16 Jun 2022 22:45:33 +0000 (01:45 +0300)]
Catch (more) mismatched args in `fgMorphArgs` (#70846)

* Catch (more) mismatched args in "fgMorphArgs"

* Add a test

2 years agoFix a few Stream-related issues in System.Net.Http (#70731)
Stephen Toub [Thu, 16 Jun 2022 22:20:28 +0000 (18:20 -0400)]
Fix a few Stream-related issues in System.Net.Http (#70731)

* Fix a few Stream-related issues in System.Net.Http

* Put back WriteTimeout

* Fix tests

2 years agoFix corerun for assemblies with mismatched filename (#70800)
Jan Kotas [Thu, 16 Jun 2022 21:51:46 +0000 (14:51 -0700)]
Fix corerun for assemblies with mismatched filename (#70800)

corerun gracefully handled filename not matching the assembly name. Handling of this case regressed in #68186. This change is fixing the regression.

Fixes #68455

2 years agoUse IndexOf{Any} in a few more places (#70176)
Stephen Toub [Thu, 16 Jun 2022 21:20:12 +0000 (17:20 -0400)]
Use IndexOf{Any} in a few more places (#70176)

* Use IndexOf{Any} in a few more places

* Address PR feedback

2 years ago[wasm] Enabled WriteToReadOnly tests - emscripten bug got fixed (#70814)
Ilona Tomkowicz [Thu, 16 Jun 2022 21:19:35 +0000 (23:19 +0200)]
[wasm] Enabled WriteToReadOnly tests - emscripten bug got fixed (#70814)

Fixes #53021.

Enabled tests from #53021 - they are passing now because issue reported by @radekdoulik got fixed: https://github.com/emscripten-core/emscripten/issues/14299.

2 years agoDisable long running test (#70843)
Fan Yang [Thu, 16 Jun 2022 21:14:12 +0000 (17:14 -0400)]
Disable long running test (#70843)

2 years agoEnable IDE1005 (Delegate invocation can be simplified) (#70522)
Stephen Toub [Thu, 16 Jun 2022 20:57:36 +0000 (16:57 -0400)]
Enable IDE1005 (Delegate invocation can be simplified) (#70522)

2 years ago[wasm] Disable WBT test failing on windows (#70808)
Ankit Jain [Thu, 16 Jun 2022 20:33:58 +0000 (16:33 -0400)]
[wasm] Disable WBT test failing on windows (#70808)

Issue: https://github.com/dotnet/runtime/issues/70675

2 years agoNarrow cast fix (#70518)
Will Smith [Thu, 16 Jun 2022 19:10:53 +0000 (12:10 -0700)]
Narrow cast fix (#70518)

* Added genActualTypeSize. Remove narrow cast if the actual type sizes are the same

* Trying to fix build

* Fixing build

* Removed genActualTypeSize. Using genActualType instead

* Added helper function

* Comments

* Moving back to morph

* Removing part of the test

* Added fgOptimizeCastOnAssignment

* Fixing build

* Removing extra bits

* Removed fgIsSafeToRemoveIntToIntCastOnAssignment, inlining the implementation, adding extra logic when actual types are not the same

2 years agoTighten checks in `areArgumentsContiguous` (#70829)
SingleAccretion [Thu, 16 Jun 2022 19:10:08 +0000 (22:10 +0300)]
Tighten checks in `areArgumentsContiguous` (#70829)

* Tighten checks in "areArgumentsContiguous"

* Add a test

2 years agoJIT: Optimize range checks for X >> CNS and for short/byte indices (#67141)
Egor Bogatov [Thu, 16 Jun 2022 18:34:25 +0000 (20:34 +0200)]
JIT: Optimize range checks for X >> CNS and for short/byte indices  (#67141)

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years agoAdd limited support for LocalCertificateSelectionCallback for QUIC (#70716)
Radek Zikmund [Thu, 16 Jun 2022 18:22:50 +0000 (20:22 +0200)]
Add limited support for LocalCertificateSelectionCallback for QUIC (#70716)

* Inline state transition helpers

Fixes #55437

* Add high level comments for HandleEventReceive and ReadAsync

* [QUIC] Call `LocalCertificateSelectionCallback` to get client certificate

* Code review feedback