Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] Using BufferedStream #4

Closed
wants to merge 10 commits into from

Conversation

adamsitnik
Copy link
Owner

@carlossanlop @Jozkee @stephentoub Please note that this PR is not even a draft, it's a PR in my fork. I've opened it as I want to get your opinion before I invest more time in it.

For the last couple of days I have been trying to wrap my head around:

@stephentoub has suggested here how this could be solved.
To be honest with you I don't like this approach as in my opinion it would not be 100% thread-safe (it's OK, FileStream was never promised to be thread-safe) and it would make FileStream even more complex.
It's definitely doable but if it's possible I would prefer to avoid making FileStream even more complex.

Stephen has also suggested using BufferedStream and removing all the buffering logic from the strategies themselves: dotnet#47128 (comment)
I love the idea of removing the buffering logic from FileStream. And this is what I've tried in this PR (branch). It makes both AsyncWindowsFileStreamStrategy and SyncWindowsFileStreamStrategy super simple and very clean (no if checks, just tiny wrappers around OS calls, see the code below). SyncWindowsFileStreamStrategy is just 169 lines of code (half of it are comments)!!

Moreover, BufferedStream solves the problem of doing sync method calls from async methods to handle the buffering.

BufferedStream uses SempahoreSlim to achieve that:

https://github.com/dotnet/runtime/blob/16a9d5d6a2290a4f13fc4b42bf433588d481c39f/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs#L661-L663

This comes with a performance penalty but also with a breaking change.

Until now, it was possible to start multiple async reads|writes and await them later. By using BufferedStream that acquires a lock it's still possible, but the requests would not be executed in parallel and FileStream.Position would get updated after the request would be finished:

https://github.com/dotnet/runtime/blob/16a9d5d6a2290a4f13fc4b42bf433588d481c39f/src/libraries/System.Private.CoreLib/src/System/IO/BufferedStream.cs#L1118-L1119

Test that fails after my changes:

https://github.com/dotnet/runtime/blob/16a9d5d6a2290a4f13fc4b42bf433588d481c39f/src/libraries/System.IO.FileSystem/tests/FileStream/WriteAsync.cs#L218-L229

If I remember correctly, we were initially OK with breaking that. But, if our users really want to perform async reads and writes in parallel, we could add offset-based methods to FileStream with a new mode (like FileOptions.Overlapped) that would not be using buffering at all (dotnet#24847):

public partial class FileStream : System.IO.Stream
{
    public override int Read(byte[] buffer, int offset, int count)
    public override int Read(System.Span<byte> buffer)
+   public virtual int Read(System.Span<byte> buffer, long fileOffset)
    public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    public override ValueTask<int> ReadAsync(System.Memory<byte> buffer, CancellationToken cancellationToken)
+   public virtual ValueTask<int> ReadAsync(System.Memory<byte> buffer, long fileOffset, CancellationToken cancellationToken)
    public override void Write(byte[] buffer, int offset, int count) { }
    public override void Write(ReadOnlySpan<byte> buffer) { }
+   public virtual void Write(ReadOnlySpan<byte> buffer, long fileOffset) { }    
    public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
    public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken)
+   public virtual ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, long fileOffset, CancellationToken cancellationToken)
}

So on the one hand we would break 0.001% of our users that does that, but on the other, we would offer them a super-fast alternative (this is what most probably they wanted from the beginning).

Speaking of the performance penalty I've spent some time tunning BufferedStream perf and I was able to get to the point that there is no perf regression in most of the cases.

\before\CoreRun.exe is 6.0 without the concept of FileStreamStrategy:

Method Job Toolchain fileSize userBufferSize options Median Ratio Allocated
Read Job-RQDFGV \after\CoreRun.exe 1024 512 None 50.33 us 0.99 4,384 B
Read Job-TPLJRT \before\CoreRun.exe 1024 512 None 50.88 us 1.00 4,288 B
Write Job-RQDFGV \after\CoreRun.exe 1024 512 None 895.70 us 1.00 4,384 B
Write Job-TPLJRT \before\CoreRun.exe 1024 512 None 899.52 us 1.00 4,288 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1024 512 None 69.46 us 1.00 5,128 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1024 512 None 69.71 us 1.00 4,848 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1024 512 None 911.77 us 0.98 4,472 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1024 512 None 928.22 us 1.00 4,840 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1024 512 Asynchronous 86.91 us 1.25 5,304 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1024 512 Asynchronous 69.49 us 1.00 4,713 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1024 512 Asynchronous 985.40 us 1.04 4,900 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1024 512 Asynchronous 938.65 us 1.00 4,693 B
Read Job-RQDFGV \after\CoreRun.exe 1024 4096 None 49.06 us 1.00 264 B
Read Job-TPLJRT \before\CoreRun.exe 1024 4096 None 49.19 us 1.00 168 B
Write Job-RQDFGV \after\CoreRun.exe 1024 4096 None 181.07 us 1.00 264 B
Write Job-TPLJRT \before\CoreRun.exe 1024 4096 None 181.63 us 1.00 168 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1024 4096 None 66.77 us 1.03 800 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1024 4096 None 64.61 us 1.00 616 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1024 4096 None 182.16 us 1.00 264 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1024 4096 None 181.49 us 1.00 168 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1024 4096 Asynchronous 85.35 us 1.03 968 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1024 4096 Asynchronous 82.89 us 1.00 760 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1024 4096 Asynchronous 183.62 us 1.00 320 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1024 4096 Asynchronous 184.87 us 1.00 200 B
OpenClose Job-RQDFGV \after\CoreRun.exe 1024 ? None 41.90 us 1.01 264 B
OpenClose Job-TPLJRT \before\CoreRun.exe 1024 ? None 41.68 us 1.00 168 B
LockUnlock Job-RQDFGV \after\CoreRun.exe 1024 ? None 81.99 us 1.04 264 B
LockUnlock Job-TPLJRT \before\CoreRun.exe 1024 ? None 78.81 us 1.00 168 B
SeekForward Job-RQDFGV \after\CoreRun.exe 1024 ? None 269.15 us 1.04 264 B
SeekForward Job-TPLJRT \before\CoreRun.exe 1024 ? None 258.58 us 1.00 168 B
SeekBackward Job-RQDFGV \after\CoreRun.exe 1024 ? None 1,660.26 us 1.01 265 B
SeekBackward Job-TPLJRT \before\CoreRun.exe 1024 ? None 1,661.86 us 1.00 168 B
ReadByte Job-RQDFGV \after\CoreRun.exe 1024 ? None 52.67 us 0.96 4,384 B
ReadByte Job-TPLJRT \before\CoreRun.exe 1024 ? None 54.19 us 1.00 4,288 B
WriteByte Job-RQDFGV \after\CoreRun.exe 1024 ? None 927.91 us 1.01 4,385 B
WriteByte Job-TPLJRT \before\CoreRun.exe 1024 ? None 931.51 us 1.00 4,288 B
Flush Job-RQDFGV \after\CoreRun.exe 1024 ? None 3,759.49 us 1.00 4,386 B
Flush Job-TPLJRT \before\CoreRun.exe 1024 ? None 3,802.99 us 1.00 4,289 B
FlushAsync Job-RQDFGV \after\CoreRun.exe 1024 ? None 7,357.75 us 1.95 496,291 B
FlushAsync Job-TPLJRT \before\CoreRun.exe 1024 ? None 3,776.47 us 1.00 4,306 B
CopyToFile Job-RQDFGV \after\CoreRun.exe 1024 ? None 986.10 us 1.00 8,770 B
CopyToFile Job-TPLJRT \before\CoreRun.exe 1024 ? None 998.14 us 1.00 8,577 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 1024 ? None 985.46 us 1.01 5,674 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 1024 ? None 983.22 us 1.00 9,465 B
OpenClose Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 43.52 us 0.94 320 B
OpenClose Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 46.30 us 1.00 200 B
LockUnlock Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 86.53 us 1.00 320 B
LockUnlock Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 88.61 us 1.00 200 B
SeekForward Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 2,391.24 us 0.99 321 B
SeekForward Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 2,406.04 us 1.00 201 B
SeekBackward Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 4,811.03 us 0.98 322 B
SeekBackward Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 4,843.99 us 1.00 201 B
ReadByte Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 71.92 us 0.93 4,760 B
ReadByte Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 76.48 us 1.00 4,641 B
WriteByte Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 1,004.14 us 1.04 4,805 B
WriteByte Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 966.91 us 1.00 4,670 B
Flush Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 29,860.54 us 1.68 152,195 B
Flush Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 17,744.32 us 1.00 152,063 B
FlushAsync Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 35,450.52 us 2.05 529,224 B
FlushAsync Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 17,602.27 us 1.00 152,279 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 1024 ? Asynchronous 1,095.60 us 1.13 6,122 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 1024 ? Asynchronous 1,060.03 us 1.00 9,860 B
Read Job-RQDFGV \after\CoreRun.exe 1048576 512 None 711.89 us 1.01 4,384 B
Read Job-TPLJRT \before\CoreRun.exe 1048576 512 None 709.69 us 1.00 4,288 B
Write Job-RQDFGV \after\CoreRun.exe 1048576 512 None 6,203.04 us 1.00 4,387 B
Write Job-TPLJRT \before\CoreRun.exe 1048576 512 None 6,442.30 us 1.00 4,289 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1048576 512 None 1,628.45 us 0.46 86,729 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1048576 512 None 3,509.77 us 1.00 234,002 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1048576 512 None 8,688.55 us 0.85 78,534 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1048576 512 None 10,451.96 us 1.00 233,995 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1048576 512 Asynchronous 4,675.79 us 1.18 95,063 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1048576 512 Asynchronous 3,979.44 us 1.00 41,577 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1048576 512 Asynchronous 17,736.84 us 1.63 86,874 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1048576 512 Asynchronous 10,844.67 us 1.00 41,603 B
Read Job-RQDFGV \after\CoreRun.exe 1048576 4096 None 671.12 us 1.04 264 B
Read Job-TPLJRT \before\CoreRun.exe 1048576 4096 None 637.65 us 1.00 168 B
Write Job-RQDFGV \after\CoreRun.exe 1048576 4096 None 6,096.33 us 1.04 267 B
Write Job-TPLJRT \before\CoreRun.exe 1048576 4096 None 5,900.05 us 1.00 169 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1048576 4096 None 1,017.60 us 1.03 29,361 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1048576 4096 None 984.37 us 1.00 29,176 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1048576 4096 None 6,860.73 us 1.04 29,356 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1048576 4096 None 6,772.76 us 1.00 29,169 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 1048576 4096 Asynchronous 4,645.51 us 1.03 80,530 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 1048576 4096 Asynchronous 4,581.12 us 1.00 80,337 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 1048576 4096 Asynchronous 16,463.98 us 1.02 80,530 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 1048576 4096 Asynchronous 16,369.54 us 1.00 80,314 B
CopyToFile Job-RQDFGV \after\CoreRun.exe 1048576 ? None 4,998.09 us 1.05 537 B
CopyToFile Job-TPLJRT \before\CoreRun.exe 1048576 ? None 4,865.97 us 1.00 369 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 1048576 ? None 5,116.65 us 1.00 3,327 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 1048576 ? None 5,161.07 us 1.00 2,799 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 1048576 ? Asynchronous 5,707.27 us 1.05 4,191 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 1048576 ? Asynchronous 5,626.98 us 1.00 7,919 B
Read Job-RQDFGV \after\CoreRun.exe 104857600 512 None 87,366.66 us 1.00 4,420 B
Read Job-TPLJRT \before\CoreRun.exe 104857600 512 None 86,611.01 us 1.00 4,304 B
Write Job-RQDFGV \after\CoreRun.exe 104857600 512 None 317,741.70 us 1.08 4,528 B
Write Job-TPLJRT \before\CoreRun.exe 104857600 512 None 310,749.10 us 1.00 4,352 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 512 None 181,296.90 us 0.49 8,196,952 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 512 None 365,479.80 us 1.00 22,942,288 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 104857600 512 None 452,437.90 us 0.69 7,377,784 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 104857600 512 None 676,302.20 us 1.00 22,942,320 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 512 Asynchronous 478,134.45 us 1.17 9,016,088 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 512 Asynchronous 408,372.10 us 1.00 3,692,312 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 104857600 512 Asynchronous 1,663,906.70 us 2.23 8,197,088 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 104857600 512 Asynchronous 725,969.00 us 1.00 3,691,952 B
Read Job-RQDFGV \after\CoreRun.exe 104857600 4096 None 78,886.50 us 0.99 300 B
Read Job-TPLJRT \before\CoreRun.exe 104857600 4096 None 81,857.69 us 1.00 184 B
Write Job-RQDFGV \after\CoreRun.exe 104857600 4096 None 308,371.30 us 1.09 408 B
Write Job-TPLJRT \before\CoreRun.exe 104857600 4096 None 309,997.80 us 1.00 232 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 4096 None 127,960.25 us 0.99 2,868,032 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 4096 None 128,430.30 us 1.00 2,867,736 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 104857600 4096 None 381,012.20 us 1.09 2,868,064 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 104857600 4096 None 375,533.40 us 1.00 2,867,760 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 4096 Asynchronous 475,784.50 us 0.99 7,988,000 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 4096 Asynchronous 479,559.25 us 1.00 7,987,712 B
WriteAsync Job-RQDFGV \after\CoreRun.exe 104857600 4096 Asynchronous 1,765,383.40 us 0.98 7,987,992 B
WriteAsync Job-TPLJRT \before\CoreRun.exe 104857600 4096 Asynchronous 1,784,226.70 us 1.00 7,987,704 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 16384 None 53,870.68 us 1.09 717,524 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 16384 None 49,269.25 us 1.00 717,312 B
ReadAsync Job-RQDFGV \after\CoreRun.exe 104857600 16384 Asynchronous 140,858.83 us 1.00 1,997,528 B
ReadAsync Job-TPLJRT \before\CoreRun.exe 104857600 16384 Asynchronous 140,296.58 us 1.00 1,997,280 B
CopyToFile Job-RQDFGV \after\CoreRun.exe 104857600 ? None 77,402.65 us 1.02 636 B
CopyToFile Job-TPLJRT \before\CoreRun.exe 104857600 ? None 77,272.05 us 1.00 424 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 104857600 ? None 84,002.55 us 1.01 180,908 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 104857600 ? None 83,337.45 us 1.00 180,360 B
CopyToFileAsync Job-RQDFGV \after\CoreRun.exe 104857600 ? Asynchronous 161,694.55 us 1.06 251,640 B
CopyToFileAsync Job-TPLJRT \before\CoreRun.exe 104857600 ? Asynchronous 160,787.30 us 1.00 255,624 B

