platform/upstream/dotnet/runtime.git
18 months agoEnable more intrinsics for tier0 (#83002)
Egor Bogatov [Mon, 6 Mar 2023 11:36:59 +0000 (12:36 +0100)]
Enable more intrinsics for tier0 (#83002)

18 months agoUpdate Microsoft.NETCore.Native.targets (#83024)
Michal Strehovský [Mon, 6 Mar 2023 11:14:52 +0000 (20:14 +0900)]
Update Microsoft.NETCore.Native.targets (#83024)

18 months agoInitial support for zmm in .NET (#80960)
DeepakRajendrakumaran [Mon, 6 Mar 2023 06:03:21 +0000 (22:03 -0800)]
Initial support for zmm in .NET (#80960)

* Adding simd64 and zmm types.

* Adding other infrastructure to lower/emit code for simd64.

* Lowering + workarounds for simd64 constants.

* Fix lowering logic for Create().

* Save/restore for zmm

* Add ToDo comments for AVX512BW

* Separate AVX512F and AVX512BW + Fix disassembly.

* Review changes.

* Fixing throughput issue.

* Additional Review comments.

* Setting 'EnableIncompleteISAClass="1"' for relevant CI runs.

* Removing 64 bit flags + correcting check.

* Apply formatting patch

---------

Co-authored-by: Tanner Gooding <tagoo@outlook.com>
18 months ago[JIT] Fixed improper peephole zero-extension removal when cdq/cwde instructions are...
Will Smith [Sun, 5 Mar 2023 23:54:18 +0000 (15:54 -0800)]
[JIT] Fixed improper peephole zero-extension removal when cdq/cwde instructions are involved (#82733)

* Fixed improper peephole zero-extension removal when cdq/cdqe/cwde instructions are involved

* Update regression test

* Formatting

* Handle cdq differently

* Handle cdq differently

* Handle cdq differently

* Take into account cmpxchg

* Take into account cmpxchg

* Feedback

* Added emitIsInstrWritingToReg. Removed the previously added function.

* Remove function from header

* Quick fix

* Added comment

* Formatting

* Feedback

* Fix build

18 months agoFix BitConverter.ToXx error message (#82987)
Stephen Toub [Sun, 5 Mar 2023 23:36:44 +0000 (18:36 -0500)]
Fix BitConverter.ToXx error message (#82987)

The current message ("Destination array is not long enough to copy all the items in the collection. Check array index and length."), which is otherwise used by CopyTo methods, makes no sense in these APIs. :)

18 months agoAdd NT_SIGINFO NOTE to ELF dumps (#82449)
Mike McLaughlin [Sun, 5 Mar 2023 17:50:49 +0000 (09:50 -0800)]
Add NT_SIGINFO NOTE to ELF dumps (#82449)

* Add NT_SIGINFO NOTE to ELF dumps

Linux Watson needs this to better triage ELF dumps.

Add CreateDumpOptions helper struct to pass all the command options around. Add the
"--code", "--errno", "--address" command line options used to fill the NT_SIGINFO
NOTE. The runtime passes to createdump on a crash.

Added "ExceptionType" field to "Parameters" section of the Linux crash report json.

* Add NT_SIGINFO define

* Code review feedback

18 months agoReplace remaining instances of COMPlus with DOTNET (#82985)
Adeel Mujahid [Sun, 5 Mar 2023 16:40:20 +0000 (18:40 +0200)]
Replace remaining instances of COMPlus with DOTNET (#82985)

* Replace remaining instances of COMPlus with DOTNET

* Fix heading in RyuJIT tutorial

18 months agoReplace some unnecessary use of CompareInfo (#82988)
Stephen Toub [Sun, 5 Mar 2023 05:11:19 +0000 (00:11 -0500)]
Replace some unnecessary use of CompareInfo (#82988)

Anywhere we're explicitly passing Ordinal or OrdinalIgnoreCase, the actual culture data is ignored.  We can just use the relevant string/span methods directly.

18 months agoUpdate dependencies from https://github.com/dotnet/msquic build 20230303.1 (#82979)
dotnet-maestro[bot] [Sun, 5 Mar 2023 05:07:43 +0000 (23:07 -0600)]
Update dependencies from https://github.com/dotnet/msquic build 20230303.1 (#82979)

System.Net.MsQuic.Transport
 From Version 8.0.0-alpha.1.23124.1 -> To Version 8.0.0-alpha.1.23153.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoClean up run.sh documentation (#82983)
Bruce Forstall [Sat, 4 Mar 2023 20:55:37 +0000 (13:55 -0700)]
Clean up run.sh documentation (#82983)

Add line about build configuration.

Fix illink syntax help.

Simplify a couple cases that just set environment variables.

18 months agoUpdate dependencies from https://github.com/dotnet/roslyn build 20230304.2 (#82980)
dotnet-maestro[bot] [Sat, 4 Mar 2023 20:54:28 +0000 (14:54 -0600)]
Update dependencies from https://github.com/dotnet/roslyn build 20230304.2 (#82980)

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-3.23153.1 -> To Version 4.6.0-3.23154.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoFix invariant check in DateTimeParse (#82971)
Stephen Toub [Sat, 4 Mar 2023 19:18:02 +0000 (14:18 -0500)]
Fix invariant check in DateTimeParse (#82971)

18 months agoUpdate dependencies from https://github.com/dotnet/arcade build 20230303.1 (#82978)
dotnet-maestro[bot] [Sat, 4 Mar 2023 18:35:49 +0000 (12:35 -0600)]
Update dependencies from https://github.com/dotnet/arcade build 20230303.1 (#82978)

Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.TargetFramework , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.GenAPI , Microsoft.DotNet.GenFacades , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.SharedFramework.Sdk , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.XUnitExtensions
 From Version 8.0.0-beta.23152.1 -> To Version 8.0.0-beta.23153.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months ago[mono] Fix Hello World sample. (#82977)
Zoltan Varga [Sat, 4 Mar 2023 15:36:11 +0000 (10:36 -0500)]
[mono] Fix Hello World sample. (#82977)

18 months agoRemove dead link (#82972)
Bruce Forstall [Sat, 4 Mar 2023 10:33:03 +0000 (03:33 -0700)]
Remove dead link (#82972)

18 months agoEnable JitDasmWithAlignmentBoundaries and JitDasmWithAddress in Release (#82666)
Egor Bogatov [Sat, 4 Mar 2023 09:40:21 +0000 (10:40 +0100)]
Enable JitDasmWithAlignmentBoundaries and JitDasmWithAddress in Release (#82666)

18 months agoAdd RID for Fedora 39 (#82185)
Omair Majid [Sat, 4 Mar 2023 07:07:20 +0000 (02:07 -0500)]
Add RID for Fedora 39 (#82185)

The changes to runtime.json and runtime.compatibility.json were
generated by tooling.

18 months agoFix the multicore performance of mapping from an instruction pointer to a MethodDesc...
David Wrighton [Sat, 4 Mar 2023 04:50:07 +0000 (20:50 -0800)]
Fix the multicore performance of mapping from an instruction pointer to a MethodDesc (#79021)

Mapping from an instruction pointer to a MethodDesc is a critical component of the runtime used in many places, notably diagnostics, slow path delegate creation, and stackwalking.

This change provides a dramatic improvement in the performance of that logic through several techniques.

1. The mapping from IP to range of interesting memory is done via a tree structure resembling that of a page table. The result of this is that in addition to reducing the locking logic, the cost of looking up in the presence of many different loaded assemblies will be reduced to a nearly constant time.
2. That tree structure is configured so that when accessing memory which will never be freed in the lifetime of the process, the memory can be accessed without taking any locks whatsoever.
3. The code map is enhanced to include not only the code generated by the JIT/R2R code, but also to include the fixup and stub precode stubs.
4. In addition, performance improvement was done to improve the performance of slow path delegate creation in particular, by reordering which checks are done, and by writing a simplified signature parse routine for computing the number of arguments to a function.

Performance of this was tested in both the EH stackwalking scenario as well as the delegate slow path creation scenario, but the delegate logic is what will be most visible when this is checked in. (See PR #79471 for details of the additional changes necessary to take advantage of this work when doing EH) (#8393 describes the potential product impact of just improving the delegate slow path creation code)

For the delegate creation scenario the perf impact was measured to be quite substantial. These numbers are in ms to create a constant number of delegates on each thread used. Smaller is better. The test was run on a 6 core machine.

| Threads | Without fix | With this PR
| ------------- | ------------- | ----- |
| 1  | 840 |  313|
| 2 | 1977 | 316 |
| 3 | 3290 | 325 |
| 4| 4259 | 344 |
| 5 | 5140 | 351 |
| 6 | 5872 | 374|
| 7 | 6463 | 442|
| 8 | 7046 | 499|
| 9 | 7648 | 547|
| 10 | 8241 | 627|
| 11 | 8851 | 749|
| 12 | 9595 | 773|

Fixes #8393

18 months ago[wasm] Improve jiterpreter trace entry point selection heuristic (#82604)
Katelyn Gadd [Sat, 4 Mar 2023 01:07:20 +0000 (17:07 -0800)]
[wasm] Improve jiterpreter trace entry point selection heuristic (#82604)

This PR adjusts the jiterpreter's heuristic that decides where it's best to put entry points:
* Adds a requirement that entry points be at least a certain distance apart, since in some cases we can end up with trace entry points right next to each other, which isn't very useful and adds overhead. (Backwards branch targets are exempted from this so loops will still JIT properly).
* If we fail to create a trace exactly located at a backwards branch target, continue trying at blocks afterward. This should help in the rare case where the body of a loop begins with an unsupported instruction.
* When considering how long a trace actually is, we treat conditional aborts (like calls and throws) separately from ignored and supported instructions, so they don't count towards the overall size of the trace. These instructions aren't actually doing any useful work and if executed the trace will exit, so it's better not to consider them when deciding whether a trace is worth compiling.
This PR also manually inlines trace entry logic.

18 months agoTrim some overheads for "r"/"o" DateTime parsing (#82925)
Stephen Toub [Sat, 4 Mar 2023 01:06:29 +0000 (20:06 -0500)]
Trim some overheads for "r"/"o" DateTime parsing (#82925)

We were doing some unnecessary work on these fast paths.

I also noticed and cleaned up an unnecessary delegate involved in Hebrew number parsing.

18 months agoImplement managed SegmentCommandLine (#82883)
Huo Yaoyuan [Fri, 3 Mar 2023 23:00:07 +0000 (07:00 +0800)]
Implement managed SegmentCommandLine (#82883)

* Implement managed version of SegmentCommandLine

* Remove P/Invoke for CommandLineToArgv

* Update parsing to latest UCRT

* Add test and fix trailing space in command

* Fix test cases

18 months ago[wasm] Debugger tests - fix build (#82958)
Ankit Jain [Fri, 3 Mar 2023 22:27:59 +0000 (17:27 -0500)]
[wasm] Debugger tests - fix build (#82958)

* [wasm] Debugger tests - fix build

`/workspaces/runtime/src/mono/wasm/debugger/DebuggerTestSuite/TestHarnessProxy.cs(135,44): error CS8601: Possible null reference assignment`

Started being hit with https://github.com/dotnet/runtime/pull/82479 .
The other instances of this were fixed in
https://github.com/dotnet/runtime/pull/82803 .

* CI: Trigger all the wasm jobs, when roslyn is updated

And this includes the debugger tests

18 months agoJIT: fix fgDfsReversePostorder (#82950)
Andy Ayers [Fri, 3 Mar 2023 21:56:52 +0000 (13:56 -0800)]
JIT: fix fgDfsReversePostorder (#82950)

This method was not doing a proper depth first search, so the reverse postorder
it created was flawed.

18 months agoFix patterns that defeat resource string optimizations in CoreLib (#82947)
Jan Kotas [Fri, 3 Mar 2023 21:49:41 +0000 (13:49 -0800)]
Fix patterns that defeat resource string optimizations in CoreLib (#82947)

Replace the resource string keys with enums

Fixes #82759

18 months agoFix trim warning in ComponentActivator (#82952)
Elinor Fung [Fri, 3 Mar 2023 21:28:54 +0000 (13:28 -0800)]
Fix trim warning in ComponentActivator (#82952)

* Fix trim warning in ComponentActivator

* Add UnsupportedOSPlatform attributes

18 months ago[wasm] Fix min/max in the jiterpreter (#82955)
Katelyn Gadd [Fri, 3 Mar 2023 21:14:09 +0000 (13:14 -0800)]
[wasm] Fix min/max in the jiterpreter (#82955)

The math intrinsics table had a typo

18 months agouse PlatformSpecific attribute to supress platform specific Quic tests (#82933)
Tomas Weinfurt [Fri, 3 Mar 2023 21:00:24 +0000 (13:00 -0800)]
use PlatformSpecific attribute to supress platform specific Quic tests (#82933)

* use PlatformSpecific attribute to supress platform specific Quic tests

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

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

Co-authored-by: Stephen Toub <stoub@microsoft.com>
18 months agoadd RID for Ubuntu 23.04 (#82284)
Tomas Weinfurt [Fri, 3 Mar 2023 20:13:53 +0000 (12:13 -0800)]
add RID for Ubuntu 23.04 (#82284)

* add RID for Ubuntu 23.04

* fix resolve

18 months ago[browser] legacy JS interop optional via WasmEnableLegacyJsInterop - native part...
Pavel Savara [Fri, 3 Mar 2023 19:24:37 +0000 (20:24 +0100)]
[browser] legacy JS interop optional via WasmEnableLegacyJsInterop - native part (#82834)

18 months ago[main] Update dependencies from dotnet/roslyn (#82479)
dotnet-maestro[bot] [Fri, 3 Mar 2023 19:17:23 +0000 (13:17 -0600)]
[main] Update dependencies from dotnet/roslyn (#82479)

* Update dependencies from https://github.com/dotnet/roslyn build 20230221.6

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-2.23120.1 -> To Version 4.6.0-2.23121.6

* Update dependencies from https://github.com/dotnet/roslyn build 20230222.3

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23122.3

* Update dependencies from https://github.com/dotnet/roslyn build 20230223.15

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23123.15

* Update dependencies from https://github.com/dotnet/roslyn build 20230225.1

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23125.1

* Update dependencies from https://github.com/dotnet/roslyn build 20230226.1

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23126.1

* Update dependencies from https://github.com/dotnet/roslyn build 20230226.2

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23126.2

* Update dependencies from https://github.com/dotnet/roslyn build 20230228.2

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23128.2

* Update dependencies from https://github.com/dotnet/roslyn build 20230301.1

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-2.23151.1

* Update dependencies from https://github.com/dotnet/roslyn build 20230302.1

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-3.23152.1

* Update dependencies from https://github.com/dotnet/roslyn build 20230303.1

Microsoft.CodeAnalysis , Microsoft.CodeAnalysis.CSharp , Microsoft.Net.Compilers.Toolset
 From Version 4.6.0-1.23073.4 -> To Version 4.6.0-3.23153.1

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
18 months ago[wasm] Implement more jiterpreter opcodes (#82940)
Katelyn Gadd [Fri, 3 Mar 2023 16:59:02 +0000 (08:59 -0800)]
[wasm] Implement more jiterpreter opcodes (#82940)

* Implement a bunch of missing math opcodes like exp, log and pow
* Implement STELEM_VT

18 months ago[main] Update dependencies from 9 repositories (#82600)
dotnet-maestro[bot] [Fri, 3 Mar 2023 16:44:57 +0000 (17:44 +0100)]
[main] Update dependencies from 9 repositories (#82600)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
18 months agoGuard more COM interop related code (#82882)
Huo Yaoyuan [Fri, 3 Mar 2023 16:27:00 +0000 (00:27 +0800)]
Guard more COM interop related code (#82882)

18 months agoNullable annotation fixes (#82803)
Jared Parsons [Fri, 3 Mar 2023 16:01:43 +0000 (08:01 -0800)]
Nullable annotation fixes (#82803)

* Nullable annotation fixes

Once runtime merges to a Roslyn toolset that has the fix for [issue
50782](https://github.com/dotnet/roslyn/issues/50782) these annotations
will be necessary. Front loading the work here with this change.

* Apply suggestions from code review

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

Co-authored-by: Stephen Toub <stoub@microsoft.com>
18 months ago[main] Update dependencies from dotnet/arcade (#82764)
dotnet-maestro[bot] [Fri, 3 Mar 2023 15:57:34 +0000 (16:57 +0100)]
[main] Update dependencies from dotnet/arcade (#82764)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoRemove cached RW mapping when the corresponding RX one is released (#82841)
Jan Vorlicek [Fri, 3 Mar 2023 15:40:52 +0000 (16:40 +0100)]
Remove cached RW mapping when the corresponding RX one is released (#82841)

When a RX mapping in the ExecutableAllocation is released and there is a
RW mapping cached for it, it incorrectly stays in the cache. So when the
same virtual address range that was just released gets reserved again
and a request to get RW mapping comes in, the cached RW mapping is used.
But it is likely that the new RX mapping has a different offset in the
underlying file mapping and thus the RW mapping is unrelated to the new
RX mapping. Using this RW mapping results either in an overwrite of a
different block of memory or just a silent dropping of what's written.

This was discovered when investigating a GC reliability framework crash.
It turned out it was also the culprit behind the #75244 issue that I
was unable to reproduce and it kept  occuring in the CI on x86 only for
quite some time.

In addition to the fix, I've found that there was an off by one
condition in the ExecutableAllocator::FindRWBlock so I've fixed that.
And I've also noticed that in UnlockedLoaderHeap::UnlockedReservePages,
if the allocation of LoaderHeapBlock failed, we would leave the data
block incorrectly on the m_pRangeList. I've fixed that too.

Close #75244

18 months agoFix typo in SingleEntry.targets property (#82935)
Adeel Mujahid [Fri, 3 Mar 2023 15:17:52 +0000 (17:17 +0200)]
Fix typo in SingleEntry.targets property (#82935)

18 months agoSupport raw ECDH key agreements
Kevin Jones [Fri, 3 Mar 2023 14:54:13 +0000 (09:54 -0500)]
Support raw ECDH key agreements

18 months ago[browser] Calculate hash for runtime assets (#82891)
Pavel Savara [Fri, 3 Mar 2023 13:18:24 +0000 (14:18 +0100)]
[browser] Calculate hash for runtime assets (#82891)

* hash assets and IL check
* @thaystg feedback about webcil hash
* @radical feedback

18 months agoIssue correct Enable/Disable commands for EventSources with EventPipe (#81867)
David Mason [Fri, 3 Mar 2023 12:05:09 +0000 (04:05 -0800)]
Issue correct Enable/Disable commands for EventSources with EventPipe (#81867)

18 months agoAllow default AsyncFlowControls rather than throwing (#82912)
Stephen Toub [Fri, 3 Mar 2023 11:43:56 +0000 (06:43 -0500)]
Allow default AsyncFlowControls rather than throwing (#82912)

ExecutionContext.SuppressFlow currently throws an exception if flow is already suppressed.  This makes it complicated to use, as you need to check whether IsFlowSuppressed first and take two different paths based on the result.  If we instead just allow SuppressFlow to return a default AsyncFlowControl rather than throwing, and have AsyncFlowControl's Undo nop rather than throw if it doesn't contain a Thread, we can again make it simple to just always use SuppressFlow without any of the other complications.

18 months ago[Mono] Enable runtime tests running on arm64 with mini JIT (#82814)
Fan Yang [Fri, 3 Mar 2023 09:55:38 +0000 (04:55 -0500)]
[Mono] Enable runtime tests running on arm64 with mini JIT (#82814)

* Enable runtime tests running on arm64 with mini JIT

* Disable failed tests

* Add tracking issue link

* Disable one more failing test

18 months ago[jiterp] Perform a single unsigned bounds check for ldelema1 (#82919)
Katelyn Gadd [Fri, 3 Mar 2023 09:40:06 +0000 (01:40 -0800)]
[jiterp] Perform a single unsigned bounds check for ldelema1 (#82919)

Array and Span both have a uint32_t length field (at least as far as wasm is concerned). If index is signed and we do an unsigned index <= length then any negative index will be treated as a massive value. For arrays it appears to be safe to exploit this and not do the >= 0 check, and interp.c doesn't do it.

18 months agoFixing a bug that causes us to mistakenly demote a gen2 region to gen0 (#82413)
Maoni Stephens [Fri, 3 Mar 2023 08:38:01 +0000 (00:38 -0800)]
Fixing a bug that causes us to mistakenly demote a gen2 region to gen0 (#82413)

We are seeing a gen0 region that's almost fully occupied (< 24 bytes free) with one giant plug (ie, no free objects at all in the region). This causes allocate_in_condemned_generations to go into an infinite loop because in ephemeral generations we expect short plugs, ie, we should be able to allocate a min free object in front of each plug. And normally we can because when we allocate objects in gen0 we make sure to break up the allocation contexts with min free objects and when we compact into gen1 we form short plugs.

We are in this situation when all of the following conditions are true -

+ we did a gen2 compacting GC that generates a pinned plug in a gen2 region almost as big as the whole region. my guess for the reason why there's this giant pinned plug is because that gen2 region was already really compact so when we called allocate_in_condemned_generations on the non pinned plugs that are next to some pinned plugs in it we discovered we can't move the non pinned plugs anyway so we artificially pinned them and formed a giant pinned plug. and during this GC those objects were no longer pinned so we have one giant non pinned plug.
+ this gen2 region needs to be the last region with pinned plugs;
+ this gen2 region hasn't been consumed by allocate_in_condemned_generations yet so it was processed by process_remaining_regions;

Then in process_remaining_regions we'll set the plan_gen_num for that gen2 region to 0 because we are doing

set_region_plan_gen_num_sip (current_region, current_plan_gen_num);

and next time we do a GC, this plug is no longer pinned (and still survived) so we call  allocate_in_condemned_generations on it which causes the infinite loop.

instead of going through the demotion logic to decide whether we should demote this region or not.

18 months agoImplement interfaces in the non-generic enumerator base (#82923)
Michal Strehovský [Fri, 3 Mar 2023 04:19:26 +0000 (13:19 +0900)]
Implement interfaces in the non-generic enumerator base (#82923)

* Implement IDisposable in the non-generic enumerator base

...so that the interface implementation details go to the non-generic dispatch map.

Saves 1.5 kB on BasicMinimalApi.

* f

18 months agoFix a few async void tests to be async Task (#82914)
Stephen Toub [Fri, 3 Mar 2023 04:15:36 +0000 (23:15 -0500)]
Fix a few async void tests to be async Task (#82914)

18 months agoRevert "Enable symbol stripping for crossgen2 (#82698)" (#82881)
Adeel Mujahid [Fri, 3 Mar 2023 03:36:19 +0000 (05:36 +0200)]
Revert "Enable symbol stripping for crossgen2 (#82698)" (#82881)

This reverts commit 6a218ab799e56d4ebaffda550de06a9a73a88b14.

18 months agoImprove DateTime.ParseExact perf for invariant culture (#82877)
Stephen Toub [Fri, 3 Mar 2023 02:46:31 +0000 (21:46 -0500)]
Improve DateTime.ParseExact perf for invariant culture (#82877)

* Improve DateTime parsing perf for invariant culture

Speed up the handling of ddd, dddd, MMM, and MMMM parts of a date time format string when using the invariant culture, which is very commonly used in parsing.  Today, when one of these is encountered, the relevant array of comparison strings is retrieved from the DateTimeFormatInfo, and each is compared as a prefix against the current position in the input, using a linguistic ignore-case comparison.  But for the invariant culture, we don't need to consult any arrays, and can do the comparison much more quickly.  These parts dominate the processing of a format like that for RFC1123.

* Address PR feedback

18 months agoSubstitute out geopolitical term in TimeZoneInfo (#82916)
Mitchell Hwang [Fri, 3 Mar 2023 01:35:24 +0000 (20:35 -0500)]
Substitute out geopolitical term in TimeZoneInfo (#82916)

18 months agoDisable SupportedWindowsPlatforms_IsSupportedIsTrue on Windows Arm64 (#82902)
Natalia Kondratyeva [Thu, 2 Mar 2023 23:44:54 +0000 (00:44 +0100)]
Disable SupportedWindowsPlatforms_IsSupportedIsTrue on Windows Arm64 (#82902)

18 months ago[mono][aot] Emit cctor instantiations for classes referenced by gshared methods....
Zoltan Varga [Thu, 2 Mar 2023 23:38:58 +0000 (18:38 -0500)]
[mono][aot] Emit cctor instantiations for classes referenced by gshared methods. (#82900)

18 months ago[mono][aot] Emit a list of exported methods into the AOT image and load them when...
Zoltan Varga [Thu, 2 Mar 2023 23:38:35 +0000 (18:38 -0500)]
[mono][aot] Emit a list of exported methods into the AOT image and load them when the image is loaded. (#82809)

If there is a runtime attach function specified, these methods can call into the runtime
before its initialized. In order for this to work, the runtime attach function needs
to load all the AOT images containing such methods, and load_aot_module () will
load and initialize these methods using the newly emitted table.

18 months agoEventPipe env var to disable stack collection (#82470)
David Mason [Thu, 2 Mar 2023 23:02:42 +0000 (15:02 -0800)]
EventPipe env var to disable stack collection (#82470)

18 months agoMark some internal/private structs as readonly (#82415)
Stephen Toub [Thu, 2 Mar 2023 22:32:57 +0000 (17:32 -0500)]
Mark some internal/private structs as readonly (#82415)

* Mark some internal/private structs as readonly

* Address PR feedback

18 months ago[wasi] CI: Provision `wasi-sdk`, and `wasmtime` only when needed (#82454)
Ankit Jain [Thu, 2 Mar 2023 21:59:25 +0000 (16:59 -0500)]
[wasi] CI: Provision `wasi-sdk`, and `wasmtime` only when needed (#82454)

* [wasm] Install wasi-sdk, and wasmtime on CI only if needed

* Add generic support for staging helix payloads

For a directory specified as a helix correlation payload, the helix
tasks will attempt to write a `.payload` file to the directory. But if the
directory is not writable then we need to stage the payload in a
writable location, before passing the path to helix.

For example, if we have `wasi-sdk` installed on the system as:
    `WASI_SDK_PATH=/usr/local/wasi-sdk`

.. then we can stage it by copying to
`artifacts/obj/helix-staging/wasi-sdk`, and then using that staging path
for the helix correlation payload.

This was already being done for `EMSDK`, and `WasiSdk` in two separate
targets. And now needs to be done for `wasmtime` also. Instead of having
completely separate targets for all this, add a new mechanism to specify
helix dependencies to stage.

For example:
```xml
  <ItemGroup>
    <HelixDependenciesToStage Condition="'$(NeedsWasmtime)' == 'true'" SourcePath="$(WasmtimeDir)"   Include="$(WasmtimeDirForHelixPayload)" />
  </ItemGroup>
```

.. and the payload can use specified as
```xml
<HelixCorrelationPayload Include="$(WasmtimeDirForHelixPayload)" Destination="wasmtime" Condition="'$(NeedsWasmtime)' == 'true'" />
```

* [wasm] CI: Fix path for wasi artifacts

These were getting created with all the wasi builds sharing the same
prefixes causing them to get overwritten.

18 months ago[wasm] Fix tests substitution conditions (#82901)
Radek Doulik [Thu, 2 Mar 2023 21:55:28 +0000 (22:55 +0100)]
[wasm] Fix tests substitution conditions (#82901)

PR #82886 fixed it for user builds, we should fix it for tests as well.

18 months agoAdd dedicated empty array enumerator for footprint reduction (#82899)
Stephen Toub [Thu, 2 Mar 2023 21:19:51 +0000 (16:19 -0500)]
Add dedicated empty array enumerator for footprint reduction (#82899)

* Add dedicated empty array enumerator for footprint reduction

Its singleton can be used in places where it's less likely the consumer will otherwise be using a T[], such that it's less likely we'll need to generate code for T[].

* Address PR feedback

18 months agoIntroducing ValidateOptionsResultBuilder (#82749)
Tarek Mahmoud Sayed [Thu, 2 Mar 2023 21:15:32 +0000 (13:15 -0800)]
Introducing  ValidateOptionsResultBuilder (#82749)

18 months agoMark Microsoft.NET.ILLink as non-shipping (#82905)
Sven Boemer [Thu, 2 Mar 2023 19:59:08 +0000 (11:59 -0800)]
Mark Microsoft.NET.ILLink as non-shipping (#82905)

This package should not be published to nuget. It is only used by xamarin, and contains the API surface for custom illink steps.

18 months ago[iOS][maccatalyst] Disable MacCatalyst and Simulator CI runs (#82915)
Steve Pfister [Thu, 2 Mar 2023 19:58:37 +0000 (14:58 -0500)]
[iOS][maccatalyst] Disable MacCatalyst and Simulator CI runs (#82915)

The work items for these configurations are failing at a high rate and causing numerous retries. Disabling temporarily to see if that helps queue traffic stabilize.

18 months agoFix string allocation in DateTimeParse.ParseByFormat (#82861)
Stephen Toub [Thu, 2 Mar 2023 19:39:50 +0000 (14:39 -0500)]
Fix string allocation in DateTimeParse.ParseByFormat (#82861)

If a quote is encountered, the parser searches for the ending quote while also handling escaped characters.  It does by adding the interim characters to a temporary ValueStringBuilder.  But it then ToString's that builder to produce a temporary string that's examined.  This is unnecessary: we can just examine the span from the VSB directly.

18 months agoStore Parallel.ForEachAsync exceptions from cancellation callbacks (#82434)
Stephen Toub [Thu, 2 Mar 2023 19:28:06 +0000 (14:28 -0500)]
Store Parallel.ForEachAsync exceptions from cancellation callbacks (#82434)

* Store Parallel.ForEachAsync exceptions from cancellation callbacks

If a cancellation callback erroneously throws an exception, make sure we store it into the list of exceptions used to complete the resulting task. In most cases, this just means we may not be returning _all_ exceptions when there are multiple.  If, however, disposal of the enumerator throws an exception and a cancellation callback throws an exception and no exceptions were thrown from the loop body, without this change the task returned from ForEachAsync likely won't be marked completed.

* Update src/libraries/System.Threading.Tasks.Parallel/tests/ParallelForEachAsyncTests.cs

18 months agoStop storing the parsed RID fallback graph (#82811)
Elinor Fung [Thu, 2 Mar 2023 19:21:16 +0000 (11:21 -0800)]
Stop storing the parsed RID fallback graph (#82811)

After startup, we only need the RID fallback graph from the root framework for component dependency resolution (AssemblyDependencyResolver). This change stops storing that graph (which is decently large for portable linux) for all applications and switches to re-populating it on demand.

Removing this stored value also lines up with the plan to move to algorithmic RID selection rather than reading from the .deps.json.

18 months agodisable tests on Server 2022 with spanish locale (#82578)
Tomas Weinfurt [Thu, 2 Mar 2023 18:22:31 +0000 (10:22 -0800)]
disable tests on Server 2022 with spanish locale (#82578)

* disable tests on Server 2022 with spanish locale

* update name

18 months agoAppend version to RID only with valid characters (#81497)
Adeel Mujahid [Thu, 2 Mar 2023 17:44:02 +0000 (19:44 +0200)]
Append version to RID only with valid characters (#81497)

This is the `init-distro-rid.sh` counterpart of 31e4f404c218eae7ba999c4df5346d30f971451c.

In `amd64/archlinux` docker container, the non-portable RID auto-detection (without explicit `-p:TargetRid=arch-x64` arg or `__DistroRid=arch-x64` env var) looks like this:

Before: `__DistroRid: arch.TEMPLATE_VERSION_ID-x64`
After: `__DistroRid: arch-x64`

18 months ago[workloads] Upstream workload fixes from 7.0 (#82069)
Steve Pfister [Thu, 2 Mar 2023 17:22:38 +0000 (12:22 -0500)]
[workloads] Upstream workload fixes from 7.0 (#82069)

Upstreamed from #75486

- The updated task now provides metadata that will allow us to split the VSDROP generation into two separate archives.
  One which only contains workload packs (needed to share DROPs across VS versions to support multi-targeting) and
  another that only contains the manifest installers and workload components.

- The ZIP archive names have been updated to disambiguate its contents and support automatic drop creation during
   staging.

Most of the changes are in eng due to the Arcade update to obtain the latest copy of the workload build tasks. Those changes are unrelated to the workload fix, but appears to be necessary.

Co-authored-by: Jacques Eloff <joeloff@users.noreply.github.com>
18 months agoEventPipe lock implementation (#82790)
Lakshan Fernando [Thu, 2 Mar 2023 17:08:32 +0000 (09:08 -0800)]
EventPipe lock implementation (#82790)

* EventPipe lock implementation

* FB

18 months agoFix Icon(Stream) handling of partial reads (#82621)
Stephen Toub [Thu, 2 Mar 2023 17:04:28 +0000 (12:04 -0500)]
Fix Icon(Stream) handling of partial reads (#82621)

Icon's ctor assumes Read on a stream will always produce as much data as was asked for, and that's not guaranteed to be the case.

18 months agoFix SoundPlayer handling of partial reads on streams (#82612)
Stephen Toub [Thu, 2 Mar 2023 17:02:29 +0000 (12:02 -0500)]
Fix SoundPlayer handling of partial reads on streams (#82612)

SoundPlayer assumes that a Read on a stream will return everything asked for, and that's not the case.

18 months ago[wasm] Avoid unnecessary relinking when publishing a blazor project for AOT (#82748)
Ankit Jain [Thu, 2 Mar 2023 17:02:12 +0000 (12:02 -0500)]
[wasm] Avoid unnecessary relinking when publishing a blazor project for AOT (#82748)

* [wasm] Wasm.Build.Tests: Add blazor+aot run test

* cleanup

* [wasm] Wasm.Build.Tests: Use $(_IsPublishing) to avoid unncessary

.. relinking during "Build", when publishing.

`Publish` target triggers `Build` target to run. When publishing, we
don't want to run relinking step during the `Build`, as it will be run
for `Publish` anyway. Earlier there wasn't a good way to differentiate
the two cases of `build` when building, and `build` when publishing, but
now the sdk sets `$(_IsPublishing)=true`, which can be used here.

* fix blazor tests

* Wasm.Build.Tests: Add support for running published blazor projects

`dotnet run` uses the regular build output. Published blazor app, like
when using AOT, needs to be run more "manually" by starting a web server
in the publish folder. This is accomplished here by using the new
xharness command `wasm webserver`.

* Detect runtime assertions in blazor runs

* Update test to track changes

* cleanup

* Disable BlazorPublishRunTest because of https://github.com/dotnet/runtime/issues/82481

* Update test to track changes

* Update xharness dependency

Updating 'Microsoft.DotNet.XHarness.CLI': '1.0.0-prerelease.23117.1' => '1.0.0-prerelease.23151.1' (from build '20230301.1' of 'https://github.com/dotnet/xharness')
Updating 'Microsoft.DotNet.XHarness.TestRunners.Common': '1.0.0-prerelease.23117.1' => '1.0.0-prerelease.23151.1' (from build '20230301.1' of 'https://github.com/dotnet/xharness')
Updating 'Microsoft.DotNet.XHarness.TestRunners.Xunit': '1.0.0-prerelease.23117.1' => '1.0.0-prerelease.23151.1' (from build '20230301.1' of 'https://github.com/dotnet/xharness')

18 months agoAdd PeriodicTimer.Period property (#82560)
Stephen Toub [Thu, 2 Mar 2023 17:01:06 +0000 (12:01 -0500)]
Add PeriodicTimer.Period property (#82560)

18 months agoMove throw out of inlined CompositeFormat helper (#82543)
Stephen Toub [Thu, 2 Mar 2023 16:56:53 +0000 (11:56 -0500)]
Move throw out of inlined CompositeFormat helper (#82543)

Either this helper isn't getting inlined because of the throw, or it's getting inlined and increasing the size of all call sites where it is.

18 months agoCombine ExecutionContext/CapturedContext fields in ManualResetValueTaskSourceCore...
Stephen Toub [Thu, 2 Mar 2023 16:41:25 +0000 (11:41 -0500)]
Combine ExecutionContext/CapturedContext fields in ManualResetValueTaskSourceCore (#82181)

There's currently an _executionContext field and a _capturedContext field.  Both of these are for non-fast-path.  This not only means the struct is larger than is necessary for the common case, it also means when we reset the instance between operations we need to clear an extra field, and it means we have an extra branch on some paths to check both fields.

We can instead combine them into a single field.  We allocate an extra tuple object if there's both an ExecutionContext and a scheduler, but this is exceedingly rare: when used as part of awaits, there will never be an ExecutionContext, so this will only happen in situations where someone is directly using the awaiter's OnCompleted (not UnsafeOnCompleted) method and there's a scheduler and ConfigureAwait(false) wasn't used.  Such a situation not only is rare, it also already has additional overheads.

This also cleans up a bit about how exceptions are handled and moves more logic out of the generic type to avoid code bloat with generic instantiations.

18 months agoGlossary: Change SoS link to documentation and describe origin in description. (Was...
Kasper Fabæch Brandt [Thu, 2 Mar 2023 16:32:01 +0000 (17:32 +0100)]
Glossary: Change SoS link to documentation and describe origin in description. (Was: Change source for SoS to Wayback Machine link) (#81178)

* Glossary: Change source for SoS to Wayback Machine link

The page seems to have disappeared in the currently archived version of Jason Zander's blog at https://learn.microsoft.com/en-us/archive/blogs/jasonz/ - so replace it with a Wayback Machine link to an archived version.

* Link to official documentation for SOS instead and mention origin of name in the description.

18 months agodisable SendFileGetsCanceledByDispose also on Catalyst (#82782)
Tomas Weinfurt [Thu, 2 Mar 2023 16:31:38 +0000 (08:31 -0800)]
disable SendFileGetsCanceledByDispose also on Catalyst (#82782)

* disable SendFileGetsCanceledByDispose also on Catalyst

* Update src/libraries/System.Net.Sockets/tests/FunctionalTests/SendFile.cs

Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
* fix build

---------

Co-authored-by: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
18 months agoUse shared IValueTaskSource implementation in AwaitableSocketAsyncEventArgs (#82147)
Stephen Toub [Thu, 2 Mar 2023 16:26:01 +0000 (11:26 -0500)]
Use shared IValueTaskSource implementation in AwaitableSocketAsyncEventArgs (#82147)

The upside here is we don't need a dedicated implementation with complicated logic inside of Socket.  The downside is this effectively increases the allocation for a Socket by a few fields, as the shared implementation has a few extra fields that go unused.

18 months agoPass wasi invariant mode through env variable (#82707)
Meri Khamoyan [Thu, 2 Mar 2023 15:32:05 +0000 (19:32 +0400)]
Pass wasi invariant mode through env variable (#82707)

Pass wasi invariant mode through env variable

18 months ago[mono][interp] Fix incorrect masking (#82890)
Vlad Brezae [Thu, 2 Mar 2023 14:32:21 +0000 (16:32 +0200)]
[mono][interp] Fix incorrect masking (#82890)

* [mono][interp] Fix incorrect masking

* [mono][interp] Fix warning

18 months agoActiveIssue for BuildInvalidSignatureTwice on mono interpreter. (#82864)
Kevin Jones [Thu, 2 Mar 2023 14:31:26 +0000 (09:31 -0500)]
ActiveIssue for BuildInvalidSignatureTwice on mono interpreter. (#82864)

18 months agoUpdate keywords. (#82896)
Ilona Tomkowicz [Thu, 2 Mar 2023 14:30:30 +0000 (15:30 +0100)]
Update keywords. (#82896)

18 months agoAdd MemoryExtensions.AsSpan(string, Index/Range) (#82794)
Stephen Toub [Thu, 2 Mar 2023 14:22:24 +0000 (09:22 -0500)]
Add MemoryExtensions.AsSpan(string, Index/Range) (#82794)

18 months agoSimplify IndexOfAnyAsciiByteValues for needles with 0 on X86 (#82866)
Miha Zupan [Thu, 2 Mar 2023 14:21:20 +0000 (15:21 +0100)]
Simplify IndexOfAnyAsciiByteValues for needles with 0 on X86 (#82866)

18 months agoHave bool and string implement ISpanParsable<T> (#82836)
Tanner Gooding [Thu, 2 Mar 2023 13:45:45 +0000 (05:45 -0800)]
Have bool and string implement ISpanParsable<T> (#82836)

18 months ago[wasm] Fix intrinsics substitution condition (#82886)
Radek Doulik [Thu, 2 Mar 2023 13:33:42 +0000 (14:33 +0100)]
[wasm] Fix intrinsics substitution condition (#82886)

Enable substitutions for SIMD only for AOT and not interpreter

18 months agoAvoid trying to get callstack[0] when it's empty like in an instrumentation pause...
Thays Grazia [Thu, 2 Mar 2023 13:25:52 +0000 (10:25 -0300)]
Avoid trying to get callstack[0] when it's empty like in an instrumentation pause (#82852)

18 months ago[mono] Move networking code to debugger component (#82785)
Alexander Köplinger [Thu, 2 Mar 2023 11:15:04 +0000 (12:15 +0100)]
[mono] Move networking code to debugger component (#82785)

The debugger is the only component left in Mono using the networking code, move the code there so we can avoid compiling it into the main runtime and also simplify it a bit.

18 months ago[browser] remove unused methods (#82865)
Pavel Savara [Thu, 2 Mar 2023 09:08:06 +0000 (10:08 +0100)]
[browser] remove unused methods (#82865)

18 months agoEnable symbol stripping for crossgen2 (#82698)
Adeel Mujahid [Thu, 2 Mar 2023 05:50:14 +0000 (07:50 +0200)]
Enable symbol stripping for crossgen2 (#82698)

18 months agoAdd OS/architecture specific CLRDEBUGINFO resource (#82863)
Mike McLaughlin [Thu, 2 Mar 2023 04:26:55 +0000 (20:26 -0800)]
Add OS/architecture specific CLRDEBUGINFO resource (#82863)

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

18 months agoUnify Array enumerators between CoreCLR and NativeAOT (#82751)
Jan Kotas [Thu, 2 Mar 2023 04:00:33 +0000 (20:00 -0800)]
Unify Array enumerators between CoreCLR and NativeAOT (#82751)

* Unify Array enumerators between CoreCLR and NativeAOT

Contributes to #82732

Reduces BasicMinimalApi native AOT size on Windows x64 by 68kB

* Update AOT compiler

* Naming convention

Co-authored-by: Stephen Toub <stoub@microsoft.com>
18 months agoFixed name of frozen string dictionary files (#82482)
PascalSenn [Thu, 2 Mar 2023 02:34:06 +0000 (03:34 +0100)]
Fixed name of frozen string dictionary files (#82482)

* Fixed name of frozen string dictionary types

* Add missing file renames

18 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 212592...
dotnet bot [Thu, 2 Mar 2023 02:13:48 +0000 (18:13 -0800)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2125925 (#82869)

18 months agoTry skipping generation of empty method dictionaries (#82591)
Michal Strehovský [Thu, 2 Mar 2023 01:15:31 +0000 (10:15 +0900)]
Try skipping generation of empty method dictionaries (#82591)

Say we're compiling `Foo<__Canon>.Method` for:

```csharp
class Foo<T>
{
    static void Method() => GenericMethod<List<T>>();
    static void GenericMethod<T>() { }
}
```

In the method body, we're generating a call to `GenericMethod<__Canon>` with a generic dictionary that we looked up from `Foo`s dictionary. But as you can see, the dictionary is empty because `GenericMethod` doesn't do anything with it's T. RyuJIT might even inline it.

The problem is that we computed how the dictionary will look like during scanning and we're forever stuck with instruction to generate a generic dictionary for every `Foo<T>` instantiation.

This is adding an optimization - if during scanning we find out that the dictionary layout of the target method is empty, we instruct RyuJIT to generate a null generic context pointer.

Saves 1.5% on BasicMinimalApi.

Cc @dotnet/ilc-contrib

18 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 212215...
dotnet bot [Thu, 2 Mar 2023 00:24:07 +0000 (16:24 -0800)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2122151 (#81871)

Co-authored-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
18 months agoImplement load_assembly delegate for hosting API (#82797)
Elinor Fung [Wed, 1 Mar 2023 22:50:04 +0000 (14:50 -0800)]
Implement load_assembly delegate for hosting API (#82797)

18 months ago[wasm] Implement more jiterpreter opcodes (#82849)
Katelyn Gadd [Wed, 1 Mar 2023 22:00:31 +0000 (14:00 -0800)]
[wasm] Implement more jiterpreter opcodes (#82849)

Implement the following opcodes:
* MINT_NEWSTR
* MINT_ARRAY_ELEMENT_SIZE
* MINT_DIV_I8
* MINT_REM_I8

18 months agoJIT: Unify arm64 and x64 GT_SELECT handling (#82610)
Jakob Botsch Nielsen [Wed, 1 Mar 2023 21:04:39 +0000 (22:04 +0100)]
JIT: Unify arm64 and x64 GT_SELECT handling (#82610)

This unifies GT_SELECT/GT_SELECTCC handling between arm64 and x64. The
arm64 backend no longer uses containment for compare chains; instead,
there is a new GT_CCMP node that both produces and consumes flags, and
lowering can lower GT_AND(op, relop) down to this node.

18 months agoCheck for pending IO in the portable thread pool's worker threads (#82245)
Koundinya Veluri [Wed, 1 Mar 2023 17:53:50 +0000 (09:53 -0800)]
Check for pending IO in the portable thread pool's worker threads (#82245)

* Check for pending IO in the portable thread pool's worker threads

- When Resource Monitor is attached, some async IO operations are bound to the thread that issued it even though the IO handle is bound to an IOCP. If the thread exits, the async IO operation is aborted. This can lead to hangs or unexpected exceptions.
- Added a check that was missing in the portable thread pool implementation to prevent exiting a worker thread when it has pending IO

Fixes https://github.com/dotnet/runtime/issues/82207

18 months ago[wasm] Enable SIMD (#80797)
Radek Doulik [Wed, 1 Mar 2023 17:31:15 +0000 (18:31 +0100)]
[wasm] Enable SIMD (#80797)

* [wasm] Enable SIMD

* Let old V8 use simd

Co-authored-by: Ankit Jain <radical@gmail.com>
* [wasm] ManagedToNativeGenerator: Skip unmanaged dlls

.. instead crashing with an exception like:

```
src/mono/wasm/build/WasmApp.Native.targets(296,5): error MSB4018: (NETCORE_ENGINEERING_TELEMETRY=Build) The "ManagedToNativeGenerator" task failed unexpectedly.
System.BadImageFormatException: This PE image is not a managed executable.
   at System.Reflection.MetadataLoadContext.LoadFromStreamCore(Stream peStream)
   at System.Reflection.MetadataLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at PInvokeTableGenerator.Generate(String[] pinvokeModules, String[] assemblies, String outputPath) in /_/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 42
   at ManagedToNativeGenerator.ExecuteInternal() in /_/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs:line 68
   at ManagedToNativeGenerator.Execute() in /_/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs:line 53
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask)
```

The wasm targets currently are not able to differentiate the managed
assemblies from the unmanaged ones. so it needs to be handled here.

* [wasm] WasmApp.Native.targets: do not trigger relinking when WasmEnableSIMD=true

Instead, let the property be effective only for the AOT case.

* Use staging image with newer v8

* [wasm] WasmAppHost: Add support for host arguments

* [wasm] console template: Add --experimental-wasm-simd to node, and remove v8 config as that isn't supported

* [wasm] Pass --experiment-wasm-simd for aot library tests too

* Try to pass full path to v8

Also remove --experimental-wasm-simd option, which shouldn't be needed
for newer v8

* Use docker image for all wasm helix jobs

As we need newer v8

* Set DOTNET_CLI_HOME under workitem payload

The correlation payload is read only

* Revert "Try to pass full path to v8"

This reverts commit a15b3ef5dcab31b0abe2bc914eee6299df7cf56f.

* Use DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

Let see whether it will avoid all the writes to correlation payload
path

* Set NeedsEMSDKNode to false

To try if we can use newer node in path

* Revert "Set DOTNET_CLI_HOME under workitem payload"

This reverts commit 5dec1aaab403f4cbbd7b0e9f03d965e96efde51c.

* Set DOTNET_CLI_HOME under workitem payload

The correlation payload is read only. And even with
`export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1` we have still many
failures.

* Reverse the test here as we don't relink anymore

* Set _ExtraTrimmerArgs for tests

So that linker substitution files are used

* Put the SIMD/trim related props in separate group

More changes from Ankit

* Add dynamic dependency

* Disable Vector128IsHardwareAcceleratedTest

Til we have the interpreter support in place

* Disable GenericVectorTests.IsHardwareAcceleratedTest

Til we have the interpreter support in place

* Disable check_no_intrinsic_cattr in emit_vector_2_3_4

And add note about opened issue

* [mono] Disable few quaternion intrinsics

For * and / operators as these are not the same as vector operations.
Opened https://github.com/dotnet/runtime/issues/82408 to implement
correct ones in future.

* Change comparison order

* Use stable images

* WBT: Add --engine-arg=--experimental-wasm-simd for node, and v8

* Do not skip dotnet 1st time experience anymore

---------

Co-authored-by: Ankit Jain <radical@gmail.com>
18 months ago[wasm] Add an internal GC lock API (#82646)
Aleksey Kliger (λgeek) [Wed, 1 Mar 2023 16:03:52 +0000 (11:03 -0500)]
[wasm] Add an internal GC lock API  (#82646)

The goal is to provide an API that can be called from JS to block a background GC from moving objects that may be accessed unsafely from JS.  Blazor does this during rendering - it traverses a set of rendering objects from JS in order to apply changes to the DOM.

Important notes for consumers of this API:
1. While the runtime GC lock is locked, calling any C# function or doing anything that may trigger managed allocation will block the runtime.
2. In a threaded build, only the main browser thread is allowed to call the `mono_wasm_gc_lock` function
3. The runtime lock is not recursive
4. Background threads initially continue running, so the managed object graph may change even while the GC lock is held (although objects may not move).  Background threads could mutate valuetype fields of reachable objects, even while the GC lock is held. However background threads will block as soon as they try to do any allocation.
5. The main browser thread may assume that managed heap objects will not move while the lock is held.

The corresponding aspnetcore API is https://github.com/dotnet/aspnetcore/pull/46909

* add wasm entrypoints to lock the GC from JS
* move gc lock api to INTERNAL object
* enter GC Unsafe before manipulating the locks

   This is an exported API, so we're normally in GC Safe mode on entry