platform/upstream/dotnet/runtime.git
12 months agoHave jitstress_isas_x86_evex set PreferredVectorBitWidth=512 (#88531)
Tanner Gooding [Sat, 8 Jul 2023 17:39:10 +0000 (10:39 -0700)]
Have jitstress_isas_x86_evex set PreferredVectorBitWidth=512 (#88531)

* Have jitstress_isas_x86_evex set PreferredVectorBitWidth=512

* Ensure that IsHardwareAccelerated correctly takes the preferred width into account

* Ensure the tests take DOTNET_PreferredVectorBitWidth into account

* Ensure PreferredVectorBitWidth is interpreted as a decimal

* Fix a build failure where the default value wasn't passed in

* Minor whitespace fix to trigger CI

12 months ago[RISC-V, LOONGARCH64] Fix FuncEvalHijack stackallocation (#88493)
t-mustafin [Sat, 8 Jul 2023 08:46:36 +0000 (11:46 +0300)]
[RISC-V, LOONGARCH64] Fix FuncEvalHijack stackallocation (#88493)

13 months ago[interp] Add MINT_STELEM_VT_NOREF (#87161)
Katelyn Gadd [Sat, 8 Jul 2023 04:59:12 +0000 (21:59 -0700)]
[interp] Add MINT_STELEM_VT_NOREF (#87161)

Based on instrumentation 0.2% of all mono_gc_wbarrier_value_copy_internal calls in a run of System.Runtime.Tests are from MINT_STELEM_VT. I suspect adding this NOREF version of the opcode will improve performance for data structures that store structs in arrays but don't contain any references - for example List<ValueTuple<...>> or Dictionary<int, int> - but it's hard to measure locally.

13 months agoPrint variable types when dumping the output (#88420)
Michał Petryka [Fri, 7 Jul 2023 20:59:21 +0000 (22:59 +0200)]
Print variable types when dumping the output (#88420)

13 months agoDisallow Options source gen produce diagnostics from outside the compilation (#88396)
Tarek Mahmoud Sayed [Fri, 7 Jul 2023 17:58:29 +0000 (10:58 -0700)]
Disallow Options source gen produce diagnostics from outside the compilation (#88396)

13 months agoFix Int128 truncating conversion discarding significant bits (#88526)
Nate Hitze [Fri, 7 Jul 2023 17:05:46 +0000 (13:05 -0400)]
Fix Int128 truncating conversion discarding significant bits (#88526)

Also fixes test that would have caught this bug.

Fixes #88389

13 months agoFIx SequenceReader Rewind(0) state corruption (#86070)
hrrrrustic [Fri, 7 Jul 2023 16:46:19 +0000 (19:46 +0300)]
FIx SequenceReader Rewind(0) state corruption (#86070)

* Add zero check

* Drop few redundant readonly

* Add test

13 months agoUse E3 to completely clear console on Unix when possible (#88487)
Nate Hitze [Fri, 7 Jul 2023 16:39:56 +0000 (12:39 -0400)]
Use E3 to completely clear console on Unix when possible (#88487)

* Use E3 to clear console on Unix when possible

Some terminals define an extra sequence to clear the terminal scroll
buffer. Using it before the clear sequence makes Clear() work like the
'clear' command.

Fix #84351

13 months agoIgnore suppressed diagnostics in code fix verifier (#88492)
Sven Boemer [Fri, 7 Jul 2023 16:33:25 +0000 (18:33 +0200)]
Ignore suppressed diagnostics in code fix verifier (#88492)

The failures started with
https://github.com/dotnet/runtime/commit/299a8c9c178c38c6e7ca62b1bcce8f6e0d895ebe,
which pulled in changes to the test SDK such that suppressed warnings
are now included in the set of warnings checked by the code fix
verifier.

13 months agoImprove BigInteger operators +, - and * for trivial cases (#84733)
Alexander Speshilov [Fri, 7 Jul 2023 16:01:15 +0000 (19:01 +0300)]
Improve BigInteger operators +, - and * for trivial cases (#84733)

* Improve BigInteger operators +, - and * for trivial cases

Move handling of trivial cases from internal methods with span
arguments to to the very beginning of public operators. This avoids
creating unneeded spans, checking them to empty state and some other
unneeded operations.

Does not affect time of processing non-trivial arguments.

Discussion: dotnet#84721

* Add assert when both left and right argument's spans are empty

13 months ago[wasm] Fix WasmBase.IsSupported in AOT (#88523)
Radek Doulik [Fri, 7 Jul 2023 15:10:37 +0000 (17:10 +0200)]
[wasm] Fix WasmBase.IsSupported in AOT (#88523)

Add `WasmBase` to `supported_wasm_intrinsics group`. That way we handle the `WasmBase`
correctly when SIMD is enabled (default case). Before this change the `emit_hardware_intrinsics`
returned false for the `WasmBase.IsSupported`, because it wasn't in the group and we are using
it for the whole `S.R.I.Wasm` namespace.

Example of the emitted code difference to confirm the fix:

    (func corlib_ulong_Log2_ulong(param i64, i32) (result i64)) code size difference: -30 bytes
    ...
       local.get $0
       i64.const
    -  i64.shr.u
    -  i32.wrap.i64
    -  local.tee $1
    -  i32.eqz
    +  i64.or
    +  i64.clz
    +  i64.const
    +  i64.xor
    -  if
    -   local.get $0
    -   i32.wrap.i64
    -   i32.const
    -   i32.or
    -   local.get $1
    -   call corlib_System_Numerics_BitOperations_Log2SoftwareFallback_uint
    -   i64.extend.i32.u
    -   return
    -
    -  local.get $1
    -  i32.const
    -  i32.or
    -  local.get $1
    -  call corlib_System_Numerics_BitOperations_Log2SoftwareFallback_uint
    -  i32.const
    -  i32.add
    -  i64.extend.i32.u

13 months agoStringBuilder: use Span.Fill in Append repeating char (#86287)
Jesper Meyer [Fri, 7 Jul 2023 14:59:57 +0000 (16:59 +0200)]
StringBuilder: use Span.Fill in Append repeating char (#86287)

13 months agoOptimized conversions between `Half` and `Single`. (#81632)
ちーず(・8・)けーき [Fri, 7 Jul 2023 14:57:03 +0000 (23:57 +0900)]
Optimized conversions between `Half` and `Single`. (#81632)

Closes #69667.

13 months agoReduce size of non-inlined ArgumentOutOfRangeException throw helpers (#88508)
Stephen Toub [Fri, 7 Jul 2023 14:56:08 +0000 (10:56 -0400)]
Reduce size of non-inlined ArgumentOutOfRangeException throw helpers (#88508)

Keeping the arguments of the delegated throw method the same order as the callee avoids unnecessary spilling.

13 months ago[RISCV] Fix .cfi directives in asm-files (#88259)
t-mustafin [Fri, 7 Jul 2023 14:33:56 +0000 (17:33 +0300)]
[RISCV] Fix .cfi directives in asm-files (#88259)

13 months agoExtend `JsonIncludeAttribute` and `JsonConstructorAttribute` support to internal...
Eirik Tsarpalis [Fri, 7 Jul 2023 11:40:29 +0000 (12:40 +0100)]
Extend `JsonIncludeAttribute` and `JsonConstructorAttribute` support to internal and private members (#88452)

* Relax JsonIncludeAttribute to also support private or internal members.

* Relax JsonConstructorAttribute to include internal or private constructors (where applicable).

13 months ago[mono][interp] Tweaks to x86 call convention handling (#88466)
Vlad Brezae [Fri, 7 Jul 2023 09:46:15 +0000 (12:46 +0300)]
[mono][interp] Tweaks to x86 call convention handling (#88466)

First, we no longer assert that the call convetion is cdecl on the slowpath. The pinvoke trampoline on x86 restores the saved stack pointer so it doesn't matter if the pinvoke callee pops or not the stack. Therefore both stdcall and cdecl calls should be supported with the same path. Untested.

Second, we use the fastpath (which uses the C call convention) only if the pinvoke signature is also cdecl, otherwise we have cconv mismatch.

13 months agoDisable default JSON reflection when PublishTrimmed == true (#88480)
Eirik Tsarpalis [Fri, 7 Jul 2023 08:45:01 +0000 (09:45 +0100)]
Disable default JSON reflection when PublishTrimmed == true (#88480)

13 months agoBring back old array enumerator code (#88371)
Michal Strehovský [Fri, 7 Jul 2023 07:38:43 +0000 (16:38 +0900)]
Bring back old array enumerator code (#88371)

This is a 0.3% size saving for Stage1. We not only allow array enumerators to be preinitialized again, but also avoid introducing many array `MethodTables` (looks like the new enumerators force array MethodTables for cases where we could have avoided them).

Fixes #82993.

13 months agoDisable failing `simpleruntimeeventvalidation` test on mono. (#88500)
Ankit Jain [Fri, 7 Jul 2023 04:17:25 +0000 (00:17 -0400)]
Disable failing `simpleruntimeeventvalidation` test on mono. (#88500)

* Disable `simpleruntimeeventvalidation` test on mono.

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

Failing with:
```
      Expected: True
      Actual:   False
      Stack Trace:
           at tracing_eventpipe._simpleruntimeeventvalidation_simpleruntimeeventvalidation_simpleruntimeeventvalidation_._simpleruntimeeventvalidation_simpleruntimeeventvalidation_simpleruntimeeventvalidation_sh()
           at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
           at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
      Output:

        Return code:      1
        Raw output file:      /root/helix/work/workitem/uploads/Reports/tracing.eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation/simpleruntimeeventvalidation.output.txt
        Raw output:
        BEGIN EXECUTION
        /root/helix/work/correlation/corerun -p System.Reflection.Metadata.MetadataUpdater.IsSupported=false -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true simpleruntimeeventvalidation.dll ''
          0.0s: ==TEST STARTING==
          0.2s: Connecting to EventPipe...
          0.2s: Started sending sentinel events...
          0.4s: Creating EventPipeEventSource...
          0.4s: EventPipeEventSource created
          0.4s: Dynamic.All callback registered
          0.4s: Running optional trace validator
          0.4s: Finished running optional trace validator
          0.4s: Starting stream processing...
          0.6s: Saw sentinel event
          0.6s: Stopped sending sentinel events
          0.6s: Starting event generating action...
          0.6s: Called GC.Collect() 0 times...
          0.7s: Called GC.Collect() 10 times...
          0.7s: Called GC.Collect() 20 times...
          0.7s: Called GC.Collect() 30 times...
          0.7s: Called GC.Collect() 40 times...
          0.7s: Stopping event generating action
          0.7s: Sending StopTracing command...
          0.7s: Saw new provider 'Microsoft-DotNETCore-EventPipe'
          0.7s: Stopping stream processing
          0.7s: Dropped 0 events
          0.7s: Finished StopTracing command
          0.7s: Reader task finished
          0.8s: Test FAILED!
          0.8s: No events for provider "Microsoft-Windows-DotNETRuntime"
          0.8s: Configuration:
          0.8s: {
          0.8s: providers: [
          0.8s: ]
          0.8s: }

          0.8s: Expected:
          0.8s: {
          0.8s: "Microsoft-Windows-DotNETRuntime" = -1 +- -0
          0.8s: }

          0.8s: Actual:
          0.8s: {
          0.8s: "Microsoft-DotNETCore-EventPipe" = 1
          0.8s: }
          0.8s: ==TEST FINISHED: FAILED!==
        Expected: 100
        Actual: 255
        END EXECUTION - FAILED
        Test failed. Trying to see if dump file was created in /home/helixbot/dotnetbuild/dumps since 7/6/2023 11:55:21 PM
        Test Harness Exitcode is : 1
        To run the test:
        > set CORE_ROOT=/root/helix/work/correlation
        > /root/helix/work/workitem/e/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation/simpleruntimeeventvalidation.sh
```

* Fix test name

13 months ago[wasm] Disable runtime test dependent on creating a process (#88498)
Ankit Jain [Fri, 7 Jul 2023 00:50:30 +0000 (20:50 -0400)]
[wasm] Disable runtime test dependent on creating a process (#88498)

`tracing/eventpipe/simpleruntimeeventvalidation`:

```
          Generated app bundle at /root/helix/work/workitem/e/tracing/eventpipe/simpleruntimeeventvalidation/simpleruntimeeventvalidation/WasmApp/
        Incoming arguments: --run simpleruntimeeventvalidation.dll
        Application arguments: --run simpleruntimeeventvalidation.dll
        console.info: Initializing dotnet version 8.0.0-ci commit hash f47b553f129cfa7f006cb1a2f2088112c5ca0112
          0.0s: ==TEST STARTING==
          0.1s: System.PlatformNotSupportedException: System.Diagnostics.Process is not supported on this platform.
           at System.Diagnostics.Process.GetCurrentProcess()
           at Tracing.Tests.Common.IpcTraceTest.Validate(Boolean enableRundownProvider)
           at Tracing.Tests.Common.IpcTraceTest.RunAndValidateEventCounts(Dictionary`2 expectedEventCounts, Action eventGeneratingAction, List`1 providers, Int32 circularBufferMB, Func`2 optionalTraceValidator, Boolean enableRundownProvider)
          0.1s: ==TEST FINISHED: FAILED!==
        test-main.js exiting simpleruntimeeventvalidation.dll with result -1
        console.info: WASM EXIT -1
```

This was added in https://github.com/dotnet/runtime/pull/87785, but got
merged on red.

13 months agoAdd missing compiler-generated attributes to corelib (#87857)
Stephen Toub [Fri, 7 Jul 2023 00:47:13 +0000 (20:47 -0400)]
Add missing compiler-generated attributes to corelib (#87857)

* Add IsUnmanaged, ScopedRef, and Nullable{Context/PublicOnly} attributes

* Update attributes and add docs / tests

* Skip test expecting NullableContextAttribute to be partially trimmed

* Update Moq to latest

* Preserve metadata for InterfaceMethodWithoutTargetInvocation

* Preserve metadata for InheritanceInvocationWithoutTarget

---------

Co-authored-by: Eric StJohn <ericstj@microsoft.com>
13 months agoUpdate testing.md (#88364)
Dan Moseley [Fri, 7 Jul 2023 00:34:21 +0000 (19:34 -0500)]
Update testing.md (#88364)

13 months agoNativeAOT Watson changes for crashes/unhandled exceptions (#88273)
Mike McLaughlin [Thu, 6 Jul 2023 20:38:23 +0000 (13:38 -0700)]
NativeAOT Watson changes for crashes/unhandled exceptions (#88273)

* NativeAOT Watson changes for crashes/unhandled exceptions

Adds simple JSON formatting to a static fixed triage buffer that is passed through RaiseFailFastException via
the exception record and special codes to the Watson analyzer.

The current approach is to try to fit as much of the crash and exception info into the static fixed buffer with fallbacks
when it doesn't fit:
   1) The header containing basic info about the crash should always fit
   2) Writes 500 stack frames and as many inner exceptions  as can fit
   3) If that still fails, limit the number of stack frames to 10
   4) if that still fails, limit the number of stack frames to 10 and the size of the frame method name to 100 bytes

These fallback policies are preliminary and will be adjusted for what is needed more by Watson. We also could go with
a completely different approach of resizing the triage buffer with some kind of low level memory allocation. Needs to
work across all our platforms.

I have gone out of my way to avoid GC allocations when rendering the JSON but there still are some strings, delegates/display class and StackTrace class instance allocations.

Escaped the JSON special chars.

Add the RhGetCrashInfoBuffer C++ helper

Cleaned up the RhFailFastReason enum.

Added COR_E_FAILFAST (and Furious) HRESULT.

Used Jan's suggestion of interlock and sleeping all the threads except the first one

Cleaned up RuntimeFailFast. May have took some liberties by only formatting the FailFast message that was there when there isn't an exception message. For unhandled exceptions, having a message for crash info header isn't necessary only for regular FailFasts.

Add module base address to stack frame. Watson is going to need it even though it is usually always the app exe name.

13 months agofix TLS resume with HttpClientHandler on Linux (#88214)
Tomas Weinfurt [Thu, 6 Jul 2023 19:42:33 +0000 (12:42 -0700)]
fix TLS resume with HttpClientHandler on Linux (#88214)

* fix TLS resume with HttpHandler

* update

* cleanup

* update

* net48

* fix spacing

13 months agoTar: use UtcDateTime when setting last write time. (#88462)
Tom Deseyn [Thu, 6 Jul 2023 19:41:39 +0000 (21:41 +0200)]
Tar: use UtcDateTime when setting last write time. (#88462)

Using LocalDateTime converts the UTC time from the archive to a local
time, which is then converted back to UTC for the file system.

This removes the local time round-trip.

13 months ago[mono] Add cmake check for HAVE_CLOCK_GETTIME (#88428)
Sanjam Panda [Thu, 6 Jul 2023 17:21:28 +0000 (22:51 +0530)]
[mono] Add cmake check for HAVE_CLOCK_GETTIME (#88428)

Fixes an issue with missing method names when perf is used together with BenchmarkDotNet using Mono on Linux due to incorrect event order of the fork events and the mmap2 events.

13 months agoDisable System.Diagnostics.Tests.EventLogMessagesTests.CanReadAndWriteMessages on...
Jakob Botsch Nielsen [Thu, 6 Jul 2023 17:10:15 +0000 (19:10 +0200)]
Disable System.Diagnostics.Tests.EventLogMessagesTests.CanReadAndWriteMessages on Windows 11 (#88472)

Fixes blocking status for #88224

13 months agoEnable reading process environment variables in EventPipe (#87771)
Lakshan Fernando [Thu, 6 Jul 2023 15:11:59 +0000 (08:11 -0700)]
Enable reading process environment variables in EventPipe (#87771)

* Process Environment support

* using free to match malloc

* Add test to CI

* Fix FreeBSD build break

* Fix typo in OSX environ def

* FB

13 months agoInline TLS field access for linux/osx x64/arm64 (#87082)
Kunal Pathak [Thu, 6 Jul 2023 14:35:26 +0000 (07:35 -0700)]
Inline TLS field access for linux/osx x64/arm64 (#87082)

* wip

* add __tls_get_addr() code in jitinterface

* working model

* linux rely on __tls_get_addr() value

* Add fields for both max/threadSTaticBlocks, have separate for GC/non-gc

* code cleanup

* code cleanup

* add comments

* jit format

* update guid

* review feedback

* fix the offset

* arm64: wip

* linux arm64 model

* arm64: offsetOfThreadStaticBlock adjustment

* Add mrs and tpid0 register

* arm64: use the new mrs/tpidr0

* fix arm64 build and offset calculation:

* arm64: working

* arm64: move to struct model

* arm64: fixed the struct model

* x64: move to struct model

* code refactoring

* #define for field access

* change mrs -> mrs_tpid0

* fix a bug

* remove unwanted method

* another fix

* Add entries in CorInfoType.cs

* Update the #ifdef

* fix the windows scenario:

* review feedback

* fix the data-type

* add osx-arm64 support

* fix osx-arm64 issues

* fix build error

* fix build error after merge

* add osx/x64 support

* fix errors

* fix the macos/x64

* disable for alpine linux

* Disable for R2R

* review feedback

* fix r2r check

* move windows to struct model

* review feedback

* fix the register clobbering in release bits

* Move the linux/x64 logic to .S file

* Use TargetOS::IsMacOS

* disable optimization for single file

* working for linux/x64

* fix some errors for osx/x64

* fix for osx x64/arm64

* fix for arm64 linux/osx

* try disable for musl/arm64

* rename variable

* Rename variable to tlsIndexObject

* Make offset variables as uint32_t

* change the type of indexObj/ftnAddr to void*

* replace ifdef(msc_ver) with ifdef(windows)

* Revert to JIT_TO_EE_TRANSITION_LEAF

* Move code to asmHelpers.S and rename method

* rename the methods per the platform

* fix osx builds

* fix build break

* fix some errors around osx

* rename some more methods

* review feedback

* review feedback

* delete the comment

* make methods static

* remove macos/x64 check

* fix the check for linux/x64

* detect early for single-file linux/x64

* move the assert

* review feedback

* misc fixup

* use fgMorphArgs()

* remove commented code

13 months ago[RISC-V] Increase instruction group size (#88468)
Alexander Soldatov [Thu, 6 Jul 2023 14:21:49 +0000 (17:21 +0300)]
[RISC-V] Increase instruction group size (#88468)

Similar to ARM default IG size is not enough for prolog generation.

13 months agoOptimize Ascii.Equals when widening (#87141)
Brennan [Thu, 6 Jul 2023 13:53:22 +0000 (06:53 -0700)]
Optimize Ascii.Equals when widening (#87141)

* Optimize Ascii.Equals when widening

* add BoundedMemory tests to ensure that boundaries are respected

---------

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
13 months agoSetup support for managed runtime events (#87785)
Lakshan Fernando [Thu, 6 Jul 2023 12:29:19 +0000 (05:29 -0700)]
Setup support for managed runtime events (#87785)

* preliminery managed runtime event support

* Linux fixes 1

* full portable threadpool support

* checkpoint before python script

* Additional GC event support

* NativeAOT to use sink threadpool file

* CI check

* Enable GC runtime tests

* Post main merge fixups

* change tests that run in CI

* Support native sinks for threading events

* Enable managed exceptions via eventpipe

* Move Exception event to EventPipe

* Add an empty exception event to disabled EventPipe

* make events do no-op in disabled eventpipe

* Update src/coreclr/nativeaot/Runtime/clretwallmain.h

Co-authored-by: Elinor Fung <elfung@microsoft.com>
* FB first stage

* Test change

* FB

* latest FB

* Pulled PR 88365

* FB

---------

Co-authored-by: Elinor Fung <elfung@microsoft.com>
13 months ago[Android] Add NdkToolFinder task & Fix up AOT app build (#88210)
Steve Pfister [Thu, 6 Jul 2023 11:22:37 +0000 (04:22 -0700)]
[Android] Add NdkToolFinder task & Fix up AOT app build (#88210)

Since we bumped to NDK 23, having the aot compiler itself generate shared libraries stopped working. This is due to NDK 23 moving most of the toolchain into a common bin directory. AS was left over in each of these directories as an alias to bin/<triple>-as.

This change adds a task to collect all of the important NDK toolchain paths. It also fixes up the aot build when AOTWithLibraryFiles is set to true and we want the aot compiler to produce shared libraries.

13 months ago[RISC-V] Fix floating point (#88311)
Dong-Heon Jung [Thu, 6 Jul 2023 04:13:54 +0000 (13:13 +0900)]
[RISC-V] Fix floating point (#88311)

* [RISC-V] Fix: passing struct in regs

* Fix a typo in CallDescrWorkerInternal

* [RISC-V] Update floating points

13 months agoDelete formatter test blob for `EqualityComparer<byte>.Default` (#88454)
Stephen Toub [Thu, 6 Jul 2023 02:30:01 +0000 (22:30 -0400)]
Delete formatter test blob for `EqualityComparer<byte>.Default` (#88454)

A change was recently made that deleted the specialized type returned, so delete the dedicated formatting test as well.

13 months agoFix diagnostic message in ComInterfaceGenerator (#88450)
Jackson Schuster [Thu, 6 Jul 2023 02:07:14 +0000 (19:07 -0700)]
Fix diagnostic message in ComInterfaceGenerator (#88450)

Fixes #88448

13 months agoFix unsafe walking of DacEnumerableHash (#88063)
David Wrighton [Thu, 6 Jul 2023 01:04:55 +0000 (18:04 -0700)]
Fix unsafe walking of DacEnumerableHash (#88063)

Under the following set of conditions, it is possible for a lookup in the `DacEnumerableHash` to fail to find already present entries.

Given Thread A which is growing the table, and thread B which is attempting to perform a lookup.

1. Thread B reads an `VolatileEntry*` from a bucket in the hashtable. Let this be EntryB. EntryB will have a next pointer which points to EntryThatWeNeedToFind, but it will not yet read that pointer value from EntryB.
2. Thread A reads the pointer to EntryB from the same bucket in the hashtable.
3. Thread A adds EntryB to the new hashtable
4. Thread A sets the bucket in the old hashtable to point to EntryThatWeNeedToFind
5. Thread A sets the next pointer in EntryB to point to NULL.
6. Thread B reads the next pointer, sees that the next pointer is NULL, and falls back to looking in the "new" hashtable for any possible updates
7. Thread B looks in the appropriate bucket in the "new" hashtable. That bucket does not yet contain EntryThatWeNeedToFind, as it hasn't yet been moved from the old hashtable.
8. Thread B returns NULL __*INCORRECTLY*__, indicating that there are no entries with the matching in them.

This change adjust how these linked lists work, but giving each one a version number which can be checked as the linked list finishes reading. The fix allows finding entries from an earlier set of buckets (as those can be in the new list temporarily, and will not interfere with finding the correct result), but will actively detect walking entries in the new list when attempting to walk the old entries.

In addition, there is a drive by fix for an issue where if there are more than ~14,000,000 entries in the table, it allocates a full new list each time the list is added to.

Fixes #85688

13 months agoDisable use of certains R2R data structures in the DAC (#88446)
David Wrighton [Thu, 6 Jul 2023 01:03:03 +0000 (18:03 -0700)]
Disable use of certains R2R data structures in the DAC (#88446)

- The ReadyToRun_EnclosingTypeMap, ReadyToRun_TypeGenericInfoMap, and ReadyToRun_MethodIsGenericMap provide optimization data which is already present in metadata
- They are not properly DACized
- Propertly DACizing these methods would not improve debugging, so instead they are disabled in the DAC

13 months agoFix which path is taken in Enumerable.Select for empty partition (#88425)
Stephen Toub [Thu, 6 Jul 2023 01:01:51 +0000 (21:01 -0400)]
Fix which path is taken in Enumerable.Select for empty partition (#88425)

* Fix which path is taken in Enumerable.Select for empty partition

My recent changes to improve perf of some LINQ iterators by implementing `IList<T>` caused Select on an empty partition to start preferring a path that wasn't optimized for empty.  This fixes it.  I searched and don't see any other operators that would be similarly negatively affected.

* Use is check

13 months agoType equivalence support in Crossgen2 (#87899)
David Wrighton [Thu, 6 Jul 2023 00:55:38 +0000 (17:55 -0700)]
Type equivalence support in Crossgen2 (#87899)

We currently have a small behavior hole on Windows where if a binary uses TypeEquivalence, it is technically possible to get crossgen2 to generate invalid code.

This fixes that by adding support for type equivalence to the managed type system, and adjusting crossgen2 to use it. This is complicated by the detail that this may generate some type references which cannot be referenced from an R2R file, so additional error checking was needed (this additional error checking is what fixes #67855).

However, while basic support for type equivalence has been added to the type system, support for actually performing type equivalent interface resolution has not been, so devirtualization of type equivalent interface calls is disabled. At this time, I do not expect to see a customer need for implementing that fairly complicated feature

Fixes #67855

13 months agoAdd consultants for some extensions areas (#88430)
Eric StJohn [Thu, 6 Jul 2023 00:31:01 +0000 (17:31 -0700)]
Add consultants for some extensions areas (#88430)

* Add consultants for some extensions areas

* Update area-owners.md

---------

Co-authored-by: Dan Moseley <danmose@microsoft.com>
13 months agoAdd docs for AsyncInterfaces (#88432)
Eric StJohn [Wed, 5 Jul 2023 23:55:38 +0000 (16:55 -0700)]
Add docs for AsyncInterfaces (#88432)

13 months agoDedup Task.WhenAll non-generic and generic implementations (#88154)
Stephen Toub [Wed, 5 Jul 2023 23:41:24 +0000 (19:41 -0400)]
Dedup Task.WhenAll non-generic and generic implementations (#88154)

The generic implementation was calling the non-generic one and then using an additional continuation to extract the resulting `Task<TResult>` due to lack of covariance on classes.  We can instead just factor the shared implementation out into a generic with the type parameter constrained to be a Task.  This results in simpler code as well as avoiding an extra continuation in the generic case.

As part of cleaning this up:
- I changed code where we need to make a defensive copy of an input collection to use CopyTo; we were already doing this in some places but not others.  This saves on an enumerator allocation when enumerating the source collection, as well as multiple interface calls.
- I augmented WhenAny to also special-case `List<Task>`, as that's a common input and we can handle it a bit more efficiently, especially if the collection ends up containing just two tasks.
- I removed the `GenericDelegateCache<TAntecedentResult, TResult>`.  That was from a time before the C# compiler supported caching of generic lambdas. It would have needed to have been updated to handle the stronger type coming out of CommonCWAnyLogic, so I instead just got rid of it.  We're better off lazily-creating these rarely used delegates, anyway.

13 months agoMake DoesConsoleSupportAnsi respect DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTIO...
June Rhodes [Wed, 5 Jul 2023 23:22:05 +0000 (09:22 +1000)]
Make DoesConsoleSupportAnsi respect DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION (#88241)

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
13 months agoAdd gtNewGenericCon (#88440)
Egor Bogatov [Wed, 5 Jul 2023 23:19:11 +0000 (01:19 +0200)]
Add gtNewGenericCon (#88440)

13 months agoJIT: Always look for SIMD fields during promotion (#84122)
Jakob Botsch Nielsen [Wed, 5 Jul 2023 22:16:25 +0000 (00:16 +0200)]
JIT: Always look for SIMD fields during promotion (#84122)

13 months ago[mono] Fix sorting custom attributes in ILStrip (#88435)
Alexander Köplinger [Wed, 5 Jul 2023 21:27:26 +0000 (23:27 +0200)]
[mono] Fix sorting custom attributes in ILStrip (#88435)

The change in https://github.com/dotnet/runtime/pull/87923 was subtly wrong, the problem is that RID on a Cecil metadata token masks out the token type.
We actually have to reconstruct the custom attribute coded-index.

13 months agoAdd option to decrypt Quic traffic in debug builds (#83001)
Tomas Weinfurt [Wed, 5 Jul 2023 21:17:11 +0000 (14:17 -0700)]
Add option to decrypt Quic traffic in debug builds (#83001)

* Add option to decrypt Quic traffic in debug builds

* feedback from review

* fixes & feedback

* feedback from review

13 months agoUnify Default Comparer logic (#88006)
Michał Petryka [Wed, 5 Jul 2023 19:07:19 +0000 (21:07 +0200)]
Unify Default Comparer logic (#88006)

Unifies (Equality)Comparer.Default logic so that it matches between CoreCLR, NativeAOT, Mono in runtime and intrinsic implementations.

Fixes devirt behaviour around Nullable types.

Also enables devirt for non final types in CoreCLR and NativeAOT.

Required for #87579.
Fixes #87391.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
13 months agoFix AVX512 moves on X86 (#88421)
Michał Petryka [Wed, 5 Jul 2023 19:01:33 +0000 (21:01 +0200)]
Fix AVX512 moves on X86 (#88421)

Extracted from #85875.

13 months agoFix Codespaces prebuild after CMake upgrade and set policy in Mono (#88410)
Alexander Köplinger [Wed, 5 Jul 2023 19:00:40 +0000 (21:00 +0200)]
Fix Codespaces prebuild after CMake upgrade and set policy in Mono (#88410)

The prebuild on Codespaces broke after the minimum CMake version was bumped in https://github.com/dotnet/runtime/pull/86530 because the container was still using Ubuntu 20.04 (Focal) which only has CMake 3.16.1.

Upgrade to Ubuntu 22.04 (Jammy) so we have a new enough CMake.

Also fix a missing policy in the Mono CMakeLists.txt that was accidentally removed.

13 months agoJIT: Compute BB weights with higher precision, use tolerance in if-conversion (#88385)
Jakob Botsch Nielsen [Wed, 5 Jul 2023 18:37:09 +0000 (20:37 +0200)]
JIT: Compute BB weights with higher precision, use tolerance in if-conversion (#88385)

In https://github.com/dotnet/runtime/issues/88376#issuecomment-1620371447
I noticed a spurious diff in the System.Tests.Perf_Int32.ToStringHex
benchmark that looked like this:

```diff
 G_M62987_IG13:
        and      edi, esi
        mov      ebx, dword ptr [rbp+88H]
-       mov      ecx, 1
        test     ebx, ebx
-       cmovle   ebx, ecx
+       jg       SHORT G_M62987_IG15
+ ;; size=12 bbWeight=1.00 PerfScore 2.50
+G_M62987_IG14:
+       mov      ebx, 1
+ ;; size=5 bbWeight=0.98 PerfScore 0.24
+G_M62987_IG15:
```

Investigating, it turns out to be caused by a check in if-conversion for
detecting loops, that is using a very sharp boundary. It turns out that
the integral block weights are exactly the same (in both the base and
diff), but the floating point calculation ended up with exactly 1 and
very close to 1 in the base/diff cases respectively.

So two changes to address it:
* Switch getBBWeight to multiply by BB_UNITY_WEIGHT after dividing
* Switch if-conversion to have a 5% tolerance so that losing just a
  single count in the wrong place will not cause a decision change. Note
  that the check here is used as a cheap "is inside loop" check.

13 months ago[main] Update dependencies from dnceng/internal/dotnet-optimization (#88132)
dotnet-maestro[bot] [Wed, 5 Jul 2023 18:24:16 +0000 (13:24 -0500)]
[main] Update dependencies from dnceng/internal/dotnet-optimization (#88132)

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230627.5

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23327.5

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230628.5

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23328.5

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230629.5

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23329.5

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230630.5

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23330.5

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230701.5

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23351.5

* Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230704.4

optimization.linux-arm64.MIBC.Runtime , optimization.linux-x64.MIBC.Runtime , optimization.windows_nt-arm64.MIBC.Runtime , optimization.windows_nt-x64.MIBC.Runtime , optimization.windows_nt-x86.MIBC.Runtime , optimization.PGO.CoreCLR
 From Version 1.0.0-prerelease.23326.3 -> To Version 1.0.0-prerelease.23354.4

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
13 months ago[mono] Fix InlineArrayAttribute access on big-endian platforms (#88417)
Ulrich Weigand [Wed, 5 Jul 2023 18:18:25 +0000 (20:18 +0200)]
[mono] Fix InlineArrayAttribute access on big-endian platforms (#88417)

Use "guint32" instead of "gpointer" to access the length field in
InlineArrayAttribute; fixes serious regression after PR #88419.

13 months agoFix SIMD node DOT retType (#88363)
Kunal Pathak [Wed, 5 Jul 2023 17:05:14 +0000 (10:05 -0700)]
Fix SIMD node DOT retType (#88363)

* Fix SIMD node DOT retType

* no need for lengthsquared

13 months agoSuppress System.Drawing.Common dependency from System.Windows.Extensions (#88157)
Eric StJohn [Wed, 5 Jul 2023 16:54:49 +0000 (09:54 -0700)]
Suppress System.Drawing.Common dependency from System.Windows.Extensions (#88157)

* Suppress System.Drawing.Common dependency from System.Windows.Extensions

* Add Drawing reference to Windows.Extensions tests

13 months agoInline more helpers in RegexParser (#88392)
Dan Moseley [Wed, 5 Jul 2023 16:11:54 +0000 (09:11 -0700)]
Inline more helpers in RegexParser (#88392)

* inline RightCharMoveRight()

* inline Textpos()

* inline MoveLeft()

* inline MoveRight()

* Inline CharAt()

* Inline RightChar()

* Inline RightChar()

* Inline CharsRight()

* Inline Textto()

* rename _pattern and _currentPos

* cleanup Category table

* Cleanup ScanBlank()

* reorder <

* reorder - =

* reorder >=

* reorder - >

* more

* bool param name

* comments

* merge

13 months ago[iOS] Add temp cindex attribute to build on xcode 15 (#88261)
Steve Pfister [Wed, 5 Jul 2023 16:10:17 +0000 (09:10 -0700)]
[iOS] Add temp cindex attribute to build on xcode 15 (#88261)

Without CursorKind 437, the cross build for iOS/tvOS and iOS/tvOSSimulator will fail. This change adds a temporary attribute to avoid that.

13 months agoJIT: Propagate multi-reg-index for upper-vector-restore ref positions (#88380)
Jakob Botsch Nielsen [Wed, 5 Jul 2023 15:16:33 +0000 (17:16 +0200)]
JIT: Propagate multi-reg-index for upper-vector-restore ref positions (#88380)

`LinearScan::resolveRegisters` will write the register back to the IR
node for an upper-vector-restore RP, so without this propagation we
would overwrite the register assignment for an unrelated field.

For example, for IR like
```scala
N001 (  9,  6) [000090] m------N---                   t90 =    LCL_VAR   struct<JIT.HardwareIntrinsics.Arm._AdvSimd.SimpleTernaryOpTest__AbsoluteDifferenceWideningUpperAndAdd_Vector128_UInt32+TestStruct, 48>(P) V00 loc0
                                                            ▌    simd16 field V00._fld1 (fldOffset=0x0) -> V14 tmp10         (last use)
                                                            ▌    simd16 field V00._fld2 (fldOffset=0x10) -> V15 tmp11         (last use)
                                                            ▌    simd16 field V00._fld3 (fldOffset=0x20) -> V16 tmp12         (last use) $540
                                                            ┌──▌  t90    struct
N002 ( 10,  7) [000091] -----------                         ▌  RETURN    struct $VN.Void
```
we could build ref positions such as

```
[000091] 449.#639 U14  UVRs   UVRes    NA   │    │    │    │    │    │    │    │    │    │    │    │    │V16a│    │    │    │
         449.#640 d0   Fixd   Keep     d0   │    │    │    │    │    │    │    │    │    │    │    │    │V16a│    │    │    │
         449.#641 V14  Use *  ReLod    d0   │    │    │    │    │    │    │    │    │    │    │V14a│    │V16a│    │    │    │
                              Keep     d0   │    │    │    │    │    │    │    │    │    │    │V14i│    │V16a│    │    │    │
         449.#642 U15  UVRs   UVRes    NA   │    │    │    │    │    │    │    │    │    │    │    │    │V16a│    │    │    │
         449.#643 d1   Fixd   Keep     d1   │    │    │    │    │    │    │    │    │    │    │    │    │V16a│    │    │    │
         449.#644 V15  Use *  ReLod    d1   │    │    │    │    │    │    │    │    │    │    │    │V15a│V16a│    │    │    │
                              Keep     d1   │    │    │    │    │    │    │    │    │    │    │    │V15i│V16a│    │    │    │
         449.#645 d2   Fixd   Keep     d2   │    │    │    │    │    │    │    │    │    │    │    │    │V16a│    │    │    │
         449.#646 V16  Use *  Keep     d2   │    │    │    │    │    │    │    │    │    │    │    │    │V16i│    │    │    │
```

When writing back register assignments the upper-vector-restore at #642
ended up overwriting the assignment for the first field on [000090],
resulting in

```scala
N447 (  9,  6) [000090] m------N--z                   t90 =    LCL_VAR   struct<JIT.HardwareIntrinsics.Arm._AdvSimd.SimpleTernaryOpTest__AbsoluteDifferenceWideningUpperAndAdd_Vector128_UInt32+TestStruct, 48>(P) V00 loc0          NA
                                                            ▌    simd16 field V00._fld1 (fldOffset=0x0) -> V14 tmp10         (last use)
                                                            ▌    simd16 field V00._fld2 (fldOffset=0x10) -> V15 tmp11         (last use)
                                                            ▌    simd16 field V00._fld3 (fldOffset=0x20) -> V16 tmp12         d2 (last use) REG NA,d1,d2 $540
                                                            ┌──▌  t90    struct
N449 ( 10,  7) [000091] -----------                         ▌  RETURN    struct REG NA $VN.Void
```
(note the REG NA instead of REG d0).

13 months agoTar: set directory modification times while extracting. (#88231)
Tom Deseyn [Wed, 5 Jul 2023 14:44:44 +0000 (16:44 +0200)]
Tar: set directory modification times while extracting. (#88231)

* Tar: set directory modification times while extracting.

* Extend test and change entry write order.

* Get rid of some enumeration allocations.

* test: check DateTime using InRange.

* Extend comment explaining the order of entries.

* Apply suggestions from code review

Co-authored-by: Dan Moseley <danmose@microsoft.com>
* Try including AltDirectorySeparatorChar.

* Revert "Try including AltDirectorySeparatorChar."

This reverts commit 086aac43a897826394156692bd82f79feb3eca9d.

* Try using Directory.SetLastWriteTime instead of File's.

* Tie up some ends.

---------

Co-authored-by: Dan Moseley <danmose@microsoft.com>
13 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 221445...
dotnet bot [Wed, 5 Jul 2023 13:16:16 +0000 (15:16 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2214454 (#88399)

13 months agoImplement JsonTypeInfoResolver.WithAddedModifier (#88255)
Eirik Tsarpalis [Wed, 5 Jul 2023 12:55:21 +0000 (13:55 +0100)]
Implement JsonTypeInfoResolver.WithAddedModifier (#88255)

13 months ago[mono][interp] Add vectorization for Vector4 (#87822)
Vlad Brezae [Wed, 5 Jul 2023 12:36:20 +0000 (15:36 +0300)]
[mono][interp] Add vectorization for Vector4 (#87822)

* [mono][interp] Reuse vectorization for Vector4

Which is pretty much Vector<float>

* [mono][interp] Implement Vector.One for float gparam

* [mono][interp] Extract code to be reused later

* [mono][interp] Intrinsify Vector<T> ctor and Vector4 ctor

The constructors receive each element as an argument. This is the same as `Vector128.Create` so we reuse that code. This ends up generating a MINT_SIMD_V128_I*_CREATE opcode which receives each element value as an argument.

* [mono][interp] Track r4 var value during interpreter optimizations

Since it is common to instantiate Vector4 with constant values, add also support for tracking R4 values during optimizations. If all elements are constant, we generate instead a single MINT_SIMD_V128_LDC, which has the entire vector value embedded in the instruction stream.

* [mono][interp] Fix Vector ctor instrinsic when called explicitly

* [mono][interp] Replace ldloca + stobj.vt pair with mov.vt

* [mono][interp] Return early if vector_klass is not simd type

It is not marked as simd type if the generic param is not valid (ex not primitive type). Future checks are not expecting this scenario and can potentially crash.

13 months agoImprove non-SIMD block copy/init codegen (#88393)
Egor Bogatov [Wed, 5 Jul 2023 12:26:24 +0000 (14:26 +0200)]
Improve non-SIMD block copy/init codegen (#88393)

13 months agoAdd clr.tools subset to runtime-community (#88160)
Jo Shields [Wed, 5 Jul 2023 10:47:48 +0000 (06:47 -0400)]
Add clr.tools subset to runtime-community (#88160)

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
13 months agoPermit trailing data after PKCS12 (#88340)
Kevin Jones [Wed, 5 Jul 2023 09:52:59 +0000 (05:52 -0400)]
Permit trailing data after PKCS12 (#88340)

13 months agoFaster optimized frozen dictionary creation (6/6) (#88093)
Adam Sitnik [Wed, 5 Jul 2023 07:45:54 +0000 (09:45 +0200)]
Faster optimized frozen dictionary creation (6/6)  (#88093)

* don't use custom ToArray for small frozen collections, up to 50% gain for creation time for collections with <= 4 items

* for these types GetHashCode returns their value casted to int, so when we receive a Dictionary/HashSet where there are key we know that all hash codes are unique and we can avoid some work later

10-15% CPU time gain and 15-20% allocation reduction for FrozenDictionary and FrozenHashSet where TKey is uint, short, ushort, byte, sbyte

* move Length Buckets code to a dedicated helper type to reduce code duplication and decrease code size

* add tests for Frozen Dictionaries with key being uint, short, ushort, byte, sbyte, nint and nuint

* fix discovered bug: IntPtr started implementing IComparable<IntPtr> in .NET 5

13 months agoBump to libc++ without libatomic linkage (#88402)
Jo Shields [Wed, 5 Jul 2023 03:41:44 +0000 (23:41 -0400)]
Bump to libc++ without libatomic linkage (#88402)

Closes: https://github.com/dotnet/runtime/issues/88361

13 months agoMove IMeterFactory to System.Diagnostics.DiagnosticSource (#88302)
Tarek Mahmoud Sayed [Wed, 5 Jul 2023 00:45:20 +0000 (17:45 -0700)]
Move IMeterFactory to System.Diagnostics.DiagnosticSource (#88302)

13 months ago[mono][llvm] Fix another crash when using opaque pointers. (#88397)
Zoltan Varga [Wed, 5 Jul 2023 00:26:05 +0000 (20:26 -0400)]
[mono][llvm] Fix another crash when using opaque pointers. (#88397)

13 months ago[mono] Respect KeepNativeSymbols when building cross compilers. (#88398)
Zoltan Varga [Wed, 5 Jul 2023 00:25:43 +0000 (20:25 -0400)]
[mono] Respect KeepNativeSymbols when building cross compilers. (#88398)

13 months agochange regex options tests to extension method (#88366)
Dan Moseley [Wed, 5 Jul 2023 00:11:43 +0000 (17:11 -0700)]
change regex options tests to extension method (#88366)

* extension method for regexoptions

* Revert "extension method for regexoptions"

This reverts commit 95b05489f0245d23d6d265a2cad2fca2ae0975a0.

* Inline UseOption

13 months ago[mono][interp] Extract simd create opcodes in separate methods (#88381)
Vlad Brezae [Tue, 4 Jul 2023 17:42:46 +0000 (20:42 +0300)]
[mono][interp] Extract simd create opcodes in separate methods (#88381)

Newer versions of clang allocate the local buffer repeatedly by bumping the stack. This behavior seems dubious, leading to stack overflows, but extracting the code outside the interp main loop is an improvement anyway for the interpreter.

13 months ago[LoongArch64] Fix the NotImplementedException within R2RDump. (#88379)
Qiao Pengcheng [Tue, 4 Jul 2023 17:02:35 +0000 (01:02 +0800)]
[LoongArch64] Fix the NotImplementedException within R2RDump. (#88379)

13 months agoJIT: Handle primitive-sized remainders overlapping padding/promotions in physical...
Jakob Botsch Nielsen [Tue, 4 Jul 2023 16:02:38 +0000 (18:02 +0200)]
JIT: Handle primitive-sized remainders overlapping padding/promotions in physical promotion (#88109)

The remainder may be separated by a bit of padding or other promoted fields but
still fit into a primitive; in this case it is still beneficial to copy it all
as a primitive, instead of falling back to a full block copy.

Example:
```csharp
private S _s;

void Foo()
{
    S s = new();
    s.A = 10;
    s.D = 20;
    s.F = 30; // A, D, F gets promoted
    _s = s;
}

private struct S
{
    public byte A;
    public byte B;
    public byte C;
    public byte D;
    public byte E;
    public byte F;
}
```

```diff
 Processing block operation [000018] that involves replacements
   dst+003 <- V04 (V01.[003..004)) (last use)
   dst+005 <- V05 (V01.[005..006)) (last use)
   Block op remainder: [001..003) [004..005)
-  => Remainder strategy: retain a full block op
+  => Remainder strategy: int at +001
```

```diff
 ;  V00 this         [V00,T01] (  3,  3   )     ref  ->  rcx         this class-hnd single-def
 ;* V01 loc0         [V01    ] (  0,  0   )  struct ( 8) zero-ref    do-not-enreg[SF] ld-addr-op
 ;# V02 OutArgs      [V02    ] (  1,  1   )  struct ( 0) [rsp+00H]   do-not-enreg[XS] addr-exposed "OutgoingArgSpace"
 ;* V03 tmp1         [V03    ] (  0,  0   )   ubyte  ->  zero-ref    "V01.[000..001)"
 ;* V04 tmp2         [V04    ] (  0,  0   )   ubyte  ->  zero-ref    "V01.[003..004)"
 ;* V05 tmp3         [V05    ] (  0,  0   )   ubyte  ->  zero-ref    "V01.[005..006)"
 ;  V06 tmp4         [V06,T00] (  5, 10   )   byref  ->  rcx         single-def "Spilling address for field-by-field copy"
 ;
 ; Lcl frame size = 0

 G_M52879_IG01:  ;; offset=0000H
  ;; size=0 bbWeight=1 PerfScore 0.00
 G_M52879_IG02:  ;; offset=0000H
        add      rcx, 8
        xor      eax, eax
-       mov      dword ptr [rcx], eax
-       mov      dword ptr [rcx+02H], eax
+       mov      dword ptr [rcx+01H], eax
        mov      byte  ptr [rcx], 10
        mov      byte  ptr [rcx+03H], 20
        mov      byte  ptr [rcx+05H], 30
- ;; size=22 bbWeight=1 PerfScore 5.50
-G_M52879_IG03:  ;; offset=0016H
+ ;; size=20 bbWeight=1 PerfScore 4.50
+G_M52879_IG03:  ;; offset=0014H
        ret
  ;; size=1 bbWeight=1 PerfScore 1.00

-; Total bytes of code 23, prolog size 0, PerfScore 8.80, instruction count 8, allocated bytes for code 23 (MethodHash=1da13170) for method Program:Foo():this (FullOpts)
+; Total bytes of code 21, prolog size 0, PerfScore 7.60, instruction count 7, allocated bytes for code 21 (MethodHash=1da13170) for method Program:Foo():this (FullOpts)
 ; ============================================================

```

We have to be careful, however, since the covering segment can now contain
promoted fields. If this happens we need to make sure we write the promoted
field _after_ the remainder.

13 months agoJIT: Quirk a quirk in fgExpandVirtualVtableCallTarget (#88374)
Jakob Botsch Nielsen [Tue, 4 Jul 2023 13:18:39 +0000 (15:18 +0200)]
JIT: Quirk a quirk in fgExpandVirtualVtableCallTarget (#88374)

Fix #88349

13 months ago[mono] Reenable disabled tests as mono now respects non-public custom attributes...
Ivan Povazan [Tue, 4 Jul 2023 13:02:54 +0000 (15:02 +0200)]
[mono] Reenable disabled tests as mono now respects non-public custom attributes in dynamic assemblies (#88322)

* Reenable disabled tests
* Disable Roslyn analyzer tests in the browser as Monitor.Wait / Monitor.Pulse are not supported on single-threaded WASM

Contributes to: https://github.com/dotnet/runtime/issues/60650

13 months agoEmail addresses in same domain not equal (#87721)
feiyun0112 [Tue, 4 Jul 2023 10:26:27 +0000 (18:26 +0800)]
Email addresses in same domain not equal (#87721)

Different email addresses in same domain should not be equal.
UriComponents.UserInfo will compare also UserInfo from the Uris.

13 months agoonly log errors of Task/Promise marshaling (#88326)
Pavel Savara [Tue, 4 Jul 2023 09:23:46 +0000 (11:23 +0200)]
only log errors of Task/Promise marshaling (#88326)

13 months agoUnified source file formatting (#88330)
Marie Píchová [Tue, 4 Jul 2023 09:17:51 +0000 (11:17 +0200)]
Unified source file formatting (#88330)

13 months ago[OSX] HybridGlobalization Workaround for insufficiently sized destination buffer...
Meri Khamoyan [Tue, 4 Jul 2023 06:20:43 +0000 (10:20 +0400)]
[OSX] HybridGlobalization Workaround for  insufficiently sized destination buffer (#88184)

Workaround for insufficiently sized dest buffer

13 months agoRemove conservative generic scanning logic (#88360)
Michal Strehovský [Tue, 4 Jul 2023 06:20:06 +0000 (15:20 +0900)]
Remove conservative generic scanning logic (#88360)

@EgorBo's #88025 made it possible to undo conservative scanning logic added in dotnet/corert#7618.

Saves 0.4% in size for Stage1 and Stage2 apps.

13 months agoAllow inlining array methods (#88367)
Michal Strehovský [Tue, 4 Jul 2023 05:48:39 +0000 (14:48 +0900)]
Allow inlining array methods (#88367)

`CanInline` would return false to methods that implement generic interfaces on arrays because we didn't consider the magic `Array<T>` types constructed.

For:

```csharp
static int Main()
{
    IReadOnlyCollection<int> l = new int[] { 1, 2, 3 };
    return l.Count;
}
```

Before:

```
       sub      rsp, 40
                                                ;; size=4 bbWeight=1 PerfScore 0.25
G_M24375_IG02:  ;; offset=0004H
       lea      rcx, [(reloc 0x4000000000420a70)]      ; int[]
       mov      edx, 3
       call     CORINFO_HELP_NEWARR_1_VC
       lea      rcx, [(reloc 0x4000000000420aa8)]      ; const ptr
       mov      rdx, qword ptr [rcx]
       mov      qword ptr [rax+10H], rdx
       mov      rdx, qword ptr [rcx+04H]
       mov      qword ptr [rax+14H], rdx
       mov      rcx, rax
       call     System.Array`1[int]:get_Count():int:this
       nop
                                                ;; size=48 bbWeight=1 PerfScore 9.75
G_M24375_IG03:  ;; offset=0034H
       add      rsp, 40
       ret
```

After:

```
       sub      rsp, 40
                                                ;; size=4 bbWeight=1 PerfScore 0.25
G_M24375_IG02:  ;; offset=0004H
       lea      rcx, [(reloc 0x4000000000420a70)]      ; int[]
       mov      edx, 3
       call     CORINFO_HELP_NEWARR_1_VC
       lea      rcx, [(reloc 0x4000000000420aa8)]      ; const ptr
       mov      rdx, qword ptr [rcx]
       mov      qword ptr [rax+10H], rdx
       mov      rdx, qword ptr [rcx+04H]
       mov      qword ptr [rax+14H], rdx
       mov      eax, 3
                                                ;; size=44 bbWeight=1 PerfScore 8.50
G_M24375_IG03:  ;; offset=0030H
       add      rsp, 40
       ret
```

13 months agoRemove empty files (#88362)
Dan Moseley [Tue, 4 Jul 2023 05:22:09 +0000 (22:22 -0700)]
Remove empty files (#88362)

13 months agoFix libraries Windows test runner script (#88354)
Bruce Forstall [Tue, 4 Jul 2023 04:18:09 +0000 (21:18 -0700)]
Fix libraries Windows test runner script (#88354)

Having HAS_TEST_RESULTS unset leads to a Windows CMD script
syntax error.

Clean up a few other things while there:
1. Explicitly set ENABLEEXTENSIONS
2. Set a variable to the test exit code. There's an unsafe assumption
currently that `%ERRORLEVEL%` doesn't change between the test run
and all of the subsequent uses.
3. Remove unnecessary quotes around setting `HAS_TEST_RESULTS=1`

Fixes #88353

13 months agoUp Minimum CMake Version to 3.20 (#86530)
Ivan Diaz Sanchez [Tue, 4 Jul 2023 02:03:12 +0000 (19:03 -0700)]
Up Minimum CMake Version to 3.20 (#86530)

* Let's see what happens :)

* CMake 3.20 works on my machine???

* Upped the llibraries CMake version to 3.20

* Upped native libs CMake version to 3.20, and updated the requirements docs.

* Add CMake Policy to 3.17.0 for native libs because of wasm.

* Downgraded native libs CMake to 3.17.0 temporarily, while we figure out the funny troublemaker wasm.

* Added a couple notes regarding CMake on Linux and Windows, and upped the corehost and libunwind CMake versions to 3.20

* Reverted external native components CMake versions, and upped tests to 3.20. Only Mono remains now.

* Added mono to the 3.20 gang. Also, changed the condition for wasm.

* Had to condition mono's CMake version as well because of wasm.

* DEBUG-ONLY COMMIT: Added some CMake logging to help me figure out what is set for wasm to think of the appropriate conditional.

* DEBUG-ONLY COMMIT: I think I have the answer for wasm now/

* Restored the DEBUG-ONLY changes and set 3.20 as the universal CMake, as the missing machines have now been updated.

* Updated requirements doc with notes for Debian 11 and lower.

13 months agoImprove LoggerFactory and Logger debugging (#88313)
James Newton-King [Tue, 4 Jul 2023 01:42:39 +0000 (09:42 +0800)]
Improve LoggerFactory and Logger debugging (#88313)

13 months agoTry adding cross-compilers for Musl (#87841)
Jo Shields [Mon, 3 Jul 2023 21:53:34 +0000 (17:53 -0400)]
Try adding cross-compilers for Musl (#87841)

* Add cross-compilers for Musl

* Fix LLVM linkage on Musl

13 months agoPass exact context to getMethodInfo (#88025)
Egor Bogatov [Mon, 3 Jul 2023 21:36:59 +0000 (23:36 +0200)]
Pass exact context to getMethodInfo (#88025)

* Modify JIT-EE API

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
13 months agoShrink column width in `ilc --help` (#88356)
Adeel Mujahid [Mon, 3 Jul 2023 21:19:50 +0000 (00:19 +0300)]
Shrink column width in `ilc --help` (#88356)

13 months agoFix condition for ENSURE_PRIMARY_STACK_SIZE (#88342)
Jan Kotas [Mon, 3 Jul 2023 20:58:35 +0000 (13:58 -0700)]
Fix condition for ENSURE_PRIMARY_STACK_SIZE (#88342)

Fixes #88339

13 months ago TcpListener should implement IDisposable (#88043)
Alexander Radchenko [Mon, 3 Jul 2023 20:52:51 +0000 (02:52 +0600)]
 TcpListener should implement IDisposable (#88043)

* TcpListener should implement IDisposable

* lint

* Code review

* Update src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPListener.cs

Co-authored-by: Anton Firszov <antonfir@gmail.com>
* Update TCPListener.cs [EditorBrowsable(EditorBrowsableState.Never)]

* Code review

* lint

* Code review

---------

Co-authored-by: Anton Firszov <antonfir@gmail.com>
13 months agoFix incorrect sequence number used in NTLM signature calculation (#87998)
Filip Navara [Mon, 3 Jul 2023 20:44:14 +0000 (22:44 +0200)]
Fix incorrect sequence number used in NTLM signature calculation (#87998)

13 months ago[mono] Remove mono_loader_save_bundled_library() (#88331)
Alexander Köplinger [Mon, 3 Jul 2023 20:14:43 +0000 (22:14 +0200)]
[mono] Remove mono_loader_save_bundled_library() (#88331)

13 months agoRemove TODO from a comment in System.Guid.cs (#88337)
SwapnilGaikwad [Mon, 3 Jul 2023 19:43:36 +0000 (20:43 +0100)]
Remove TODO from a comment in System.Guid.cs (#88337)

13 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 221346...
dotnet bot [Mon, 3 Jul 2023 15:46:39 +0000 (17:46 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2213468 (#88301)

13 months ago[Crossgen] Don't display list of enum values in help (#88324)
Adam Sitnik [Mon, 3 Jul 2023 14:14:56 +0000 (16:14 +0200)]
[Crossgen] Don't display list of enum values in help (#88324)

13 months agoUpgrade to LLVM 16 & C++17, and bundle libc++ on Linux (#87190)
Jo Shields [Mon, 3 Jul 2023 13:46:29 +0000 (09:46 -0400)]
Upgrade to LLVM 16 & C++17, and bundle libc++ on Linux (#87190)

* Upgrade to LLVM 16, and stop focusing on C++11 ABi stuff from CentOS 7

Co-authored-by: Zoltan Varga <vargaz@gmail.com>
13 months ago[mono] fix memfuncs for FreeBSD (#88300)
Thefrank [Mon, 3 Jul 2023 13:31:49 +0000 (06:31 -0700)]
[mono] fix memfuncs for FreeBSD (#88300)

* fix memfuncs for FreeBSD

* match format