But for some cases, ReadAsync and WriteAsync get a non-trivial hit. I've optimized mostly the ReadAsync path (did not spend too much time on WriteAsync as it was more proof of concept) and the perf penalty comes mostly from:

  • the fact that we perform async IO (previously populating the _buffer with data from the disk was always sync. There is very little we can do about it and this is kind of expected. It pops up as a regression in single-threaded microbenchmark but would definitely improve throughput in most real-life scenarios.
  • the async machinery (extra allocs). According to my understanding, this could be addressed by using IValueTaskSource as suggested by @stephentoub. And the fact that we would always have 1 active async read|Write in BufferedStream would make it even simpler?

We could minimize the overhead with IValueTaskSource and I am sure that by fixing dotnet#16354 and dotnet#25905 we could make ReadAsync and WriteAsync overall 20-60% faster than .NET 5.0 (depending on file and buffer size).

@stephentoub @carlossanlop @Jozkee Could you please take a brief look at my changes in BufferedStream, tests, and both Windows file strategies and let me know what do you think about using BufferedStream?

If we agree that this approach is acceptable, we could do the following:

cc @jeffhandley

@adamsitnik adamsitnik closed this Mar 4, 2021
adamsitnik pushed a commit that referenced this pull request May 24, 2021
…tnet#52769)

Transition to GC Unsafe mode on every MONO_RT_EXTERNAL_ONLY function in
reflection.c

In particular, fix mono_reflection_type_from_name which is used in
https://github.com/xamarin/xamarin-android/blob/681887ebdbd192ce7ce1cd02221d4939599ba762/src/monodroid/jni/embedded-assemblies.cc#L350

Fixes stack traces like

```
05-14 08:06:12.848 31274 31274 F DEBUG   :       #00 pc 00000b99  [vdso] (__kernel_vsyscall+9)
05-14 08:06:12.848 31274 31274 F DEBUG   :       #1 pc 0005ad68  /apex/com.android.runtime/lib/bionic/libc.so (syscall+40) (BuildId: 6e3a0180fa6637b68c0d181c343e6806)
05-14 08:06:12.848 31274 31274 F DEBUG   :       #2 pc 00076511  /apex/com.android.runtime/lib/bionic/libc.so (abort+209) (BuildId: 6e3a0180fa6637b68c0d181c343e6806)
05-14 08:06:12.848 31274 31274 F DEBUG   :       #3 pc 0002afcd  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::mono_log_handler(char const*, char const*, char const*, int, void*)+141) (BuildId: 9726f32ad5f8fa5e7c5762baf2f6e3294da41cc1)
05-14 08:06:12.848 31274 31274 F DEBUG   :       #4 pc 00112c5d  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (eglib_log_adapter+141) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #5 pc 00020fdf  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (monoeg_g_logv+175) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #6 pc 0002113a  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (monoeg_g_log+42) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #7 pc 00128892  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_threads_transition_do_blocking+258) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #8 pc 0012a406  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_threads_enter_gc_safe_region_unbalanced_with_info+134) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #9 pc 0012a27e  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_threads_enter_gc_safe_region_internal+46) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #10 pc 000799a7  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_loader_lock+71) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #11 pc 000447a1  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_class_create_from_typedef+129) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #12 pc 0003c073  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_class_get_checked+99) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #13 pc 0003cc0f  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_class_from_name_checked_aux+735) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #14 pc 00037989  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_class_from_name_checked+73) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #15 pc 000cc5f4  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_reflection_get_type_internal+132) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       #16 pc 000c9bce  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_reflection_get_type_with_rootimage+126) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#17 pc 000ca204  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (_mono_reflection_get_type_from_info+292) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#18 pc 000ca06e  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_reflection_type_from_name_checked+334) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#19 pc 000c9f01  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonosgen-2.0.so (mono_reflection_type_from_name+49) (BuildId: b67e93dd750dafdd6f65f408b021b6a3a74868ac)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#20 pc 0001b40b  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(char const*)+427) (BuildId: 9726f32ad5f8fa5e7c5762baf2f6e3294da41cc1)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#21 pc 0001b551  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonodroid.so (xamarin::android::internal::EmbeddedAssemblies::typemap_java_to_managed(_MonoString*)+113) (BuildId: 9726f32ad5f8fa5e7c5762baf2f6e3294da41cc1)
05-14 08:06:12.849 31274 31274 F DEBUG   :       dotnet#22 pc 000211a7  /data/app/~~rMrkpKmVPaBpM5jKb8fPAg==/com.microsoft.maui-JfRo8RWSDJaNtJuBa0y7_Q==/lib/x86/libmonodroid.so (xamarin::android::internal::MonodroidRuntime::typemap_java_to_managed(_MonoString*)+39) (BuildId: 9726f32ad5f8fa5e7c5762baf2f6e3294da41cc1)
```
adamsitnik pushed a commit that referenced this pull request May 24, 2021
…2915)

* [build] Define NO_UNALIGNED_ACCESS for 32-bit arm platforms

Possibly related to crashes on Android like this:

```
05-18 10:59:07.466 17076 17076 F libc    : Fatal signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xb9c95a41 in tid 17076 (simplehellomaui), pid 17076 (simplehellomaui)
05-18 10:59:07.501 17104 17104 I crash_dump32: obtaining output fd from tombstoned, type: kDebuggerdTombstone
05-18 10:59:07.502   989   989 I tombstoned: received crash request for pid 17076
05-18 10:59:07.503 17104 17104 I crash_dump32: performing dump of process 17076 (target tid = 17076)
05-18 10:59:07.512 17104 17104 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-18 10:59:07.512 17104 17104 F DEBUG   : Build fingerprint: 'google/crosshatch/crosshatch:11/RQ2A.210405.005/7181113:user/release-keys'
05-18 10:59:07.512 17104 17104 F DEBUG   : Revision: 'MP1.0'
05-18 10:59:07.512 17104 17104 F DEBUG   : ABI: 'arm'
05-18 10:59:07.515 17104 17104 F DEBUG   : Timestamp: 2021-05-18 10:59:07+0200
05-18 10:59:07.515 17104 17104 F DEBUG   : pid: 17076, tid: 17076, name: simplehellomaui  >>> com.microsoft.simplehellomaui <<<
05-18 10:59:07.515 17104 17104 F DEBUG   : uid: 10364
05-18 10:59:07.515 17104 17104 F DEBUG   : signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0xb9c95a41
05-18 10:59:07.515 17104 17104 F DEBUG   :     r0  bb4a5cd0  r1  b9c95a49  r2  00000000  r3  e94c7520
05-18 10:59:07.515 17104 17104 F DEBUG   :     r4  0000000c  r5  00000000  r6  ff843c50  r7  ff843e70
05-18 10:59:07.515 17104 17104 F DEBUG   :     r8  b69547f8  r9  e99eac50  r10 00000000  r11 00000021
05-18 10:59:07.515 17104 17104 F DEBUG   :     ip  e94c74f0  sp  ff843c48  lr  bb31e0dd  pc  bb3a4d24
05-18 10:59:07.531   709   709 E Layer   : [Surface(name=Task=1)/@0x52e6b1a - animation-leash#0] No local sync point found
05-18 10:59:07.532   709   709 E Layer   : [Surface(name=Task=1571)/@0x9c90165 - animation-leash#0] No local sync point found
05-18 10:59:07.706 17104 17104 F DEBUG   : backtrace:
05-18 10:59:07.707 17104 17104 F DEBUG   :       #00 pc 000ddd24  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mono_method_to_ir+9232) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #1 pc 000d7777  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (inline_method+622) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #2 pc 000ec0a3  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mono_method_to_ir+67470) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #3 pc 000cda6d  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mini_method_compile+2264) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #4 pc 000cf413  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mono_jit_compile_method_inner+50) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #5 pc 000d1d7f  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mono_jit_compile_method_with_opt+1766) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #6 pc 0012d94d  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (common_call_trampoline+832) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #7 pc 0012d5cb  /data/app/~~J4DFQ3c1v2YGrEurX7TNjg==/com.microsoft.simplehellomaui-_jGGPiZpZ3yT-QCTNDcgvQ==/lib/arm/libmonosgen-2.0.so (mono_magic_trampoline+62) (BuildId: d0a4e41a500357a621884b64f6ca8533b62a664b)
05-18 10:59:07.707 17104 17104 F DEBUG   :       #8 pc 0000006a <anonymous:b7986000>
```

* move to host/target sections
@adamsitnik adamsitnik deleted the bufferedStrategy branch July 2, 2021 11:10
adamsitnik pushed a commit that referenced this pull request Jul 6, 2021
)

* Pin MicrosoftNetCompilersToolsetVersion to a version that supports Static Abstracts in Interfaces

* Fixed issues related to enabling generic math in a general sense (#4)

- Disable constraint checking during EEInit
- Disable il linker running on CoreLib
- Fixup generic math tests to actually build

* Adding interfaces to support generic math

* Implement generic math interfaces on core types

* Updating the System.Runtime ref assembly to support generic math

* Add a basic xunit test for generic-math

* Removing unnecessary nullable annotations

* Ensure all preview interface members are explicitly implemented

* Don't use var for various methods in Double/Half/Single

* Ensure FeatureGenericMath is defined for Mono

* Skip generic math tests on Mono WASM due to dotnet#54910

* Apply suggestions from code review

Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>

Co-authored-by: David Wrighton <davidwr@microsoft.com>
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
adamsitnik pushed a commit that referenced this pull request Feb 24, 2022
…otnet#65628)

* [wasm] Add support for a random test case orderer, for xunit tests

This is enabled by default for wasm with
`$(XUnitUseRandomizedTestOrderer)=true`.

When the library tests run, they print two messages like:

```
  info: Using random seed for test cases: 700149826
  info: Using random seed for collections: 700149826
  info: Starting:    System.Collections.Immutable.Tests.dll
```

These seeds are picked randomly every time the tests are run. To run the
tests with a specific seed, use environment variable
`XUNIT_RANDOM_ORDER_SEED`.

When running with tests, this can be used as:

    `WasmXHarnessMonoArgs="--setenv=XUNIT_RANDOM_ORDER_SEED=<seed>`

* Enable test orderer only for libraries tests

* [wasm] Automatically pass XUNIT_RANDOM_ORDER_SEED envvar to wasm apps

* Disable random test ordering for `System.Xml.RW.XmlWriterApi.Tests`

`System.Xml.Tests.TCCloseOutput.*` tests seem to depend on the order of
execution.

```
[06:35:14] fail: [FAIL] System.Xml.Tests.TCCloseOutput.CloseOutput_4(utils: XmlWriterUtils { Async = False, WriterType = UTF8Writer }, outputType: "Stream")
[06:35:14] info: System.IO.FileNotFoundException : File Not Found: writer.out
[06:35:14] info:    at XmlCoreTest.Common.FilePathUtil.getStream(String filename)
[06:35:14] info:    at System.Xml.Tests.TCCloseOutput.CloseOutput_4(XmlWriterUtils utils, String outputType)
[06:35:14] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```

* [wasm] Disable random tests ordering for `System.Runtime.Loader`

It seems to cause failures like, reproducible with
`XUNIT_RANDOM_ORDER_SEED=2106784294`:

```
[06:25:43] fail: [FAIL] System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(alc: "Empty", assemblyName: "System.Runtime.Loader.Tests", culture: "en")
[06:25:43] info: Assert.Same() Failure
[06:25:43] info: Expected: "Default" System.Runtime.Loader.DefaultAssemblyLoadContext #0
[06:25:43] info: Actual:   "Empty" System.Runtime.Loader.AssemblyLoadContext #4
[06:25:43] info:    at System.Runtime.Loader.Tests.SatelliteAssembliesTests.SatelliteLoadsCorrectly_FromName(String alc, String assemblyName, String culture)
[06:25:43] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```

* [wasm] Disable random test ordering for `System.Runtime.Numerics`

Randomized runs seem to fail with:

```
[03:29:54] info: Starting:    System.Runtime.Numerics.Tests.dll
[03:29:58] fail: [FAIL] System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests
[03:29:58] info: Assert.Equal() Failure
[03:29:58] info:           ↓ (pos 0)
[03:29:58] info: Expected: -0
[03:29:58] info: Actual:   0
[03:29:58] info:           ↑ (pos 0)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.VerifyDoubleExplicitCastToBigInteger(Double value)
[03:29:58] info:    at System.Numerics.Tests.cast_toTest.RunDoubleExplicitCastToBigIntegerTests()
[03:29:58] info:    at System.Reflection.RuntimeMethodInfo.InvokeWorker(Object obj, BindingFlags invokeAttr, Span`1 parameters)
```

Reproducible with `XUNIT_RANDOM_SEED_ORDER=1883302047`.

* Add issues for the failing tests
adamsitnik pushed a commit that referenced this pull request Jun 23, 2022
* Initial implementation for contract customization

fix build errors

Move converter rooting to DefaultJsonTypeInfoResolver so that it can be used standalone

Fix ConfigurationList.IsReadOnly

Minor refactorings (#1)

* Makes the following changes:

* Move singleton initialization for DefaultTypeInfoResolver behind a static property.
* Consolidate JsonSerializerContext & IJsonTypeInfoResolver values to a single field.
* Move reflection fallback logic away from JsonSerializerContext and into JsonSerializerOptions

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.cs

* remove testing of removed field

Simplify the JsonTypeInfo.CreateObject implemenetation (#2)

* Simplify the JsonTypeInfo.CreateObject implemenetation

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.cs

* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfoOfT.cs

Co-authored-by: Krzysztof Wicher <mordotymoja@gmail.com>

Co-authored-by: Krzysztof Wicher <mordotymoja@gmail.com>

Tests and fixes for JsonTypeInfoKind.None

TypeInfo type mismatch tests

Allow setting NumberHandling on JsonTypeInfoKind.None

test resolver returning wrong type of options

JsonTypeInfo/JsonPropertyInfo mutability tests

rename test file

Move default converter rooting responsibility behind DefaultJsonTypeInfoResolver (#3)

* Move default converter rooting responsibility behind DefaultJsonTypeInfoResolver

* address feedback

Add simple test for using JsonTypeInfo<T> with APIs directly taking it

fix and tests for untyped/typed CreateObject

uncomment test cases, remove todo

More tests and tiny fixes

Add a JsonTypeInfoResolver.Combine test for JsonSerializerContext (#4)

* Fix JsonTypeInfoResolver.Combine for JsonSerializerContext

* Break up failing test

Fix simple scenarios for combining contexts (#6)

* Fix simple scenarios for combining contexts

* feedback

JsonSerializerContext combine test with different camel casing

Remove unneeded virtual calls & branching when accessing Get & Set delegates (#7)

JsonPropertyInfo tests everything minus ShouldSerialize & NumberHandling

Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs

Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonConverterOfT.cs

throw InvalidOperationException rather than ArgumentNullException for source gen when PropertyInfo.Name is assigned through JsonPropertyInfoValues

tests for duplicated property names and JsonPropertyInfo.NumberHandling

Add tests for NumberHandling and failing tests for ShouldSerialize

disable the failing test and add extra checks

disable remainder of the failing ShouldSerialize tests, fix working one

Fix ShouldSerialize and IgnoreCondition interop

Add failing tests for CreateObject + parametrized constructors

Fix CreateObject support for JsonConstructor types (#10)

* Fix CreateObject support for JsonConstructor types

* address feedback

Make contexts more combinator friendly (#9)

* Make contexts more combinator friendly

* remove converter cache

* redesign test to account for JsonConstructorAttribute

* Combine unit tests

* address feedback

* Add acceptance tests for DataContract attributes & Specified pattern (#11)

* Add private field serialization acceptance test (#13)

* tests, PR feedback (#14)

* PR feedback and extra tests

* Shorten class name, remove incorrect check (not true for polimorphic cases)

* Make parameter matching for custom properties map property Name with parameter (#16)

* Test static initialization with JsonTypeInfo (dotnet#17)

* Fix test failures and proper fix this time (dotnet#18)

* Fix test failures and proper fix this time

* reinstate ActiveIssueAttribute

* PR feedback and adjust couple of tests which don't set TypeInfoResolver

* fix IAsyncEnumerable tests

* Lock JsonSerializerOptions in JsonTypeInfo.EnsureConfigured()

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
adamsitnik added a commit that referenced this pull request Jul 14, 2022
…etLastAccessTime, SetLastWriteTime (dotnet#60507)

* Implement proposal

* Undo auto-reformat

* Add ref

* Fix Parameter Naming in FileSystem.Unix.cs

* Partial test implementation

* Fix typo

* Fix parameter naming

* Naming fix and remove unnessecary method

* Add more test cases

* Implement usage of Kernel32 Method GetFileInformationByHandle and struct BY_HANDLE_FILE_INFORMATION

* Fix Test SetLastWriteTimeTicks_SafeFileHandle

* Disable SafeFileHandle specific-tests on other platforms than Windows

* Add Common reference to project file of System.IO.AccessControl

* fix

* Add preprocessor variable check

* Add check for preprocessor var

* Fix CS0649

* Remove preprozessor variable checks

* Fix tab/spaces conflict in Interop.BY_HANDLE_FILE_INFORMATION

* Fix misplaced StructLayoutAttribute

* Fix project file identation

* Remove preprocessor variable checks for GetSetAttributes test

* Use ThrowHelper instead of direct throwing

* Use ThrowHelper instead of direct throwing

* Add null-forgiving operator to fix build-failures

* Fix build failures

* Win32 interop improvements

* Specify FileAccess in File.OpenHandle calls for testing purposes

* Implement GetLastWin32Error proposal / @Jozkee

Co-authored-by: David Cantú <dacantu@microsoft.com>

* Fix build

* Usage of kernel32.dll!SetFileInformationByHandle in FileSystem.SetFileTime

* Usage of access parameter in GetSetTimes tests

* Remove auto-generated trash

* Add localization string to NativeAOT Strings.resx

* Unix Implementation of GetAttributes, SetAttributes, GetCreationTime, GetLastAccessTime and GetLastWriteTime

* Unix Implementation SetLastAccessTime and SetLastWriteTime

* Add error handling to FChMod call

* Revert "Unix Implementation SetLastAccessTime and SetLastWriteTime"

This reverts commit bce7faadb52bf308e6258864d464334448a4bda3.

* Unix Implementation SetLastAccessTime and SetLastWriteTime

* Move SafeHandle implementation to FileStatus.

* `SafeFileHandle` `FileStatus` (#4)

* [RateLimiting] Dequeue items when queuing with NewestFirst (#63377)

* Don't reuse registers in Debug mode (#63698)

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>

* Add IsKnownConstant jit helper and optimize 'str == ""' with str.StartsWith('c') (#63734)

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>

* - mono_wasm_new_external_root for roots on stack (#63997)

- temp_malloc helper via linear buffer in js
- small refactorings
Co-authored-by: Katelyn Gadd <kg@luminance.org>

* [Arm64] Don't use D-copies in CopyBlock (#63588)

* Increase the maximum number of internal registers allowd per node in src/coreclr/jit/lsra.h

* Based on discussion in https://github.com/dotnet/runtime/issues/63453 don't allocate a SIMD register pair if the JIT won't be able to use Q-copies in src/coreclr/jit/lsraarmarch.cpp

* Update CodeGen to reflect that Q-copies should be used only when size >= 2 * FP_REGSIZE_BYTES and using of them makes the instruction sequence shorter in src/coreclr/jit/codegenarmarch.cpp

* Update comment - we don't use D-copies after that change in src/coreclr/jit/codegenarmarch.cpp

* Disable hot reload tests for AOT configurations (#64006)

* Bump Explicit-layout value types with no fields to at minimum 1 byte size. (#63975)

* Add runtime-extra-platforms pipeline to have matching runtime PR and Rolling builds (#62564)

* Add runtime-extended-platforms pipeline to have matching runtime PR and Rolling builds

* Fix evaluate changed paths condition for the extra pipeline

* PR Feedback and fix condition

* Move MacCatalyst back to staging, disable tvOS tests

* Disable browser wasm windows legs

* Make ILStubGenerated event log ModuleID corresponding to that on other events (#63974)

* Retries for flaky WMI test (#64008)

* [arm64] JIT: Redundant zero/sign extensions after ldrX/ldrsX (#62630)

* JIT: fix up switch map for out-of-loop predecessor (#64014)

If we have a loop where some of the non-loop predecessors are switchs, and
we add pre-header to the loop, we need to update the switch map for those
predecessors.

Fixes #63982.

* Update StructMarshalling design now that DisableRuntimeMarshallingAttribute is approved (#63765)

Co-authored-by: Elinor Fung <elfung@microsoft.com>

* Fix Crossgen2 bug #61104 and add regression test (#63956)

The issue tracks the runtime regression failure where
Crossgen2-compiled app is unable to locate a type with non-ASCII
characters in its name. The failure was caused by the fact that
Crossgen2 was incorrectly zero-extending the individual UTF8 characters
when calculating the hash whereas runtime is sign-extending them.

Thanks

Tomas

* Fix invalid threading of nodes in rationalization (#64012)

The code in question assumes that the ASG will be
reversed and thus threads "simdTree" before "location"
in the linear order. That dependency, while valid,
because "gtSetEvalOrder" will always reverse ASGs
with locals on the LHS, is unnecessary and incorrect
from the IR validity point of view.

Fix this by using "InsertAfter" instead of manual
node threading.

* Check if the child object is in the heap range before get_region_plan_gen_num (#63828)

* Check if the child object is in the heap range before object_gennum (#63970)

* 'cmeq' and 'fcmeq' Vector64<T>.Zero/Vector128<T>.Zero ARM64 containment optimizations (#62933)

* Initial work

* Added a comma to display

* Cleanup

* Fixing build

* More cleanup

* Update comment

* Update comment

* Added CompareEqual Vector64/128 with Zero tests

* Do not contain op1 for now

* Wrong intrinsic id used

* Removing generated tests

* Removing generated tests

* Added CompareEqual tests

* Supporting containment for first operand

* Fix test build

* Passing correct register

* Check IsVectorZero before not allocing a register

* Update comment

* Fixing test

* Minor format change

* Fixed formatting

* Renamed test

* Adding AdvSimd_Arm64 tests:

* Adding support for rest of 'cmeq' and 'fcmeq' instructions

* Removing github csproj

* Minor test fix

* Fixed tests

* Fix print

* Minor format change

* Fixing test

* Added some emitter tests

* Feedback

* Update emitarm64.cpp

* Feedback

* [Arm64] Keep unrolling InitBlock and CopyBlock up to 128 bytes (#63422)

* Add INITBLK_LCL_UNROLL_LIMIT and CPBLK_LCL_UNROLL_LIMIT of 128 bytes in src/coreclr/jit/targetarm64.h

* Keep unrolling InitBlock up to INITBLK_LCL_UNROLL_LIMIT bytes when dstAddr points to the stack in src/coreclr/jit/lowerarmarch.cpp

* Keep unrolling CopyBlock up to CPBLK_LCL_UNROLL_LIMIT bytes when both srcAddr and dstAddr point to the stack in src/coreclr/jit/lowerarmarch.cpp

* Add ProcessLinkerXmlBase to NativeAOT (#63666)

Add Xml Parsing linker files as a reference source to NativeAOT
Rename NativeAOT ProcessLinkerXmlBase version to ProcessXmlBase (uses XmlReader) 
Add ProcessLinkerXmlBase from linker and fix it so it can be used in NativeAOT (uses XPath)

* Fix gc_heap::remove_ro_segment (#63473)

* Fix OpenSSL version check in GetAlpnSupport

The previous check failed 3.0.0 because the Minor was 0 and Build was 0.

It could probably be rewritten to be `>= new Version(1, 0, 2)`, but that'd require more thinking.

* Fix issues with verify_regions, clear_batch_mark_array_bits. (#63798)

Details:
- we cannot verify the tail of the region list from background GC, as it may be updated by threads allocating.
- fix case in clear_batch_mark_array_bits where end is equal to the very end of a segment and we write into uncommitted memory in the mark_array.
-  bgc_clear_batch_mark_array_bits did some checks and then called clear_batch_mark_array_bits which repeated the exact same checks. Renamed clear_batch_mark_array_bits to bgc_batch_mark_array_bits and removed the old copy, removed the declaration for clear_batch_mark_array_bits.

* [debugger][wasm] Added support for non user code attribute (#63876)

* Hidden methods and step through methods behave the same way.

* Perpared flow for setting JustMyCode in the future.

* Tests for JustMyCode setting before debug launch.

* Transformed into dynamic JustMyCode change flow.

* JustMyCode disabled, first 3 cases solved.

* Finished behavior for JMC disabled (with 1 difference).

* JMC enabled: stepIn np bp + stepIn bp + resume bp.

* Functional version (with minor deviations from expected behavior).

* Refactoring.

* All tests for NonUserCode work.

* Fix line number after adding code above.

* Fix error in merge.

* Removing duplicated tests.

* [wasm][debugger] Added support for stepper boundary attribute (#63991)

* Hidden methods and step through methods behave the same way.

* Perpared flow for setting JustMyCode in the future.

* Tests for JustMyCode setting before debug launch.

* Transformed into dynamic JustMyCode change flow.

* JustMyCode disabled, first 3 cases solved.

* Finished behavior for JMC disabled (with 1 difference).

* JMC enabled: stepIn np bp + stepIn bp + resume bp.

* Functional version (with minor deviations from expected behavior).

* Refactoring.

* All tests for NonUserCode work.

* Fix line number after adding code above.

* Stepper boundary with tests.

* Save information about multiple decorators.

* Fix error in merge.

* Polish the PR build doc (#64036)

* [wasm] WebSocket tests on NodeJS (#63441)

- NPM package with WS.
- Restore npm during build.
- Load npm modules in test-main.js.

Co-authored-by: Pavel Savara <pavel.savara@gmail.com>

* Fix dependency in runtime-official.yml (#64040)

After https://github.com/dotnet/runtime/pull/62564 the `hostedOs` value is included in the job name.

* [API Implementation]: System.Diagnostics.CodeAnalysis.StringSyntaxAttribute (#62995)

* Add StringSyntaxAttribute

* Fix attribute declaration and add usage

* Address PR feedback

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

* Reduce the memory footprint of HttpHeaders (#62981)

* Change HttpHeaders backing store to an array

* Reduce the size of HeaderDescriptor to 1 object

* Update UnitTests, fix GetOrCreateHeaderInfo

* Switch to a dictionary after ArrayThreshold headers

* Add unit tests

* Use storeValueRef naming consistently

* Workaround field layout regression (#63005)

* Mark _descriptor on HeaderDescriptor as nullable

* Remove HeaderDescriptor.Descriptor and add HasValue, IsKnownHeader, Equals

* Simplify HttpHeaderParser.Separator logic

* Add comments on HasValue checks

* Lazily group headers by name

* Add a header ordering+grouping test

* Make use of the _count field

* Revert all HeaderDescriptor changes from PR

* Switch back to always grouping by name

* Assert that the collection is not empty in GetEnumeratorCore

* Optimize AddHeaders for empty collections

* Reference the Roslyn bug issue

* Assert that multiValues are never empty

* Don't preserve a Dictionary across Clear

* Add comment about why a custom HeaderEntry type is used

* Disable DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException (#64044)

* Add test coverage for frozen objects and GC interaction (#64030)

* Test coverage for frozen objects and GC interaction

* Update Preinitialization.cs

* Remove Type.MakeGenericType dependency from source generation (#64004)

* Remove Type.MakeGenericType dependency from srcgen

* address feedback

* add trimmer warning suppression

* address feedback

* Add ns2.0 support to System.Formats.Cbor (#62872)

* Add ns2.0 support to System.Formats.Cbor

* Add NetFrameworkMinimum to tfms

* Add ReadHalf and WriteHalf to compatibility suppressions

* Remove unwanted comment

* Exception sets: debug checker & fixes (#63539)

* Add a simple exception sets checker

* Add asserts to catch missing nodes

* Fix normal VN printing

* Fix JTRUE VNs

* Fix PHI VNs

* Update VNs for "this" ARGPLACE node

* Tolerate missing VNs on PHI_ARGs

We do not update them after numbering the loops.

(Though perhaps we should)

* Tolerate unreachable blocks

* Fix exception sets for VNF_PtrTo VNFuncs

* Add VNUniqueWithExc

* Add VNPUniqueWithExc

* Fix arrays

* Consistently give location nodes VNForVoid

And always add exception sets for them.
This will simplify the exception set
propagation code for assignments.

* Fix CSE

* Fix GT_RETURN

* Fix LCLHEAP

* Fix GT_ARR_ELEM

* Fix unique HWI

* Fix unique SIMD

* Fix GT_SWITCH

* Fix CKFINITE

* Fix HWI loads

* Fix fgValueNumberAddExceptionSetForIndirection

The method does not need to add the exception set for
the base address. Additionally, the way it did add the
sets, by unioning with normal value numbers, lost all
exceptions not coming from the base address.

This was fine for the unary loads, but broke the HWI loads
that could have exceptions coming from not just the address.

* Fix GT_RETFILT

* Fix INIT_VAL

* Fix DYN_BLK

* Fix FIELD_LIST

* De-pessimize CkFinite

* Add a test for HWIs

* Add a test for LCLHEAP

* Change test to check for store block operators (#60878)

* Update XUnit to 2.4.2-pre.22 (#63948)

* Update to Xunit build 2.4.2-pre.13

Also pick up latest pre-release of analyzers

* Disambiguate calls to Assert.Equals(double,double,int)

Xunit added a new Assert overload that caused a lot of ambiguous calls.
https://github.com/xunit/xunit/issues/2393

Workaround by casting to double.

* Fix new instances of xUnit2000 diagnostic

* Workaround xUnit2002 issue with implicit cast

Works around https://github.com/xunit/xunit/issues/2395

* Disable xUnit2014 diagnostic

This diagnostic forces the use of Assert.ThrowsAsync for any async method,
however in our case we may want to test that a method will throw
synchronously to avoid regressing that behavior by moving to the async
portion of the method.

* Use AssertExtensions to test for null ArgumentException.ParamName

Workaround https://github.com/xunit/xunit/issues/2396

* Update to Xunit 2.4.2-pre.22

* Fix another ArugmentException.ParamName == null assert

* Preserve OBJ/BLK on the RHS of ASG (#63268)

One of my upcoming changes will need this information to
accurately detect type mismatch in "fgValueNumberBlockAssignment".

* Revert "Temporarily disable coredumps during library testing on macOS (#63742)" (#64057)

This reverts commit 2c28e63f9360280011a3b03c1ca6dc0edce1fae4.

Fixes #63761

* Performance: Fix Browser Wasm job not being found for dependent jobs (#64058)

* Figure out the name that browser wasm now uses.

*  linux to the Browser wasm depends on name.

Update the browser wasm dependson name to match the new one found in the pipeline.

* Fix exception propagation over HW exception frame on macOS arm64 (#63596)

* Fix exception propagation over HW exception frame on macOS arm64

There is a problem unwinding over the PAL_DispatchExceptionWrapper
to the actual hardware exception location. The unwinder is unable
to get distinct LR and PC in that frame and sets both of them to
the same value. This is caused by the fact that the
PAL_DispatchExceptionWrapper is just an injected fake frame and
there was no real call. Calls always return with LR and PC set
to the same value.

The fix unifies the hardware exception frame unwinding with Linux
where we had problems unwinding over signal handler trampoline, so
PAL_VirtualUnwind skips the trampoline and now also the
PAL_DispatchExceptionWrapper frame by copying the context of
the exception as the unwound context.

* Reenable DllImportGenerator.Unit.Tests

* Add StringSyntax attribute to Regex.pattern field (#64063)

I missed adding this one in my initial audit.  It'll be exceedingly rare for a developer to manually write code that assigns a string to this protected field, but every source-generated regex does so, and thus any colorization VS provides will benefit looking at the source-generated code.

* Sync shared code from aspnetcore (#64059)

Co-authored-by: JamesNK <JamesNK@users.noreply.github.com>

* Read the System.GC.CpuGroup settings in runtimeconfig.json (#64067)

* Log message of unexpected exception in ThrowsAny (#64064)

* Log message of unexpected exception in ThrowsAny

* Update AssertExtensions.cs

* Enable some browser legs on the extra-platforms pipeline (#64065)

* Enable some browser legs on the extra-platforms pipeline

* Flow platform parameter from helix queues templates

* Fix another condition

* Allow CreateScalarUnsafe to be directly contained by hwintrinsics that support scalar loads (#62407)

* Ensure that floating-point constants can be contained by hardware intrinsics

* Allow CreateScalarUnsafe to be directly contained by hwintrinsics that support scalar loads

* Rename IsContainableHWIntrinsicOp to TryGetContainableHWIntrinsicOp and improve handling

* Ensure that NI_AVX2_BroadcastScalarToVector128/256 are properly tracked as MaybeMemoryLoad

* Applying formatting patch

* Ensure a few other "maybe memory" and special memory operand size cases are handled

* Applying formatting patch

* Remove commented code (#63869)

* Add pmi_path argument to superpmi.py script and use it in the superpmi-collect pipeline. (#63983)

* Add -pmi_path argument to superpmi.py collect command and use it to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py

* Set pmi_path to $(SuperPMIDirectory)\crossgen2

* Print a warning if -pmi_path or -pmi_location is specified while --pmi is not in src/coreclr/scripts/superpmi.py

* Move setting of PMIPATH environment variable under `if self.coreclr_args.pmi is True:` in src/coreclr/scripts/superpmi.py

* Move pmi argument validation to setup_args() in src/coreclr/scripts/superpmi.py

* Clone root_env if we are going to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py

* Update the macOS CoreCLR building documentation. (#63932)

This updates the documentation to refer to the up-to-date location of
requirements and prerequisites.

* Introduce RandomAccess.SetLength (#63992)

* don't Flush readonly MemoryMappedViewAccessor on disposal (#63794)

* don't Flush if it's impossible to write

* address code review feedback: apply same optimization to MemoryMappedViewStream

* Implement System.Runtime.CompilerServices.DisabledRuntimeMarshallingAttribute on CoreCLR-family of runtimes/type systems (#63320)

* Add the DisableRuntimeMarshallingAttribute to the build.

* Add initial test suite

* Implement support in IL stubs for the "disabled runtime marshalling" feature.

* Add testing for inlining IL stubs.

* Block SetLastError and LCID support when DisableRuntimeMarshallingAttribute is applied.

* Bump NativeAOT-only R2R version header (missed previously)

* Implement support in crossgen2 and NativeAOT

* Clean up the test tree and update the tests to fail more reliably when bugs are present.

Fix a bug that was uncovered when the tests were refactored.

* Fix NativeAOT and clean up crossgen2

* Add a test for NoPreserveSig with DisableRuntimeMarshalling

* Assign hr in SUCCEEDED macro.

* PR feedback.

* Block varargs in disabled marshalling mode.

* Fix typo

* Block types that have a field that is auto-layout somewhere in their layout.

* Fix typo

* Revert the AutoLayoutOrHasAutoLayoutFIeld check in the "marshalling enabled" case

* Only set scope when it isn't null (it's null for some cases).

* Fix narrowing conversion failure.

* First pass simple implementation in Mono

* Fix assert to still work for the built-in marshalling system

* S_FALSE is a thing

* Fix type load failures caused by eager type handle loading.

* Get MethodILScope from the calling method when available (this covers all cases where we need it)

* Add const modifier.

* Try 2 to fix const modifiers

* Fix compilation of NativeAOT jitinterface

* Fix type lookup in Mono

* Use try_get model for getting the attribute type in the case of failure. Fix mono implementation for looking up the attribute.

* Handle void and generic instantiations

* Update auto-layout check to check recursively in layout.

* Enhance test suite with more tests for UnmanagedCallersOnly, generics, and the like. Fix AutoLayout test.

* Fix IL and a few typos

* Set a value in the padding for easier debugging.

* Create sig->marshalling_disabled to track when marshalling is disabled, which is separate from the concept of "is this signature a P/Invoke"

* Fix running test suite on Mono + Mini JIT

* Fix recursive type load failure by only checking the "has auto-layout or field with auto-layout" for value types.

* Fix mono windows build.

* Feedback from Michal.

* Fix bug in EcmaAssembly.HasAssemblyCustomAttribute

* Make the runtime flavor check in the wrapper generator case-invariant

* Use helper method since various different platforms/configurations throw different exceptions for these scenarios.

* Fix AutoLayout test refactor and use a dummy value for the padding field in both enabled and disabled scenarios.

* Add an explicit test for using enums as they're a little weird and needed some special-casing.

* Fix build-time test filtering in xunit wrapper generator.

* Fix some x86-specific issues

* Add a nice big comment block.

* Fix x86

* Refactor tests so we can skip one on Mono since Char->char lossy conversion is not supported.

* Disable test in issues.targets until an alternative solution is reached.

* Add another SkipOnMono attribute in the "Enabled" test suite.

* Apply UnmangedFunctionPointerAttribute to help hint to the Mono LLVM AOT compiler to compile the managed->native thunks at aot-time

* Unify on "runtime marshalling" terminology

* Clean up unused usings.

* Address Jan's feedback except for applying the attribute to CoreLib.

* PR feedback.

* Mono throws an InvalidProgramException for varargs

* Fix copy-paste issue.

* Make sure we use the P/Invoke's Module and not the caller's module when deciding if runtime marshalling is enabled for a varargs P/Invoke call.

* Handle how LLVM AOT reports the failure to handle varargs (EEE)

* Make ILLink validation steps in libs incrementally buildable (#64041)

* Make ILLink validation steps in libs incrementally buildable

Both the illink-oob and the illink-sharedframework targets don't define Inputs and Outputs which makes them run during no-op incremental builds. This change defines Inputs and Outputs based on what's used during the target's execution so that if the input assemblies or the illink assembly itself haven't changed, the step will be skipped.

Also renaming properties and items to make them more readable and consistent. As these target files are "extensions" of the src.proj file and aren't shared anywhere, they can be treated like logic inside a project file and hence prefixing properties and items with an underscore "_" isn't necessary.

* Fix broken callstacks in interpreter on MonoVM. (#60338)

* Fix some broken callstacks in interpreter.

* Fix build error.

* Initial WASI support prototype (#63890)

* Add StringSyntaxAttribute.Json (#64081)

* [main] Update dependencies from 5 repositories (#64002)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>

* Fix crash when VS4Mac is debugging VS4Mac arm64 (#64085)

Fix crash when VS4Mac is debugging VS4Mac arm64

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

* ILVerify: Handle readonly references in ldfld (#64077)

* ILVerify: Handle readonly references in ldfld

Fixes #63953

* Fix test name

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>

* Avoid additional local created for delegate invocations (#63796)

Very often 'this' is already a local and we can avoid creating another
local.

* [wasm][debugger] Apply changes on wasm using sdb protocol. (#63705)

* Apply changes on wasm using sdb protocol.

* conflict

* Merge conflict.

* Fix merge

* Fix compilation error.

* Fixed IsFloatPositiveZero from returning 'true' on non-constant double operands (#64083)

* Fixed IsFloatPositiveZero from returning 'true' on non-constant double operands

* Update src/coreclr/jit/gentree.h

Co-authored-by: Egor Bogatov <egorbo@gmail.com>

Co-authored-by: Egor Bogatov <egorbo@gmail.com>

* Ensure several helper intrinsics are correctly imported and handled (#63972)

* Ensure several helper intrinsics are correctly imported and handled

* Ensure that Sum for TYP_INT/UINT on Arm64 is correctly handled

* Respond to PR feedback and ensure ExtractMostSignificantBits for Vector64<int/uint> on Arm64 also uses AddPairwise

* Applying formatting patch

* Ensure the clsHnd is correct

* Fix the remaining musl failures

* Ensure that we aren't sign-extending TYP_BYTE (System.SByte) for ExtractMostSignificantBits

* Ensure an assert is correct on x64

* Ensure Vector64<int/uint>.Dot on Arm64 uses AddPairwise, not AddAcross

* Apply formatting patch

* RegexNode cleanup (#64074)

No functional changes, just code cleanup:
- Move node types into a RegexNodeKind enum
- Rename some of the kinds to make them more descriptive
- Rename node.Next to node.Parent to better describe its purpose
- Add a bunch of comments about node kinds

* Refactor optimizing morph for commutative operations (#63251)

* Create "fgOptimizeCommutativeArithmetic"

And just move code from "fgMorphSmpOp" to it.

Just one diff: better comma throw propagation in an ILGEN method.

* Refactor the function

Split it into specialized variants for each operator,
delete redundant code, fix up one case of wrong typing
for a constant in the MUL -> SHIFT optimization.

One CSE diff due to different VNs because of the typing
change for the constant (int -> long).

Many text diffs: "mov x3, 5" => "mov w3, 5".

* Do not set GTF_NO_CSE for sources of block copies (#63462)

It is not necessary, the compiler fully supports locals
on the RHS of a struct assignment. Not marking these results
in a CQ improvement, from struct (including SIMD) CSEs and
global constant propagation into promoted fields.

* Handle embedded assignments in copy propagation (#63447)

* Clean things up a little

Delete redundant conditions, use "LclVarDsc*", rename locals for clarity.

* Delete a redundant condition

For actual def nodes, GTF_VAR_CAST will never be set, it is
only set in "optNarrowTree" for uses.

For "def nodes" that are actually uses (parameters), the VNs
will never match anyway.

* Handle embedded assignments in copy propagation

Previously, as the comments in copy propagation tell us, it
did not handle "intervening", or not-top-level definitions of
locals, instead opting to maintain a dedicated kill set of them.

This is obviously a CQ problem, but also a TP one, as it meant
there had to be a second pass over the statement's IR, where
the definitions would be pushed on the stack.

This change does away with that, instead pushing new definitions
as they are encountered in execution order, and simultaneously
propagating on uses. Notably, this means the code now needs to
look at the real definition nodes, i. e. ASGs, not the LHS locals,
as those are encountered first in canonical execution order, i. e.
for a tree like:

```
  ASG
    LCL_VAR V00 "def"
    ADD
      LCL_VAR V00
      LCL_VAR V00
```

Were we to use the "def" as the definition point, we would wrongly
push it as the definition on the stack, even as the assignments
itself hasn't happened yet at that point.

There are nice diffs with this change, all resulting from unblocked
propagations, and mostly coming from setup arguments under calls.

* Simplify optIsSsaLocal

* Update format script permissions so it can be called on Unix systems directly. (#64107)

* Revert "Enable System.Text.Json tests on netfx (#63803)" (#64108)

This reverts commit 34794bc5f2bcdbaa9057bb07b8764e2bb6a411a2.

* Make ApiCompat.proj incrementally buildable (#64037)

* Make ApiCompat.proj incrementally buildable

In https://github.com/dotnet/runtime/pull/64000, I noticed that ApiCompat.proj never builds incrementally. Even though the RunApiCompat target has Inputs and Outputs, those aren't defined too late inside the target to have any effect. Moving them out and declare the generated response file as an output.

Also simplifying some msbuild logic and renaming some properties as underscore prefixes in project files don't make sense if the property isn't reserved in any way.

* Update ApiCompat.proj

* Remove enable drawing on unix switch (#64084)

* Remove enable drawing on unix switch

* Update some tests and not run tests that need Drawing on non Windows

* PR Feedback, just turn off the switch

* Address-expose locals under complex local addresses in block morphing (#63100)

* Handle complex local addresses in block morphing

In block morphing, "addrSpill" is used when the destination or source
represent indirections of "complex" addresses. Unfortunately, some trees
in the form of "IND(ADDR(LCL))" fall into this category.

If such an "ADDR(LCL)" is used as an "addrSpill", the underlying local
*must* be marked as address-exposed. Block morphing was using a very
simplistic test for when that needs to happen, essentially only recognizing
"ADDR(LCL_VAR/FLD)". But it is possible to have a more complicated pattern
as "PrepareDst/Src" uses "IsLocalAddrExpr" to recognize indirect stores
to locals.

Currently it appears impossible to get a mismatch here as morph transforms
"IND(ADD(ADDR(LCL_VAR), OFFSET))" into "LCL_FLD" (including for TYP_STRUCT
indirections), but this is a very fragile invariant. Transforming TYP_STRUCT
GT_FIELDs into GT_OBJs instead of GT_INDs breaks it, for example.

Fix this by address-exposing the local obtained via "IsLocalAddrExpr".

* Add a TODO-CQ for LCL_FLD usage

* [Group 2] Enable nullable annotations for `Microsoft.Extensions.DependencyInjection` (#63836)

* Annotate src

* Update ResolverBuilder.Build

* Update RunOnEmptyStackCore

* ILEmitResolverBuilderContext constructor

* Remove setter

* Add assert

* Enable nullable annotations for Microsoft.Extensions.Configuration.UserSecrets (#63700)

* [mono] Cleanup trailing whitespace. (#64112)

* Delete `GT_DYN_BLK` (#63026)

* Import GT_STORE_DYN_BLK directly

* Delete GT_DYN_BLK

* DynBlk -> StoreDynBlk

* Add some tests

* Mark tests Pri-1

* Rebase and fix build

* Bring back the odd early return

* Ignore conversion exceptions during dictionary construction (#63792)

* Extract SuperPMI into a separate component (#64035)

Allows building the runtime without SPMI.

`build.cmd clr` will still build SPMI.
`build.cmd clr.native` will still build SPMI.
`build.cmd clr.runtime` will no longer build SPMI.

This is mostly motivated by NativeAOT subset builds where SPMI contributes to 10% of the native build time (nativeaot CorecLR subset builds pretty quickly compared to full CoreCLR).

* Add COMWrappers to crossgen (#63969)

* pipelines: Add wasm jobs (#64109)

* Fixing update issue with multivalued properties #34267 (#56696)

* Add custom attribute test

* Adding test demonstrating issue #34267

* Solution for issue #34267

Replacing all values in property with the new collection, instead of just
appending new values, leaving old values in place.

* Incorporate review feedback

Changing the variable name

* Relax assert in ApplyEditAndContinue (#64132)

Fixes #64070

* Disable NJulianRuleTest test crashing in CI (#64142)

* Updating unit tests for DirectoryServices.AccountManagement (#56670)

Removing old, redundant unit tests that were actually never executed

Migrating old tests to new test infrastructure with configurable LDAP/AD
connections

* Fix MultiByteToWideChar call in pal (#64146)

* Extra tests for assembly name parser. (#64022)

* Dead code in native assembly name parsing

* disallow `\u` escaping in assembly names

* misc cleanup

* forward slash is illegal escaped or not

* ignore "language" attribute in assembly name ("culture" must be used)

* duplicate attributes are ok if unrecognized (just add tests)

* drop support for "custom" blob attribute

* drop support for publickey[token]=neutral ("null" must be used)

* ignore unknown assembly name attributes in mono (compat)

* disallow \0 anywhere in the assembly name

* disallow \0 in assembly names on mono (compat)

* only check for embedded nulls when parsing

* fix mono build

* make GCC happy

* couple test scenarios for publickey vs. publickeytoken (CoreRT parser might trip on these)

* produce errors on duplicate known attributes in mono

* Dispose LdapConnections used by ValidateCredentials (#62036)

Ensure that cached LdapConnection instances created by
PrincipalContext.ValidateCredentials are disposed when
the corresponding PrincipalContext is disposed.

Fix #62035

* Add runtime support for `ref` fields (#63985)

* Add mono and coreclr runtime support for ref fields

* Update Reflection.Emit tests to validate ref fields.

Add test for TypedReference as a ref field.

* Spmi replay asmdiffs mac os arm64 (#64119)

* Split unix-arm64 into linux-arm64 and osx-arm64 in src/coreclr/scripts/superpmi-replay.proj

* Split unix-arm64 into linux-arm64 and osx-arm64 in src/coreclr/scripts/superpmi-asmdiffs.proj

* Add all subdirectories of $(SuperPMIDirectory) as PMIPATH in src/coreclr/scripts/superpmi-collect.proj

* Update NativeAOT codegen and Crossgen2 for CreateSpan (#63977)

- Make sure FieldRVA pointers remain aligned as required by the code generator
  - Use the same Packing Size approach as the IL Linker will use (See jbevain/cecil#817 for details)
  - Compilers that generate CreateSpan will need to follow that trick to be compatible with rewriters.
- Provide ECMA spec augment describing packing size detail

* Add alignment to mapped field stream (#63305)

* Align MappeFieldDataStream at 8 byte boundary

* Add test to verify that the mapped field rva data blob is aligned to ManagedPEBuilder.MappedFieldDataAlignment

* Only align when the mapped field data is of size not equal to 0

* Implement hash and HMAC stream one shots 

This implements hashing and HMAC statics for streams. Additionally,
"LiteHmac" and "LiteHash" were introduced. The existing HMAC and hash
provider functionality do some bookkeeping we don't need for resetting.
Since we do not need to use these hash handles after the digest has
been finalized, resetting is unnecessary work. For HMAC, that also means
keeping a copy of the key around for some implementations which we don't
need to do.

The LiteHash and LiteHmac types are implemented as structs with a common
interface. To avoid boxing, generics are used and constrained to the interface
where possible.

The Browser implementation just defers to the existing HashDispenser rather
than do anything novel.

The HashProviderCng is somewhat specialized in its ability to reset. It did
up-front check to determine if the platform supported reusable hash providers,
and further had a single implementation for HMAC and Digests. The current
Lite hash design requires that they remain separate types.

* Title and message resources should be enforced to exist to prevent printing empty messages (#64151)

Sync ILLink.Shared folder with the latest version in dotnet/linker main branch

List of changes include:
- Enforce title and message resources to exist to prevent printing empty messages
- All diagnostics produced by linker now have a DiagnosticId, a title and a message
- Schema for xml link attributes file

- Added a readme file to the ILLink.Shared project to keep track of the commit is being used from dotnet/linker

* Allow generating Dwarf version 5 (#63988)

Contributes to https://github.com/dotnet/runtimelab/issues/1738.

* Re-enable failing long path test (#64113)

* Port MD4 managed implementation from mono/mono (#62074)

Porting MD4 managed implementation from mono/mono (MD4.cs and MD4Managed.cs). 
  
It adds:  
- an internal class in the System.Net.Security with a single HashData method for now;  
- a set of related MD 4 unit tests to System.Net.Security.Unit.Tests project.

* Fix one source of perf regression in GCHeap::Alloc. This impacts the System.Collections.CtorFromCollectionNonGeneric<Int32> family of benchmarks. (#64091)

These benchmarks manage to make GCHeap::Alloc into a hotspot, so the call to IsHeapPointer() at the end matters for performance.

* Add blsr (#63545)

* Fix FileSystemAclExtensions.Create when passing a null FileSecurity (#61297)

* Make FileSecurity parameter nullable.

* Add missing ArgumentException message for FileMode.Append.

* Refactor tests to ensure FileSecurity is tested with all FileMode and FileSystemRights combinations. Separate special cases.

* Remove exception that throws when FileSecurity is null.
Ensure we have logic that can create a FileHandle when FileSecurity is null.
Fix bug where FileShare.Inheritable causes IOException because it is being unexpectedly passed to the P/Invoke (it should just be saved in the SECURITY_ATTRIBUTES struct).
Add documentation to mention this parameter as optional.
Ensure all exceptions match exactly what we have in .NET Framework, with simpler logic.

* Address suggestions

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>

* Tune FP CSEs live across a call better (#63903)

The problem was that the comparison of a weighted refcount,
which usually has the order of hundreds or tens, with a small
digit like "4" was too weak and missed some cases where we
were still trying to CSE cheaps floats across calls and ending
up with lots of stack shuffling.

Fix this by using different tuning parameters, namely the costs
estimated for the uses and defs (increase them to account for
the spills and reloads).

* [main] Update dependencies from dotnet/arcade dotnet/icu dotnet/xharness dotnet/emsdk (#64098)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update zip extraction to never throw any exceptions when the LastWriteTime update fails (#63912)

* Use kebab-case in FB automation labels (#64048)

* Onboard new Triage & PR Boards (#64198)

* Exclusively use GitHub teams for Libraries area mentions (#64199)

* Reduce buffer size used in XmlReader when using Async mode (#63459)

The current choice of AsyncBufferSize resulted in the character buffer in the XmlTextReader being allocated on the Large Object Heap (LOH)

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

* Ignoring leading dot when comparing cookie domains (#64038)

* ignoring leading dot when comparin cookie domain

* Simplify cookie comparing logic to equality and moving it to CookieComparer to fix the build

* Domain comparing optimizarion and more unit tests

* small check optimization

* Renaming method

* Add missing handle function enter/return macros (#64061)

The mono_field_static_get_value method uses a handle, but did not set up
enter/exit macros properly, so this handle was leaked.

Some code in Unity calls this embedding API method pretty often, which
can lead to the mark stack overflowing in the GC code.

* Drop support for .NET 5 SDK (#64186)

We had to duplicate a lot of Microsoft.NET.ILLink.targets logic.

* Implement IEquatable<T> on value types overriding Equals (and enable CA1066/1077) (#63690)

* [mono] Temporarily disable two tests that fail on arm64 LLVM FullAOT. (#64180)

* Delete stale reference in System.Drawing.Primitives (#64202)

* Respond to feedback in GenerateMultiTargetRoslynComponentTargetsFile (#63943)

* Respond to feedback in GenerateMultiTargetRoslynComponentTargetsFile

Two small follow up changes from #58446

- Fix a type-o that breaks incremental build. Forgot to use MSBuild property syntax
- Instead of having the infrastructure hard-code removing 'Abstractions', packages can set their own Disable source gen property name.

* PR feedback

* Use the static HashData(Stream) method in more places

* Add executable bit to tizen sh files (#64216)

* Bump Intellisensense package version to latest from `dotnet7-transport` (#63352)

* Ensure that we aren't accidentally generating instructions for unsupported ISAs (#64140)

* Assert that the ISA of the set intrinsic ID is supported

* Ensure gtNewSimdCmpOpAllNode and gtNewSimdCmpOpAnyNode don't generate AVX2 instructions when not supported

* Ensure codegen for Vector128.Dot when SSSE3 is disabled is correct

* Update src/coreclr/jit/hwintrinsiccodegenarm64.cpp

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Ensure Vector256.Sum has a check for AVX2

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* Don't reference .NETFramework shims in libraries product or test composition (#64193)

* Don't reference .NETFramework shims

Stop referencing .NETFramework shims in libraries ref or source projects as those are supplementary and shouldn't impact the product composition.

* [Android][libs] Enable Internal.Console.Write in System.Private.CoreLib (#63949)

* [Android][libs] Enable Internal.Console.Write in System.Private.CoreLib

* [docs] Add debugging System.Private.CoreLib Internal.Console.Write

* Elaborate on debugging corelib log

* Address feedback

* Install v8 and Prebuild wasm (#64100)

* Port Mono to Raspberry Pi, ship as new linux-armv6 RID (#62594)

* Initial ARMv6 arch addition. Builds mono runtime, not CoreCLR (Mono already supports the CPU arch subset used by Raspberry Pi, whilst porting CoreCLR to e.g. VFPv2 would be major work)
* Build small clr subset on ARMv6, it's needed for SDK and we want to check it works

* Fix remote unwind (#64220)

The _OOP_find_proc_info was setting only a couple of members of the
unw_dyn_info_t instance on stack. So the remaining ones had random
values. The load_offset was a recently added member to the struct.
When we have updated libunwind, this change came in. The load_offset was
random and that has broken unwindign as this offset is subtracted from
the IP when looking up unwind info.

The fix clears the whole struct. I have verified that the issue we had no
longer happens with the fix.

* Put back FindCaseSensitivePrefix regex alternation support (#64204)

* Put back FindCaseSensitivePrefix alternation support

* Fix the bug from the initial version, and add more comments

* Update tests to expect RemoteExecutor to check exit code (#64133)

* update generation_allocation_size correctly for SIP regions (#64176)

SIP regions need to update the corresponding generation's generation_allocation_size and since this can be more than 1 gen older than the region's gen, we need to make all generation's alloc size get updated.

* Android remove backward timezones (#64028)

Fixes #63693

It was discovered that Android produces duplicate TimeZone DisplayNames among all timezone IDs in GetSystemTimeZones. These duplicate DisplayNames occur across TimeZone IDs that are aliases, where all except one are backward timezone IDs.

If a name is changed, put its old spelling in the 'backward' file

From the Android TimeZone data file tzdata, it isn't obvious which TimeZone IDs are backward (I find it strange that they're included in the first place), however we discovered that on some versions of Android, there is an adjacent file tzlookup.xml that can aid us in determining which TimeZone IDs are "current" (not backward).

This PR aims to utilize tzlookup.xml when it exists and post-filter's the Populated TimeZone IDs in the AndroidTzData instance by removing IDs and their associated information (byteoffset and length) from the AndroidTzData instance if it is not found in tzlookup.xml. This is using the assumption that all non-backward TimeZone IDs make it to the tzlookup.xml file.

This PR also adds a new TimeZoneInfo Test to check whether or not there are duplicate DisplayNames in GetSystemTimeZones

* Update main branding to preview2 (#64219)

* Catch UnicodeEncodeErrors (#64251)

* Make XmlSerializer.Generator targets incremental (#64191)

* Make XmlSerializer.Generator targets incremental

Adding inputs and outputs to make XmlSerializer.Generator incremental

* Make sure that shared memory object name meets the length requirements (#64099)

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

* Fix PAL_wprintf for wide characters (#64181)

* [main] Update dependencies from dotnet/runtime dotnet/llvm-project (#64205)

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

Microsoft.NETCore.ILAsm , Microsoft.NETCore.DotNetHostPolicy , Microsoft.NETCore.DotNetHost , Microsoft.NETCore.App.Runtime.win-x64 , System.Runtime.CompilerServices.Unsafe , runtime.native.System.IO.Ports , Microsoft.NET.Sdk.IL , System.Text.Json
 From Version 7.0.0-alpha.1.22066.4 -> To Version 7.0.0-alpha.1.22073.5

* Update dependencies from https://github.com/dotnet/llvm-project build 20220123.1

runtime.win-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.win-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.osx.11.0-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-musl-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-arm64.Microsoft.NETCore.Runtime.ObjWriter
 From Version 1.0.0-alpha.1.22070.1 -> To Version 1.0.0-alpha.1.22073.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Delete unused ApiCompat baseline files (#64190)

* Delete unused ApiCompat baseline files

* Delete ApiCompatBaseline.netfx.netstandardOnly.txt

* Remove manual .NETFramework baseline validation

* Delete ApiCompatBaseline.netcoreapp.netfx461.ignore.txt

* Delete ApiCompatBaseline.netcoreapp.netfx461.txt

* Improve Regex handling of anchors (#64177)

* Improve Regex handling of anchors

- Extend search for leading anchor to support alternations.  This means that an expression like `^abc|^def` will now observe the leading `^` whereas previously it didn't.
- Add a FindFirstChar optimization that jumps to the right position for a pattern that matches a computeable max length and ends with an end anchor.

* Address PR feedback

* Add the exception set for `ObjGetType` (#64106)

* Model NRE for ObjGetType

* Add tests

* [ILVerify] Fix casting check for arrays of generic parameters with class constraints (#64259)

Fixes #63999

* Use lower call count threshold for tiering in debug builds (#60945)

* Use lower call count threshold for tiering in debug builds

To exercise more paths during tests, see https://github.com/dotnet/runtime/pull/60886

* Skip tests using AsyncIO in FileSystemAclExtensionsTests where it's not supported (#64212)

The mono runtime does not yet support AsyncIO on Windows and there were some tests failing on CI because of it.
Fixes #64221

* Correct JsonNode.Root doc (#64238)

* Take ARMv6 out of PlatformGroup All (#64267)

* Take ARMv6 out of PlatformGroup All, CoreCLR assumes this means full support

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>

* Only send to Helix for rolling build, due to small Helix queue (#64274)

* Add ref field runtime feature indication (#64167)

* Add ref field runtime feature indication

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

* Faster IndexOf for substrings (#63285)

* Improve "lastChar == firstChar" case, also, use IndexOf directly if value.Length == 1

* Try plain IndexOf first, to optimize cases where even first char of value is never met

* add 1-byte implementation

* copyrights

* fix copy-paste mistake

* Initial LastIndexOf impl

* More efficient LastIndexOf

* fix bug in Char version (we need two clear two lowest bits in the mask) & temporarily remove AdvSimd impl

* use ResetLowestSetBit

* Fix bug

* Add two-byte LastIndexOf

* Fix build

* Minor optimizations

* optimize cases with two-byte/two-char values

* Remove gotos, fix build

* fix bug in LastIndexOf

* Make sure String.LastIndexOf is optimized

* Use xplat simd helpers - implicit ARM support

* fix arm

* Delete \

* Use Vector128.IsHardwareAccelerated

* Fix build

* Use IsAllZero

* Address feedback

* Address feedback

* micro-optimization, do-while is better here since mask is guaranteed to be non-zero

* Address feedabc

* Use clever trick I borrowed from IndexOfAny for trailing elements

* give up on +1 bump for SequenceCompare

* Clean up

* Clean up

* fix build

* Add debug asserts

* Clean up: give up on the unrolled trick - too little value from code bloat

* Add a test

* Fix build

* Add byte-specific test

* Fix build

* Update IndexOfSequence.byte.cs

* [main] Update dependencies from dotnet/arcade dotnet/xharness dotnet/icu dotnet/hotreload-utils dotnet/llvm-project (#64265)

* Update dependencies from https://github.com/dotnet/arcade build 20220124.13

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

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

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

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

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 7.0.0-preview.2.22071.2 -> To Version 7.0.0-preview.2.22074.5

* Update dependencies from https://github.com/dotnet/hotreload-utils build 20220124.1

Microsoft.DotNet.HotReload.Utils.Generator.BuildTool
 From Version 1.0.2-alpha.0.22069.1 -> To Version 1.0.2-alpha.0.22074.1

* Update dependencies from https://github.com/dotnet/llvm-project build 20220124.2

runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools
 From Version 11.1.0-alpha.1.22067.2 -> To Version 11.1.0-alpha.1.22074.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Add CancellationToken to TextReader.ReadXAsync (#61898)

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>

* Restrict parallelism in LLVM FullAOT compile, to prevent OOM (#63800)

* Restrict parallelism in FullAOT compile, to prevent OOM

* Reduce parallelism further, due to more OOM

* Moved AssemblyName helpers to managed (#62866)

* Moved ComputePublicKeyToken to managed

* Managed assembly name parsing (adapted from nativeaot)

* Fix for HostActivation failures.

* PR feedback (RuntimeAssemblyName is back to CoreRT + other comments)

* remove AssemblyNameNative::Init form the .hpp

* remove AppX compat ifdef

* renamed instance fields to convention used in C#

* `Argument_InvalidAssemblyName`   should be   `InvalidAssemblyName`. Majority of use is `FileLoadException`.

* remove `this.`

* PR feedback (assign to fileds, bypass properties)

* missed this change in the rebase

* "low-hanging fruit" perf tweaks.

* move one-user helpers to where they are used.

* removed ActiveIssue for #45032

* remove AssemblyNameHelpers.cs form corelib

* Remove the List when detecting duplicates. Support PublicKey.

* whitespace

* Fix managed implementation to match the new tests.

* Some minor cleanup.

* Do not validate culture too early

* PR feedback

* use SR.InvalidAssemblyName

* Report the input string when throwing FileLoadException

* tweaked couple comments

* Disable RegexReductionTests tests on browser

* Fix formatting of resource string where excess arguments are passed (#63824)

* Fix formatting of resource string where excess arguments are passed. #63607

* Fix BuildCharExceptionArgs and ECCurve.Validate

* Fix CA2208

* Fix CA2208. Remove paramName becaus it is in error message

* Code review fixes

* Code review fixes

* Add Regex.Count string overloads (#64289)

* Clarify purpose of PDB Document hashing (#64306)

Fixes #63505

* Fix arm64/PInvoke so that NESTED_ENTRY/NESTED_END labels match. (#64296)

This was exposed by building on arm64 with gcc-12,
wherein the assembler complained about not being able
to evaluate the constant expression for .size for the symbol
on NESTED_END.  Since the symbol on NESTED_END is not
referenced anywhere else in the code base,
I concluded that it was wrong, and NESTED_ENTRY was right.

I have not tested this on anything but arm64 + gcc-12

* When decommitting, leaving one instead of two pages in regions case. (#64243)

* Ensure that canceled Task.Delays invoke continuations asynchronously from Cancel (#64217)

* Add gen folder moving gen projects from src folder (#64231)

* Fix minor typos in GC documentation. (#64298)

* Explicitly specify four subdirectories to use as part of the paths for -pmi_path arguments and expand the paths on a remote machine in src/coreclr/scripts/superpmi-collect.proj (#64308)

* Disable RegexReductionTests on browser (#64312)

* Add UnreachableException (#63922)

* [mono] Recognize new names for Xamarin.iOS etc assemblies (#64278)

They are being renamed in https://github.com/xamarin/xamarin-macios/pull/13847

* Remove usage of codecvt from corerun (#64157)

* Remove usage of codecvt from corerun

* Update src/coreclr/hosts/corerun/corerun.cpp

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

Co-authored-by: Aaron Robinson <arobins@microsoft.com>

* Refactor FileStatus.Unix. (#62721)

* Refactor FileStatus.Unix.

- Moves InitiallyDirectory out of FileStatus into FileSystemInfo.
In FileSystemInfo it can be a readonly field making its usage clearer.
And FileStatus can then directly be used to implement some FileSystem methods
without allocating an intermediate FileInfo/DirectoryInfo.

- Treat not exists/exist as initialized states to avoid wrongly assuming
initialized means the file cache is valid, which isn't so when the file does
not exist.

- Use 0 for tracking uninitialized to make default(FileStatus) uninitialized.

* Fix unique VNs for `ADDR`s (#64230)

* Add the test

* Fix unique VNs for ADDRs

They need to keep the exception sets.

* Implemented hierarchy of attributes. (#64201)

* Implemented hierarchy of attributes.

* Shortened.

* Fixed overlooked test naming and simplified.

* Partial refactor.

* Update the managed type system to more gracefully fail when calling a varargs method. (#64286)

* Update the managed type system to more gracefully fail when calling a varargs method.

* Use ThrowHelper instead of manually throwing the exception.

* Update src/coreclr/tools/Common/TypeSystem/Ecma/EcmaSignatureParser.cs

Co-authored-by: Jan Kotas <jkotas@microsoft.com>

* [mono] Add some missing Internal.Runtime.CompilerServices.Unsafe intrinsics. (#64314)

* Remove usage of FEATURE_CORESYSTEM (#63850)

* Remove usage of FEATURE_CORESYSTEM from coreclr.

* [main] Update dependencies from dotnet/arcade dotnet/runtime-assets (#64331)

* Update dependencies from https://github.com/dotnet/arcade build 20220125.6

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

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

Microsoft.DotNet.CilStrip.Sources , System.ComponentModel.TypeConverter.TestData , System.Drawing.Common.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.22060.1 -> To Version 7.0.0-beta.22075.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Fixes bad log method generation in certain cases. (#64311)

In certain cases when developer by mistake places ILogger, Exception, or LogLevel in the message template,  the code generator will produce the expected warning and makes sure the code will indeed compile and run correctly.

Prior to this fix, the code generator would fail to compile with when either of ILogger, Exception or LogLevel were placed in message template incorrectly.

Fixes #64310

* Fix IsMutuallyAuthenticated on Linux and OSX (#63945)

* WIP - prepared a failing test

* Fix IsMutuallyAuthenticated on Linux

* Fix failing unit tests

* Minor cleanup

* Port changes to OSX

* Fix comment

* Invoke cert selection inline, don't allocate new credentials on Linux/OSX

* Fix tests on OSX

* Code review feedback

* Move tests to separate file

* Fix build

* Fix Failing tests

* Support {Last}IndexOfAny with sets after {lazy} loops (#64254)

When emitting backtracking loops, the loop consumes as much and then backtracks through the consumed input.  Rather than doing this one character by one character, we previously added use of LastIndexOf to search for the next place the literal after the loop matches.  We can also augment that to use IndexOfAny to search for a small set that comes after a loop instead of a literal.

Similarly when emitting backtracking lazy loops, rather than consuming one character and trying the rest of the expression and then consuming another character and trying the rest of the expression, we previously added an optimization to use IndexOf{Any} to find the next possible location of a match based on the literal that comes after the lazy loop.  And we can similarly augment that to support a small set after the lazy loop.

This is particularly helpful for IgnoreCase, as we're on a path to replacing literals with sets that contain all equivalent casings of that character.

* Fix race conditions in SystemEvents shutdown logic (#62773)

* Fix race conditions in SystemEvents shutdown logic

When the application is terminated through Restart Manager the event broadcasting window will get the `WM_CLOSE` message. The message gets handled by passing it to `DefWndProc` which calls `DestroyWindow` on the window itself thus making the window handle invalid. The `Shutdown` method expects the window handle to be valid to post `WM_QUIT` message to terminate the thread running the message loop but that's no longer possible under these conditions.

Additionally there's second race condition with the `s_eventThreadTerminated` event that is created during shutdown and set conditionally. A race condition between the threads could cause it to be created when the window message thread is already shutting down and thus it would never be set. Waiting for it in the `Shutdown` method would be cause a deadlock. This thread is also completely unnecessary since a `Join` is performed on the thread itself.

The fix has several changes that act together:
- `s_eventThreadTerminated` event is removed completely in favor of only relying on `Thread.Join`
- `WM_DESTROY` message is detected (which happens as a result of WM_CLOSE calling `DefWndProc` which in turn calls `DestroyWindow`) and handled by shutting down the message loop thread
- The message loop itself is rewritten to use standard `GetMessageW` loop. The reasoning on why it was not used seems not to be valid anymore since AppDomain shutdowns are performed differently

* Add unit test.

* Add braces

* Add marshaller for TypeLoad failure cases (#64317)

This is marshaller used when there incorrect configuration of marshaller applied to fields mostly

* Add additional loop table asserts (#64126)

1. Assert that top-level loops are basic block disjoint
2. Assert LPFLG_ITER related flags are legal

In addition:
1. Create a `optClearLoopIterInfo` phase to clear various bits in the loop
table that are known to no longer be valid, to prevent bad asserts or JitDump
output on their values.
2. Move the EndPhase call in Phase::PostPhase happens early, not late.
This causes any subsequent asserts due to post-phase checking to be
marked with the correct phase, in cases where there was a nested phase
executed (such as liveness re-computation).
3. Convert PHASE_INSERT_GC_POLLS to use EndPhase checking
4. Convert fgDetermineFirstCodeBlock to return a PhaseStatus
5. Some minor cleanup in optUpdateLoopsBeforeRemoveBlock()
(this was extracted from some bigger changes)

* Moved AssemblyName helpers to managed (part 2) (#63915)

* implement GetAssemblyName via dynamic call to MetadataReader

* A few more file-locking tests.

* fix #28153

* no need for version when getting MetadataReader

* rename the argument to match AssemblyName

* perf tweaks

* use memory-mapped file to read metadata

* adjust tests for the new implementation

* use "bufferSize: 1" when stream is going to be mapped.

* null-conditional operator.

* do Dispose before re-throwing

* get rid of the platform-specific/native stuff

* remove assemblyname.hpp

* remove `VerifyIsAssembly()`

* PR feedback

* put back gStdMngIEnumerableFuncs and the others

* Fix several bugs in NullabilityInfoContext. (#64143)

* Fix several bugs in NullabilityInfoContext.

* Reverse ASG(CLS_VAR, ...) (#63957)

This helps with register allocation. Consider:
```
***** BB01
STMT00001 ( 0x000[E-] ... ??? )
N003 ( 18, 10) [000003] -ACXG-------              *  ASG       ref    $c0
N001 (  3,  4) [000002] ----G--N----              +--*  CLS_VAR   ref    Hnd=0x8fec230 Fseq[hackishFieldName]
N002 ( 14,  5) [000000] --CXG-------              \--*  CALL      ref    CscBench.GetMscorlibPathCore $c0
```
The rationalizer will rewrite it to what is effectively:
```
***** BB01
STMT00001 ( 0x000[E-] ... ??? )
N004 ( 18, 12) [000003] -ACXG---R---              *  ASG       ref
N003 (  3,  6) [000002] n---G--N----              +--*  IND       ref
N002 (  1,  4) [000006] H-----------              |  \--*  CLS_VAR_ADDR byref  Hnd=0x8fec230
N001 ( 14,  5) [000000] --CXG-------              \--*  CALL      ref    CscBench.GetMscorlibPathCore
```
And the final LIR will look like:
```
               [000006] ------------                 IL_OFFSET void   INLRT @ 0x000[E-]
N001 (  3,  4) [000002] ----G--N----         t2 =    CLS_VAR_ADDR byref  Hnd=0x8fec230
N002 ( 14,  5) [000000] --CXG-------         t0 =    CALL      ref    CscBench.GetMscorlibPathCore $c0
                                                  /--*  t2     byref
                                                  +--*  t0     ref
N003 ( 18, 10) [000…
adamsitnik pushed a commit that referenced this pull request Jun 12, 2023
…tnet#87189)

This fixes a startup crash on Big Sur:

> error: * Assertion at /Users/runner/work/1/s/src/mono/mono/utils/mono-hwcap-arm64.c:35, condition `res == 0' not met

Because sysctl can't find some of these options:

    $ sysctl hw.optional.armv8_crc32
    hw.optional.armv8_crc32: 1
    $ sysctl hw.optional.arm.FEAT_RDM
    sysctl: unknown oid 'hw.optional.arm.FEAT_RDM'
    $ sysctl hw.optional.arm.FEAT_DotProd
    sysctl: unknown oid 'hw.optional.arm.FEAT_DotProd'
    $ sysctl hw.optional.arm.FEAT_SHA1
    sysctl: unknown oid 'hw.optional.arm.FEAT_SHA1'
    $ sysctl hw.optional.arm.FEAT_SHA256
    sysctl: unknown oid 'hw.optional.arm.FEAT_SHA256'
    $ sysctl hw.optional.arm.FEAT_AES
    sysctl: unknown oid 'hw.optional.arm.FEAT_AES'

Full stack trace:

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x0000010ef37560 libmonosgen-2.0.dylib`monoeg_assertion_message
    frame #1: 0x0000010ef375cc libmonosgen-2.0.dylib`mono_assertion_message + 32
    frame #2: 0x0000010ef40d6c libmonosgen-2.0.dylib`mono_hwcap_arch_init + 544
    frame #3: 0x0000010ef54bd8 libmonosgen-2.0.dylib`mono_hwcap_init + 72
    frame #4: 0x0000010ee14dc0 libmonosgen-2.0.dylib`parse_optimizations + 52
    frame #5: 0x0000010edbed48 libmonosgen-2.0.dylib`mono_init
    frame #6: 0x0000010ee18968 libmonosgen-2.0.dylib`mono_jit_init_version
    frame #7: 0x0000010f48a300 libxamarin-dotnet-debug.dylib`xamarin_bridge_initialize + 216
    frame #8: 0x0000010f4900a4 libxamarin-dotnet-debug.dylib`xamarin_main + 376
@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
1 participant