platform/upstream/dotnet/runtime.git
17 months ago[wasm][debugger] Skip wasm frames if just my code is enabled (#81732)
Thays Grazia [Thu, 16 Feb 2023 13:21:52 +0000 (10:21 -0300)]
[wasm][debugger] Skip wasm frames if just my code is enabled (#81732)

* Trying to avoid stepping out when there is no source available and justmycode is enabled.

* Skip only wasm frames.

* Fix test after using DebuggerNonUserCode on JSImport and JSExport.

* Fix stepping out when JustMyCode is enabled and the function that should be skipped is the last in the callstack.

* Fix side effect.

* addressing radical comments offline

17 months agoFill missing @mention data in area-owners.json (#82228)
Marek Safar [Thu, 16 Feb 2023 12:59:06 +0000 (13:59 +0100)]
Fill missing @mention data in area-owners.json (#82228)

17 months agoAvoid a RIP relative addressing pessimization (#82213)
Tanner Gooding [Thu, 16 Feb 2023 12:55:03 +0000 (04:55 -0800)]
Avoid a RIP relative addressing pessimization (#82213)

* Avoid a RIP relative addressing pessimization

* Applying formatting patch

17 months agoInclude more details in exception from wrong async callback (#82104)
Stephen Toub [Thu, 16 Feb 2023 12:12:36 +0000 (07:12 -0500)]
Include more details in exception from wrong async callback (#82104)

* Include more details in exception from wrong async callback

Every now and then, we get reports of an exception due to an invalid object being passed to one of our callback delegates that expects specific state.  To help diagnose those better, this adds more details about what state was actually provided.

* Fix inlining

17 months agoJIT: Expand loop detection in if-conversion (#82170)
Jakob Botsch Nielsen [Thu, 16 Feb 2023 12:01:09 +0000 (13:01 +0100)]
JIT: Expand loop detection in if-conversion (#82170)

The BB weight approach does not detect unnatural loops.

Fix #82106

17 months agoJIT: Slightly refactor handling of conditions/conditional branches in the backend...
Jakob Botsch Nielsen [Thu, 16 Feb 2023 09:36:08 +0000 (10:36 +0100)]
JIT: Slightly refactor handling of conditions/conditional branches in the backend (#82020)

Slightly refactor how compares are represented and processed in the backend in
preparation of lifting the remaining cmov restrictions.

- Change all compare nodes to always produce values and never set flags. That
  is, GT_EQ/GT_NE/GT_LT/GT_LE/GT_GE/GT_GT/GT_TEST_EQ/GT_TEST_NE now are all
  "normal" nodes, always.

- Stop optimizing compares by looking for a user JTRUE node. Instead, we
  optimize the compare when we see it (for example, EQ/NE(AND(x, y), 0) is
  turned into GT_TEST_EQ/GT_TEST_NE(x, y)), but we do not change the user JTRUE
  node to a JCC node. We now never create SETCC nodes when we see the compare,
  and we always turn JTRUE nodes into JCC nodes with a proper condition.

- Handle the transformation from JTRUE to JCC when we actually get to JTRUE. The
  transformation that now happens is:

  1. The compare node is turned into a GT_CMP (for GT_EQ to GT_GT) or GT_TEST
  node (for GT_TEST_EQ/GT_TEST_NE) node. These nodes are always void-typed and
  do not produce values; they only set the CPU flags, and correspond directly to
  low-level target instructions (like cmp/test).

  2. The JTRUE is turned into JCC with the condition from the compare.

  For arm64/xarch, we handle optimizing EQ/NE(node_that_sets_zero_flag, 0) at
  this stage too now.

- Introduce new xarch backend-only GT_BITTEST_EQ/GT_BITTEST_NE that semantically
  correspond to (x & (1 << y)) != 0. The corresponding "set flags" node is GT_BT
  and already exists. We would previously transform (x & (1 << y)) != 0 into
  GT_BT + GT_SETCC (when the user was not a JTRUE). This is now transformed into
  GT_BITTEST_EQ/GT_BITTEST_NE instead, which are completely normal nodes. The
  processing of JTRUE handles the transformation into BT + JCC.

- Change some of the emitter compare peepholes to work with this scheme. This
  requires some lookahead when we see them, but allows us to get rid of an
  "ugly" flag.

- Allow liveness to DCE GT_CMP/GT_TEST when they have had GTF_SET_FLAGS unset
  (due to FG optimizations). We already allowed this for GT_EQ, so this showed
  up as some regressions.

Some example LIR diffs:

```diff
  Generating: N033 (???,???) [000136] -----------                            IL_OFFSET void   INLRT @ 0x00A[E-] REG NA
  Generating: N035 (  1,  1) [000009] -----------                    t9 =    LCL_VAR   int    V02 loc1         u:1 ecx REG ecx $141
  Generating: N037 (  1,  1) [000011] -c---------                   t11 =    CNS_INT   int    16 REG NA $42
                                                                          ┌──▌  t9     int
                                                                          ├──▌  t11    int
- Generating: N039 (  3,  3) [000012] N------N-U-                         ▌  GE        void   REG NA $142
+ Generating: N039 (  3,  3) [000012] -------N-U-                         ▌  CMP       void   REG NA
  IN0005:        cmp      ecx, 16
- Generating: N041 (  5,  5) [000013] -----------                         ▌  JTRUE     void   REG NA $VN.Void
+ Generating: N041 (???,???) [000144] -----------                            JCC       void   cond=UGE REG NA
  IN0006:        jae      L_M20112_BB03
                                                                          ┌──▌  t112   ubyte
                                                                          ├──▌  t54    int
- Generating: N061 ( 22, 14) [000060] ---XGO-----                         ▌  BT        void   REG NA
+ Generating: N061 ( 22, 14) [000060] ---XGO-----                   t60 = ▌  BITTEST_NE int    REG eax
  IN0009:        bt       eax, esi
- Generating: N063 (???,???) [000144] -----------                  t144 =    SETCC     int    cond=C REG eax
  IN000a:        setb     al
  IN000b:        movzx    eax, al
-                                                                         ┌──▌  t144   int
+                                                                         ┌──▌  t60   int
  Generating: N065 ( 23, 15) [000061] ---XGO-----                         ▌  RETURN    int    REG NA <l:$1c8, c:$1c7>
```

17 months agoMicrosoft.NETCore.Platforms: fix graph not being updated on pack. (#82204)
Tom Deseyn [Thu, 16 Feb 2023 06:27:39 +0000 (07:27 +0100)]
Microsoft.NETCore.Platforms: fix graph not being updated on pack. (#82204)

17 months agoFix tests to use ConditionalFact that need it (#82203)
Kevin Jones [Thu, 16 Feb 2023 05:39:51 +0000 (00:39 -0500)]
Fix tests to use ConditionalFact that need it (#82203)

17 months agoAdd jiterpreter trace transfer and other optimizations
Katelyn Gadd [Thu, 16 Feb 2023 05:02:22 +0000 (21:02 -0800)]
Add jiterpreter trace transfer and other optimizations

* Adds the concept of 'trace transfer' where if a trace compile stopped due to reaching another trace's entry point, we will now enter that other trace directly (with the aid of a helper function). The helper function will also notice if the target trace branches back to itself and continue running it, which allows a subset of loops to run without returning to the interpreter. (Right now this loop optimization only seems to activate a small percentage of the time, but it does work.)
* Optimize appendName for the common case of single-character names, and use encodeInto instead of encode. Before this in a browser-bench run out of ~550ms of trace compile time, 80ms was appendName alone 😟
* 'safepoint needed' checks are now done inline in traces instead of via a function call into runtime C (as suggested by @vargaz), which should make them a bit cheaper.
* The math functions like asin and tan are now all implemented in C - previously we used the JS Math object for them since you're meant to be able to do that in wasm, but I realized the output of the JS ones might not precisely match what the regular interpreter's libc would produce. So now they will be consistent.

17 months agoPrevent XUnitLogChecker from failing if no logs are found. (#82212)
Ivan Diaz Sanchez [Thu, 16 Feb 2023 03:28:45 +0000 (19:28 -0800)]
Prevent XUnitLogChecker from failing if no logs are found. (#82212)

17 months agoRemove ConfigurationBinder usage from Console Logging (#82098)
Eric Erhardt [Thu, 16 Feb 2023 03:05:20 +0000 (21:05 -0600)]
Remove ConfigurationBinder usage from Console Logging (#82098)

* Remove ConfigurationBinder usage from Console Logging

This allows ConfigurationBinder, and its dependencies like TypeConverter,
to be trimmed in an application that uses Console Logging, like an
ASP.NET API application.

Fix #81931

* Ensure invalid configuration data throws appropriate exception.

17 months agoWorkloads: Fix a regression in file permissions for workload packs (#82211)
Ankit Jain [Thu, 16 Feb 2023 01:35:06 +0000 (20:35 -0500)]
Workloads: Fix a regression in file permissions for workload packs (#82211)

Reverts
https://github.com/dotnet/runtime/commit/b6e2dbe97c917d9e5ae722fde543d1ab5581b5f7
essentially.

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

This especially shows up on macOS when doing a system install. When installing the workload to a user directory, the permissions get set correctly, which is why this was not caught by Wasm.Build.Tests .

17 months agoEnable building NativeAOT for Apple mobile platforms (#81780)
Alexander Köplinger [Thu, 16 Feb 2023 01:00:08 +0000 (02:00 +0100)]
Enable building NativeAOT for Apple mobile platforms (#81780)

These changes allow the NativeAOT runtime to compile for and run on iOS, tvOS and MacCatalyst.

17 months ago[tests][ios] Disable StartupHook (#82175)
Mitchell Hwang [Wed, 15 Feb 2023 21:41:15 +0000 (16:41 -0500)]
[tests][ios] Disable StartupHook (#82175)

17 months agoFix emitting `DehydratedDataCommand.ZeroFill` when alignment is high (#82155)
Michal Strehovský [Wed, 15 Feb 2023 21:11:18 +0000 (06:11 +0900)]
Fix emitting `DehydratedDataCommand.ZeroFill` when alignment is high (#82155)

The alignment might not fit into a single byte.

17 months agoImplement DivRem intrinsic for X86 (#66551)
Huo Yaoyuan [Wed, 15 Feb 2023 21:10:23 +0000 (05:10 +0800)]
Implement DivRem intrinsic for X86 (#66551)

* Add managed api for divrem

* Add NI definition of DivRem

* Fix DivRem to be static

* Implement DivRem in clrjit

* Add tests for DivRem

* Adjust lsra and RMW

* Use DivRem intrinsic in Math

* Bring lower change from coreclr#37928
This fixes error while crossgen2 compiling Utf8Formatter.TryFormat(TimeSpan).

* Fix signedness of DIV

* Revert RMW change and fix reg allocation

* Fix import of X64 intrinsic

* Fix static in PNSE version

* Fix accidential indent change

* Apply format patch

* op3 candidate should be different from op1 and op2

* Add guard over AsHWIntrinsic

* Disable DivRem intrinsic use for Mono

* Fix LSRA and invalid assertion

* Set RWM information correctly, although totally unused.

* Move multi-reg temp allocation to common helper

* Disable DivRem intrinsic test for Mono.

* Fix typo of quotient

* Use impAssignMultiRegTypeToVar

* Update #ifdef

* Remove change in LowerBlockStore

* Adjust assert and helper method

* Update CheckMultiRegLclVar

* fix build errors

* Fix some merge conflicts

* Fix some errors

* Fix GCC build error

* jit format

* Make the size depending on the struct

* Fix the formatting of summary

* Remove trailing spaces

* Fix the tests to adopt new model

* Fix MAX_RET_REG_COUNT -> MAX_MULTIREG_COUNT

* Exclude from mono run

* Add RequiresProcessIsolation

* Real fix for build break

* Fix the test cases to adopt to the new system

* Disable for llvm-fullaot

* Also continue disabling for mono

* Disable the test in a different group

* fix merge conflict

* format

* fix another merge conflict error

* misc changes from review

* fix the replay errors

* jit format

* Add exclude list in mono/llvmfullaot

* Review feedback and fix bug in CheckMultiRegLclVar

* Pass registerCount

* review feedback

* Remove the extra comments

* Disable tests on mono llvmfullaot runs as well

* Add missing case for upper save/restore

* Add missing RequiresProcessIsolation

* Revert "Add missing case for upper save/restore"

This reverts commit a98dbde4bd547824388fcb410c06b2503a870fb6.

* Remove RequiresProcessIsolation property

* Replace ref with fakelibs

* Add references of fakelib to test project

* Fix CompatibilitySuppressions.xml

* fix test builds

* Remove unneeded extern/using

* Revert "Replace ref with fakelibs"

This reverts commit e1b5fb38ce84c34f143e36be6aafc27ce820d8df.

* Revert "Revert "Replace ref with fakelibs""

This reverts commit 39ae98d2fee0c2b9d94437bce744c9f065654ed0.

* Exclude DivRem.csproj

* Handle the case to delay-free op3 for op1/op2

* Create the DivRem.RefOnly fake CoreLib as a reference assembly

Make the DivRem tests reference the DivRem fake
CoreLib as reference assembly; and ensure that it is not included as a
ProjectReference by the toplevel HardwareIntrinsics merged test
runners.

The upshot is that the DivRem tests can call the extra APIs via
a direct reference to CoreLib (instead of through System.Runtime), but
the fake library is not copied into any test artifact directories, and
the Mono AOT compiler never sees it.

* Unify AddDelayFreeUses

---------

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
17 months agoCreate skeleton for the ComInterfaceGenerator (#80887)
Jeremy Koritzinsky [Wed, 15 Feb 2023 21:03:41 +0000 (13:03 -0800)]
Create skeleton for the ComInterfaceGenerator (#80887)

Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
17 months agoAdd new Xml Type parser (#82145)
Tlakaelel Axayakatl Ceja [Wed, 15 Feb 2023 20:55:14 +0000 (12:55 -0800)]
Add new Xml Type parser (#82145)

Use new type parser for xml processing
Add tests in nativeAOT
Port XML testing changes from NativeAOT to illink
Port logic to distinguish who needs to Kept an element in illink

17 months agoIf we hit a jiterpreter enter opcode while compiling a trace, stop compiling there...
Katelyn Gadd [Wed, 15 Feb 2023 20:10:05 +0000 (12:10 -0800)]
If we hit a jiterpreter enter opcode while compiling a trace, stop compiling there (#82130)

This keeps traces shorter and reduces the amount of time spent compiling them

17 months agoFix NamedMutex PAL test (#82122)
Adeel Mujahid [Wed, 15 Feb 2023 19:52:34 +0000 (21:52 +0200)]
Fix NamedMutex PAL test (#82122)

17 months ago[mono][interp] Intrinsify CreateSpan (#82093)
Vlad Brezae [Wed, 15 Feb 2023 19:34:47 +0000 (21:34 +0200)]
[mono][interp] Intrinsify CreateSpan (#82093)

* [mono][interp] Remove redundant opcode

* [mono][interp] Intrinsify CreateSpan

17 months agoCI: don't trigger *all* library tests on wasm-only changes (#81906)
Ankit Jain [Wed, 15 Feb 2023 19:19:15 +0000 (14:19 -0500)]
CI: don't trigger *all* library tests on wasm-only changes (#81906)

* CI: don't trigger *all* library tests on wasm-only changes

For wasm changes that should trigger wasm library tests, a different
subset is used.

* CI: Remove unused wasi-build-only.yml

* Add runtime-wasm-optional to wasm-only list

17 months agoeng/SourceBuild.props: remove dangling SourceBuildNonPortable. (#82160)
Tom Deseyn [Wed, 15 Feb 2023 18:58:43 +0000 (19:58 +0100)]
eng/SourceBuild.props: remove dangling SourceBuildNonPortable. (#82160)

17 months agoFix reporting of an async IO timeout error on Windows (`SerialPort`) (#81744)
Koundinya Veluri [Wed, 15 Feb 2023 18:57:45 +0000 (10:57 -0800)]
Fix reporting of an async IO timeout error on Windows (`SerialPort`) (#81744)

- When an async `SerialPort` IO operation times out, it reports the timeout in the IO completion with an `NTSTATUS` value of `WAIT_TIMEOUT` (258)
- In the thread pool when using `GetQueuedCompletionStatusEx`, the `NTSTATUS` value was being checked against `STATUS_SUCCESS` to determine success, so the `WAIT_TIMEOUT` was reported as an error. This leads to a different exception being thrown, compared to before when `GetQueuedCompletionStatus` was used.
- Fixed to use similar logic to the SDK's `NT_SUCCESS` macro, which treats the `WAIT_TIMEOUT` value as a success, which is similar to what `GetQueuedCompletionStatus` does
- There are already tests that verify this behavior in `System.IO.Ports` tests, though [they are currently disabled](https://github.com/dotnet/runtime/blob/b39d6a6eb44860746e91e5ce4f585beff33d1f63/src/libraries/System.IO.Ports/tests/Support/TCSupport.cs#L108-L118) due to instabilities. I have verified locally that the relevant failures are fixed and that there are no new failures in those tests.

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

17 months agoUpdate CEEInfo::getAddressOfPInvokeTarget to handle already resolved P/Invokes (...
Tanner Gooding [Wed, 15 Feb 2023 18:05:14 +0000 (10:05 -0800)]
Update CEEInfo::getAddressOfPInvokeTarget to handle already resolved P/Invokes (#82150)

* Update CEEInfo::getAddressOfPInvokeTarget to handle already resolved P/Invokes

* Make sure to use NDirectMethodDesc

* Respond to PR feedback and remove dead GetNativeNDirectTarget logic

* Fix a manual offsetof for NDirectMethodDesc

* Use offsetof directly

* Remove some more dead code

* Fix the JIT/EE transition for getAddressOfPInvokeTarget

* Fix the getAddressOfPInvokeTarget contract

17 months ago[main] Update dependencies from dotnet/llvm-project dotnet/emsdk dotnet/icu dotnet...
dotnet-maestro[bot] [Wed, 15 Feb 2023 17:20:20 +0000 (12:20 -0500)]
[main] Update dependencies from dotnet/llvm-project dotnet/emsdk dotnet/icu dotnet/xharness dotnet/hotreload-utils dotnet/cecil (#82048)

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

runtime.linux-arm64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.linux-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-musl-x64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.linux-musl-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.linux-x64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.linux-x64.Microsoft.NETCore.Runtime.ObjWriter , runtime.osx-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.osx-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.osx-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.osx-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-arm64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.win-arm64.Microsoft.NETCore.Runtime.ObjWriter , runtime.win-x64.Microsoft.NETCore.Runtime.JIT.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.ObjWriter
 From Version 14.0.0-alpha.1.23110.1 -> To Version 14.0.0-alpha.1.23113.3

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

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 8.0.0-preview.2.23108.2 -> To Version 8.0.0-preview.2.23113.1

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

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

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

Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100-preview.2
 From Version 8.0.0-preview.2.23108.1 -> To Version 8.0.0-preview.2.23113.1

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

Microsoft.DotNet.HotReload.Utils.Generator.BuildTool
 From Version 1.1.0-alpha.0.23107.1 -> To Version 1.1.0-alpha.0.23113.1

* Update dependencies from https://github.com/dotnet/cecil build 20230213.1

Microsoft.DotNet.Cecil
 From Version 0.11.4-alpha.23106.4 -> To Version 0.11.4-alpha.23113.1

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months ago[mono][jit] Adding parametrized macros for arm64/neon opcode encodings, codegen tests...
Jan Dupej [Wed, 15 Feb 2023 16:51:22 +0000 (17:51 +0100)]
[mono][jit] Adding parametrized macros for arm64/neon opcode encodings, codegen tests for the same. (#81887)

17 months agoFix CancellationTokenSource_CancelAsync_AllCallbacksInvoked test (#82153)
Stephen Toub [Wed, 15 Feb 2023 16:13:50 +0000 (11:13 -0500)]
Fix CancellationTokenSource_CancelAsync_AllCallbacksInvoked test (#82153)

If the task internally queued by CancelAsync hasn't started yet by the time we block waiting for it, Wait could inline it and end up running it on the current thread.

17 months agoDisable failing test (#82162)
Šimon Rozsíval [Wed, 15 Feb 2023 16:08:16 +0000 (17:08 +0100)]
Disable failing test (#82162)

17 months ago[mono] Implement synch block fast paths in managed (#81380)
Aleksey Kliger (λgeek) [Wed, 15 Feb 2023 14:23:18 +0000 (09:23 -0500)]
[mono] Implement synch block fast paths in managed (#81380)

* [mono] Implement synch block fast paths in managed

   Investigate one incremental alternative from https://github.com/dotnet/runtime/issues/48058

   Rather than switching to NativeAOT's Monitor implementation in one step, first get access to Mono's synchronization block from managed, and implement the fast paths for hash code and monitor code in C#.

* Implement TryEnterFast and TryEnterInflatedFast

   This should help the interpreter particularly, since it doesn't have an intrinsic path here

* Add replacements for test_owner and test_synchronized icalls

   ObjectHeader.IsEntered and ObjectHeader.HasOwner, respectively

* access sync block through helpers

* Get a pointer to the object header another way

   Unsafe.As<TFrom,TTo>() was converting a object** into a header*.

   Go through Unsafe.AsPointer to get a Header** and then deref it once to get a header

* logical shifts, not arithmetic

   on wasm32, IntPtr and int are both the same size. so when we store a hash code into _lock_word that ends up with the 30th high bit set, the right shift to get it back out needs to be arithmetic or else we get incorrect hash codes

* force inlining

* move fast path into ReliableEnterTimeout

* Don't pass lockTaken to ObjectHolder.TryEnterFast

   set it in the caller if we succeeded

* TryEnterFast: handle flat recursive locking, too

* Implement Monitor.Exit fast path in managed

   If the LockWord is flat, there has been no contention, so there is noone to signal when we exit

* Don't call MonoResolveUnmanagedDll for the default ALC

   it would always return null anyway.

   But also this avoids a circular dependency between the managed Default ALC constructor and Monitor icalls (the ALC base constructor locks allContexts).

* [interp] don't lookup internal calls that were replaced by an opcode

   If it was replaced by an intrinsic, we're not really going to call the wrapper, no need to look for it

* Add Interlocked.CompareExchange interp intrinsics for I4 and I8

* more inlining: LockWordCompareExchange

* Use a ref struct to pass around the address of a MonoObject* on the stack

   This is similar to ObjectHandleOnStack except with a getter that lets us view the object header.

   Get rid of calls to GC.KeepAlive.

   With this, the fast path (locking a flat unowned object) doesn't have any calls on it besides argument validation

* Add fast path for Monitor.Exit for inflated monitors with no waiters

* Check for obj == null before ThrowIfNull

   In the interp it's cheaper to do a null check followed by a call than an unconditional call

* Inline RuntimeHelpers.GetHashCode

* inline TryEnterInflatedFast; nano-opts

   - change SyncBlock.HashCode to return the value, not a ref - we don't have managed code that writes into the sync block.
   - change TryEnterInflatedFast to avoid looping - if the CompareExchange fails, fall back to the slow path

* disable the TryGetHashCode fast path helper

   It was actually making things slower on the interpreter.

   In the JIT it made object.GetHashCode about 50% faster for an object with a pre-computed hash, but that might mean we need the same kind of "no-wrapper; then wrapper" fastpath/slowpath that we have for the Monitor.Enter intrinsic in mini.

* Fix last exit from inflated monitor

   When nest == 1 the caller is responsible for setting the owner to 0 to indicate that the monitor is unlocked.  (But we leave the nest count == 1, so that it is correct next time the monitor is entered)

* avoid repeated calls in TryEnterInflatedFast

* Combine TryExit and IsEntered into TryExitChecked

   avoid duplicated lockword and sync block manipulations

* Re-enable managed GetHashCode in JIT; intrinsify in interp

   Instead of treating InternalGetHashCode/InternalTryGetHashCode as intrinsics in the interpreter, intrinsify RuntimeHelpers.GetHashCode and RuntimeHelpers.TryGetHashCode and avoid the managed code entirely when possible

* add CMPXCHG opcodes to the jiterpreter

   For the i64 version, pass the address of the i64 values to the helper function.

   The issue is that since JS doesn't have i64, EMSCRIPTEN_KEEPALIVE messes with the function's signature and we get import errors in the JITed wasm module.  Passing by address works around the issue since addresses are i32.

* fix whitespace

* [jiterp] Allow null obj in hashcode intrinsics

   The underlying C functions are null-friendly, and the managed intrinsics are allowed to C null inputs.  The assert is unnecessary.

17 months agoAdding support to mono for v128 constants (#81902)
Tanner Gooding [Wed, 15 Feb 2023 13:57:39 +0000 (05:57 -0800)]
Adding support to mono for v128 constants (#81902)

* Adding support to mono for v128 constants

* Ensure that mini-amd64 can handle Vector128<T> constants

* Have xconst "maximum instruction length" match r8const

* Ensure the right data.target indices are written

* Correctly handle the X128 patch point

* Ensure MONO_TYPE_I and MONO_TYPE_U are handled

* Ensure Vector`1 is handled

17 months agoDisable on failing platforms (#82159)
Marie Píchová [Wed, 15 Feb 2023 13:54:35 +0000 (14:54 +0100)]
Disable on failing platforms (#82159)

17 months agoBaseline another JIT test (#82158)
Michal Strehovský [Wed, 15 Feb 2023 12:21:17 +0000 (21:21 +0900)]
Baseline another JIT test (#82158)

This test starts failing once we reflection-root the test assembly.

17 months agoSPMI: Ensure we disable loop alignment consistently (#82100)
Jakob Botsch Nielsen [Wed, 15 Feb 2023 10:38:06 +0000 (11:38 +0100)]
SPMI: Ensure we disable loop alignment consistently (#82100)

Recently we disabled loop alignment in SPMI diffs, but this was only
done for the SPMI invocations when we generate disassembly. This would
result in the diffs run seeing different generated code than subsequent
disassembly runs.

This splits the environment variables we want to have enabled in the
diffs SPMI invocation out into its own dictionary. These are force
overridden.

17 months ago[browser] do not throw if culture data does not exist in icu (#82094)
Pavel Savara [Wed, 15 Feb 2023 10:34:04 +0000 (11:34 +0100)]
[browser] do not throw if culture data does not exist in icu (#82094)

* align with Blazor startup
* update tests

17 months agoRun unconditional msquic Linux test only in our CI, i.e. Helix (#82108)
Marie Píchová [Wed, 15 Feb 2023 08:48:29 +0000 (09:48 +0100)]
Run unconditional msquic Linux test only in our CI, i.e. Helix (#82108)

17 months agoSimplify an error condition in tryrun.cmake (#82070)
Adeel Mujahid [Wed, 15 Feb 2023 03:19:23 +0000 (05:19 +0200)]
Simplify an error condition in tryrun.cmake (#82070)

17 months agoBump generic cycle detection cutoff for the test tree (#82074)
Michal Strehovský [Wed, 15 Feb 2023 03:06:49 +0000 (12:06 +0900)]
Bump generic cycle detection cutoff for the test tree (#82074)

There's a JIT test that expects being able to recurse a bit deeper than what we allow by default.

17 months agoBaseline some failing JIT tests (#82075)
Michal Strehovský [Wed, 15 Feb 2023 03:06:24 +0000 (12:06 +0900)]
Baseline some failing JIT tests (#82075)

17 months ago[NativeAOT] Add ability to generate library and exe entry points (#81873)
Austin Wise [Wed, 15 Feb 2023 02:26:08 +0000 (18:26 -0800)]
[NativeAOT] Add ability to generate library and exe entry points (#81873)

This PR adds a new flag to ILC, `--splitinit` . The flag splits the initialization that is normally done for executable into two parts. The `__managed__Startup` function runs classlib and module initializers. The `__managed__Main` function performs the remaining initialization and executes the entry-point of the managed application.

The use case for this is to allow calling `UnamanagedCallersOnly` functions before the managed `main` function. Running on iOS is the first use case for this feature (#80905).

It was not clear to me how to fit this into the larger NativeAot build system. Should this be thought of as "a static library that also has a `__managed__Main` compiled in" or as "an executable that splits its initialization into two parts"? So I added support to ILC for both cases: compiling with the `--nativelib` flag and without it.

Lastly, I added some build integration the "an executable that splits its initialization into two parts" case, along with test. The idea is the user sets the `CustomNativeMain` property in their project. They are then responsible for providing a `NativeLibrary` item pointing to an object file containing their native `main` function. At runtime, when they call their first managed function, NativeAOT initialization will run. This includes calling `__managed__Main`, so the user cannot forget to initialize the runtime.

Related issues: #81097 #77957

17 months agoRemove reference to Cecil submodule in illink (#82124)
Jackson Schuster [Wed, 15 Feb 2023 01:39:01 +0000 (19:39 -0600)]
Remove reference to Cecil submodule in illink (#82124)

* Remove reference to cecil submodule in illink and unused projects

17 months agoDisable rundownvalidation test on GCStress for arm (#82118)
Bruce Forstall [Tue, 14 Feb 2023 23:18:21 +0000 (16:18 -0700)]
Disable rundownvalidation test on GCStress for arm (#82118)

Linux arm GCStress 3 times out

Tracking: https://github.com/dotnet/runtime/issues/81323

17 months agoGeneralize `emitRemoveLastInstruction()` (#82002)
Bruce Forstall [Tue, 14 Feb 2023 23:17:38 +0000 (16:17 -0700)]
Generalize `emitRemoveLastInstruction()` (#82002)

Allow it to remove the last instruction of an already-saved
instruction group.

Fixes #81505

17 months agoUse string interpolation in a few more places (#82096)
Stephen Toub [Tue, 14 Feb 2023 21:29:25 +0000 (16:29 -0500)]
Use string interpolation in a few more places (#82096)

Places where we'd otherwise be allocating for at least one of the subcomponents.

17 months agoRemove allocations in some System.Net GetHashCode methods (#82095)
Stephen Toub [Tue, 14 Feb 2023 21:29:13 +0000 (16:29 -0500)]
Remove allocations in some System.Net GetHashCode methods (#82095)

* Remove allocations in some System.Net GetHashCode methods

* Address PR feedback

17 months agoExclude Ubuntu 18.04 arm 32 docker image (#82092)
Marie Píchová [Tue, 14 Feb 2023 21:00:45 +0000 (22:00 +0100)]
Exclude Ubuntu 18.04 arm 32 docker image (#82092)

17 months agoSprinkle some more readonly around (#81297)
Stephen Toub [Tue, 14 Feb 2023 20:33:24 +0000 (15:33 -0500)]
Sprinkle some more readonly around (#81297)

* Sprinkle some more readonly around

* Revert a few changes / address feedback

17 months agoThis is the first of a series of changes to annotate the fields/methods in the gc_hea...
Maoni Stephens [Tue, 14 Feb 2023 20:32:28 +0000 (12:32 -0800)]
This is the first of a series of changes to annotate the fields/methods in the gc_heap in a meaningful way - (#82072)

separate fields from methods and make the annotation on the same line to make search a lot easier

17 months agoAdd Linux NativeAOT debug info regression test (#81612)
Andy Gocke [Tue, 14 Feb 2023 19:48:36 +0000 (11:48 -0800)]
Add Linux NativeAOT debug info regression test (#81612)

The test runs llvm-dwarfdump and verifies that the number of warnings
and errors is expected. As we improve the debug information we can
start tracking individual warnings and errors, hopefully bringing
this number to zero.

17 months agoTemporarily disable ParallelCrash, ParallelCrashMainThread under GCStress (#82066)
Bruce Forstall [Tue, 14 Feb 2023 18:47:24 +0000 (11:47 -0700)]
Temporarily disable ParallelCrash, ParallelCrashMainThread under GCStress (#82066)

These are regularly failing in GCStress testing.

Tracking: https://github.com/dotnet/runtime/issues/80356

17 months agoAdd emsdk dependencies to fix codeflow to installer (#81988)
Marc Paine [Tue, 14 Feb 2023 18:37:57 +0000 (10:37 -0800)]
Add emsdk dependencies to fix codeflow to installer (#81988)

* Update Version.Details.xml

* Apply suggestions from code review to remove sourcebuild labels

Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
---------

Co-authored-by: Matt Mitchell <mmitche@microsoft.com>
17 months agoTemporarily disable TestCallingConventions test for x86 GCStress (#82060)
Bruce Forstall [Tue, 14 Feb 2023 18:31:57 +0000 (11:31 -0700)]
Temporarily disable TestCallingConventions test for x86 GCStress (#82060)

Tracking: https://github.com/dotnet/runtime/issues/78620

17 months agoRevert "Allow some intrinsics in Tier0 (#77357)" (#82079)
Bruce Forstall [Tue, 14 Feb 2023 18:21:15 +0000 (11:21 -0700)]
Revert "Allow some intrinsics in Tier0 (#77357)" (#82079)

This reverts commit e1edb16b0320eaadf721ddbe7df4caaeb524982e.

17 months ago[Merge-on-Red] - Implement XML log fixer for Helix (#80751)
Ivan Diaz Sanchez [Tue, 14 Feb 2023 17:47:38 +0000 (09:47 -0800)]
[Merge-on-Red] - Implement XML log fixer for Helix (#80751)

The XML log fixer for tests in Helix is now implemented and functional.

17 months agoRemove a bunch of array allocations (#82041)
Stephen Toub [Tue, 14 Feb 2023 17:31:39 +0000 (12:31 -0500)]
Remove a bunch of array allocations (#82041)

17 months agoAllow ConcurrentDictionary concurrencyLevel == -1 (#82067)
Stephen Toub [Tue, 14 Feb 2023 17:31:23 +0000 (12:31 -0500)]
Allow ConcurrentDictionary concurrencyLevel == -1 (#82067)

* Allow ConcurrentDictionary concurrencyLevel == -1

Rather than throwing for it, treat it as a sentinel meaning the default concurrency level.

* Address PR feedback

17 months ago[main] Update dependencies from dotnet/arcade (#82087)
dotnet-maestro[bot] [Tue, 14 Feb 2023 16:39:18 +0000 (11:39 -0500)]
[main] Update dependencies from dotnet/arcade (#82087)

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

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months agoJIT: Optimize zero inits out only for locals that aren't candidates to be tracked...
Jakob Botsch Nielsen [Tue, 14 Feb 2023 11:21:41 +0000 (12:21 +0100)]
JIT: Optimize zero inits out only for locals that aren't candidates to be tracked (#82042)

Otherwise we may track it after lowering and invalidate the assumptions
made by the optimization.

Fix #82020

17 months agoAdd assert messages to ConcurrentDictionary test failing on native aot (#82047)
Stephen Toub [Tue, 14 Feb 2023 10:45:34 +0000 (05:45 -0500)]
Add assert messages to ConcurrentDictionary test failing on native aot (#82047)

* Add assert messages to ConcurrentDictionary test failing on native aot

* Replace default.rd.xml

* Update src/libraries/System.Collections.Concurrent/tests/ConcurrentDictionary/ConcurrentDictionary.Generic.Tests.cs

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

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
17 months agoSystem.Console: remove terminfo file size check (#82038)
Tom Deseyn [Tue, 14 Feb 2023 09:21:04 +0000 (10:21 +0100)]
System.Console: remove terminfo file size check (#82038)

17 months agoRegularExpressions.Tests: match MicrosoftCodeAnalysisVersion used by RegularExpressio...
Tom Deseyn [Tue, 14 Feb 2023 09:03:20 +0000 (10:03 +0100)]
RegularExpressions.Tests: match MicrosoftCodeAnalysisVersion used by RegularExpressions.Generator when DotNetBuildFromSource. (#82036)

* RegularExpressions.Tests: match MicrosoftCodeAnalysisVersion used by RegularExpressions.Generator when DotNetBuildFromSource.

* RegularExpressions.Tests: remove pinned version for MicrosoftCodeAnalysis.

17 months agoTemplatize fgAddRefPred (#81865)
Bruce Forstall [Tue, 14 Feb 2023 07:27:15 +0000 (00:27 -0700)]
Templatize fgAddRefPred (#81865)

The `initializingPreds` argument is only `true` in a few cases.
Convert it to a template argument to see if there is any measureable
throughput impact.

17 months agoFix build.cmd -s clr.aot+libs (#82019)
Austin Wise [Tue, 14 Feb 2023 07:02:32 +0000 (23:02 -0800)]
Fix build.cmd -s clr.aot+libs (#82019)

The instructions to build NativeAOT suggest this invocation:

```
build.cmd -s clr.aot+libs
```

However I get this error while building:

```
C:\runtime\src\libraries\externals.csproj(90,5): error : Could not locate CoreCLR IL files.
```

Here is the target that generates the error:

https://github.com/dotnet/runtime/blob/main/src/libraries/externals.csproj#L72-L91

It looks like it is only supposed to run when compiling against vanillia
CoreCLR.

17 months agoIntrinsify `CreateSpan` in static constructor interpreter (#81747)
Michal Strehovský [Tue, 14 Feb 2023 02:39:38 +0000 (11:39 +0900)]
Intrinsify `CreateSpan` in static constructor interpreter (#81747)

Introduction of `CreateSpan` and its use in CoreLib regressed the number of types we can preinitialize. To add insult to injury, we were also hitting throwing paths in the cctor interpreter because the patterns generated by the C# compiler got lumped into uninteresting IL-only sequences we treated as invalid IL (the cctor interpreter should really only throw for invalid IL, but sometimes we throw for valid-but-uncommon IL too). As a result, even a hello world was hitting half a dozen first chance exceptions.

This adds intrinsic treatment to `CreateSpan`. We also need to treat `ReadOnlySpan` specially because of #78681. That issue is basically a rewrite of the interpreter memory model and likely won't be addressed anytime soon.

17 months agoTemporarily disable Interop/COM/ComWrappers/WeakReference/WeakReferenceTest (#82054)
Bruce Forstall [Tue, 14 Feb 2023 01:52:07 +0000 (18:52 -0700)]
Temporarily disable Interop/COM/ComWrappers/WeakReference/WeakReferenceTest (#82054)

Disable under GCStress.

Tracking: https://github.com/dotnet/runtime/issues/81362

17 months agoDisable DictionaryExpansion.cmd test on win-x86 (#82056)
Bruce Forstall [Tue, 14 Feb 2023 01:48:10 +0000 (18:48 -0700)]
Disable DictionaryExpansion.cmd test on win-x86 (#82056)

Tracking: https://github.com/dotnet/runtime/issues/75244

17 months agoEnable tests blocked on closed issue #50381 (#82024)
Michal Strehovský [Tue, 14 Feb 2023 01:46:23 +0000 (10:46 +0900)]
Enable tests blocked on closed issue #50381 (#82024)

This issue is closed. Either these are fixed, or the issue needs to be open.

17 months agoLazily initialize base state for Random-derived type (#81627)
Stephen Toub [Tue, 14 Feb 2023 01:43:04 +0000 (20:43 -0500)]
Lazily initialize base state for Random-derived type (#81627)

When the legacy Random algorithm is used, which happens when a seed is supplied or when a type derived from Random is used, the state for the algorithm is initialized, including an int[56] that gets allocated.  For a Random-derived type that overrides all of the base methods, however, that state is never used.  We can create it lazily rather than at ctor time and avoid those base costs if they're never used.

(I'd previously made several attempts at this, but each ended up with regressions up to 15%.  Any regressions here appear to be within the noise, and even if they manifest, would only be limited to the case of Random-derived types that don't supply their own implementations.)

17 months agoMove 'special characters' detection logic to JsonReaderHelpers (#82059)
Eirik Tsarpalis [Tue, 14 Feb 2023 01:42:47 +0000 (01:42 +0000)]
Move 'special characters' detection logic to JsonReaderHelpers (#82059)

17 months agoUse the new BitArray.HasAllSet() method (#82057)
Eirik Tsarpalis [Tue, 14 Feb 2023 01:41:40 +0000 (01:41 +0000)]
Use the new BitArray.HasAllSet() method (#82057)

17 months agoAdd new InteropData ordering rule (#82044)
Jan Kotas [Mon, 13 Feb 2023 23:10:05 +0000 (15:10 -0800)]
Add new InteropData ordering rule (#82044)

Fixes #82037

17 months agoFix XmlSqlBinaryReader and introduce a corpus of SqlXml tests (#81878)
Jeff Handley [Mon, 13 Feb 2023 23:04:36 +0000 (15:04 -0800)]
Fix XmlSqlBinaryReader and introduce a corpus of SqlXml tests (#81878)

* Fix XmlSqlBinaryReader and introduce a corpus of SqlXml tests

* Revert solution file changes made by VS

* Use runtime-assets test files for Text and SQL Binary XML tests

* Remove System.Data.Common.TestData package reference

* Reference the System.Data.Common.TestData package for SqlXml tests

* Add System.Common.Data.TestData to Version.Details.xml for automated dependency flow

17 months agoAllow some intrinsics in Tier0 (#77357)
Egor Bogatov [Mon, 13 Feb 2023 22:46:47 +0000 (23:46 +0100)]
Allow some intrinsics in Tier0 (#77357)

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
17 months agoCreate BitArray.HasAllSet() and .HasAnySet(). (#81527)
LateApexEarlySpeed [Mon, 13 Feb 2023 22:43:30 +0000 (06:43 +0800)]
Create BitArray.HasAllSet() and .HasAnySet(). (#81527)

* Create BitArray.HasAllSet().

* Fix comment: use span rather than vector directly.

* Create BitArray.HasAnySet().

* Fix comment: alpha order ref methods.

* Create tests.

* Fix comment: rename variable; check by '>= 0'.

* Add xml doc.

* Fix comment: add cases of other bits besides of the last bit.

17 months ago[wasm] Wasm.Build.Tests - some cleanup to prepare for Wasi.Build.Tests, and wasi...
Ankit Jain [Mon, 13 Feb 2023 22:42:35 +0000 (17:42 -0500)]
[wasm] Wasm.Build.Tests - some cleanup to prepare for Wasi.Build.Tests, and wasi workload (#81977)

* [wasm] Extract a base class from WasmAppBuilder, for future use with WasiAppBuilder task
* [wasm] RunScriptTemplate* - cleanup for use in WBT
And introduce a $SDK_DIR_NAME envvar

* [wasm] Wasm.Build.Tests - move some files to Common/ for use with Wasi.Build.Tests
* Address review feedback from @maraf

17 months agoJIT: Add DOTNET_JitOnlyOptimizeRange (#82034)
Jakob Botsch Nielsen [Mon, 13 Feb 2023 21:23:48 +0000 (22:23 +0100)]
JIT: Add DOTNET_JitOnlyOptimizeRange (#82034)

Useful to bisect situations where some optimization is breaking the
world.

17 months agoFix non-determinism in Type.IsAssignableTo (#78939)
David Wrighton [Mon, 13 Feb 2023 21:08:30 +0000 (13:08 -0800)]
Fix non-determinism in Type.IsAssignableTo (#78939)

* Fix non-determinism in Type.IsAssignableTo
- The previous work in #54588 introduced non-determinism to interface resolutions, and was only correct assuming that interface casts were never attempted to be fed through the casting helpers.
- The fix is to simply not allow casts to the interface type to succeed if they are of the SpecialMarkerType ForGenericCasting (which is just the open generic type)

If this change causes measurable impact to the performance of casting or such, we could rework it to represent the special marker types with a special bit or something, but it would be much more invasive of a change.

Fixes #78619
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
17 months agoUpdate Microsoft.Extensions.Logging.EventSource.Tests.csproj (#82022)
Michal Strehovský [Mon, 13 Feb 2023 20:25:59 +0000 (05:25 +0900)]
Update Microsoft.Extensions.Logging.EventSource.Tests.csproj (#82022)

17 months agoAdd CancellationTokenSource.CancelAsync (#81444)
Stephen Toub [Mon, 13 Feb 2023 20:22:41 +0000 (15:22 -0500)]
Add CancellationTokenSource.CancelAsync (#81444)

17 months agoReplace some single-char strings with chars (#81831)
Stephen Toub [Mon, 13 Feb 2023 20:22:10 +0000 (15:22 -0500)]
Replace some single-char strings with chars (#81831)

* Replace some single-char strings with chars

Also a few other minor improvements noticed along the way.

* Update src/libraries/System.Diagnostics.Process/src/System/Diagnostics/ProcessManager.Windows.cs

17 months agoJIT: start working on profile consistency (#81936)
Andy Ayers [Mon, 13 Feb 2023 19:49:29 +0000 (11:49 -0800)]
JIT: start working on profile consistency (#81936)

Dump flow graph before running post-phase checks so the flow graph
visualization can be used in conjunction with the profile checker output
to spot profile problems.

Various provisional fixes to try and shore up the inevitably inconsistent
OSR profile. Add a compensating pseudo-edges to the OSR entry to help
explain where the missing flow counts have gone. Relax checking for
the OSR entry. Add likelhood when we redirect flow to the OSR entry.
Locate the OSR entry and original method entry early so we can
special-case them in diagnostics.

Defer marking interesting blocks (say for switch peeling) until we've
set edge likelihoods, since (someday) those decisions should use edge
likelihoods.

Disable profile checking after profile incorporation. The plan is to
walk this disable back incrementally and fix issues in each succesive
phase, ultimately checking them all. But currently we still have a lot
of check failures right after this first phase.

Contributes to #46885.

17 months agoSetThreadDpiAwareness for host error dialog (#81930)
Elinor Fung [Mon, 13 Feb 2023 18:54:14 +0000 (10:54 -0800)]
SetThreadDpiAwareness for host error dialog (#81930)

17 months ago[main] Update dependencies from dotnet/xharness dotnet/runtime-assets dotnet/runtime...
dotnet-maestro[bot] [Mon, 13 Feb 2023 17:42:59 +0000 (12:42 -0500)]
[main] Update dependencies from dotnet/xharness dotnet/runtime-assets dotnet/runtime (#81996)

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

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

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

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

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

Microsoft.NET.ILLink.Tasks , Microsoft.NET.Sdk.IL , Microsoft.NETCore.App.Runtime.win-x64 , Microsoft.NETCore.ILAsm , runtime.native.System.IO.Ports , System.Text.Json
 From Version 8.0.0-preview.2.23105.4 -> To Version 8.0.0-preview.2.23112.4

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months ago[main] Update dependencies from dotnet/arcade (#81995)
dotnet-maestro[bot] [Mon, 13 Feb 2023 17:41:01 +0000 (12:41 -0500)]
[main] Update dependencies from dotnet/arcade (#81995)

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

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months agoRemove a number of JsonPropertyInfo reflection code to DefaultJsonTypeInfoResolver...
Eirik Tsarpalis [Mon, 13 Feb 2023 17:02:23 +0000 (17:02 +0000)]
Remove a number of JsonPropertyInfo reflection code to DefaultJsonTypeInfoResolver (#81990)

17 months agoFix pal tests build on osx-arm64 (#81604)
Adeel Mujahid [Mon, 13 Feb 2023 17:00:37 +0000 (19:00 +0200)]
Fix pal tests build on osx-arm64 (#81604)

17 months agoRemove errno check from the fallback in getexepath (#81852)
Adeel Mujahid [Mon, 13 Feb 2023 16:32:56 +0000 (18:32 +0200)]
Remove errno check from the fallback in getexepath (#81852)

17 months agoBump iOS/tvOS minimum version to 11.0, cleanup some code (#81965)
Alexander Köplinger [Mon, 13 Feb 2023 15:18:56 +0000 (16:18 +0100)]
Bump iOS/tvOS minimum version to 11.0, cleanup some code (#81965)

In .NET 8 the minimum Apple OS versions we're supporting are iOS/tvOS 11.0 and macOS 10.15.

This bumps the version settings in various files and cleans up code that can now assume it's running on a later OS version. For example, it allows us to get rid of a couple `dlsym()` calls in System.Security.Cryptography.Native.Apple.

We can also stop building the iOS arm and iOSSimulator x86 runtime packs since 32bit platforms aren't supported by iOS 11

17 months agoFix scanning `newarr` (#82028)
Michal Strehovský [Mon, 13 Feb 2023 15:05:47 +0000 (00:05 +0900)]
Fix scanning `newarr` (#82028)

Match what we do in JitInterface. Allowing the array to import would later fail when we try to create `IEnumerable<void>`.

17 months agoFix getting typecode of generic parameters restricted to be Enum (#82029)
Michal Strehovský [Mon, 13 Feb 2023 15:04:25 +0000 (00:04 +0900)]
Fix getting typecode of generic parameters restricted to be Enum (#82029)

Found in JIT tests.

17 months ago[coop][interp] Fix GC transitions for thunk invoke wrappers (#81773)
Aleksey Kliger (λgeek) [Mon, 13 Feb 2023 14:36:24 +0000 (09:36 -0500)]
[coop][interp] Fix GC transitions for thunk invoke wrappers (#81773)

The code that recognizes GC transition icalls in the interpreter was only assuming that it will see `mono_threads_enter_gc_safe_region_unbalanced` / `mono_threads_exit_gc_safe_region_unbalanced` which are used by managed-to-native wrappers.

In most cases for native-to-managed wrappers the marshaller emits `mono_threads_attach_coop` / `mono_threads_detach_coop` and those are handled elsewhere by setting the `needs_thread_attach` flag on the `InterpMethod`.

However when the `mono_marshal_get_thunk_invoke_wrapper` API is used, we emit a thunk invoke wrapper which uses
`mono_threads_enter_gc_unsafe_region_unbalanced` / `mono_threads_exit_gc_unsafe_region_unbalanced`

Change the thunk invoke wrapper to also use attach_coop/detach_coop.  This makes the thunks a bit more flexible (they can now be called from unattached threads), at the cost of a TLS lookup.  Also fixes interpreter support since they use the existing attach/detach handling.

As an implementation detail, I added a GC Unsafe Transition Builder to the marshaling code.

Fixes a failure seen in https://github.com/dotnet/runtime/pull/81380 in the MonoAPI/MonoMono/Thunks test (exposed by calling a cctor later than previously)

* Assert that CEE_MONO_GET_SP is followed by gc safe enter/exit icalls

   Only assert in debug builds

* [marshal] Add GCUnsafeTransitionBuilder; use for thunk_invoke_wrapper

Make a "GC Unsafe Transition Builder" - that always calls
mono_threads_attach_coop / mono_threads_detach_coop.

Use it in the native to managed wrappers:
emit_thunk_invoke_wrapper and emit_managed_wrapper

This is a change in behavior for emit_thunk_invoke_wrapper -
previously it directly called mono_threads_enter_gc_unsafe_region_unbalanced.

That means that compared to the previous behavior, the thunk invoke
wrappers are now a bit more lax: they will be able to be called on
threads that aren't attached to the runtime and they will attach
automatically.

On the other hand existing code will continue to work, with the extra
cost of a check of a thread local var.

Using mono_thread_attach_coop also makes invoke wrappers work
correctly in the interpreter - it special cases
mono_thread_attach_coop but not enter_gc_unsafe.

17 months agoConsole.Tests: extend VerifyInstalledTermInfosParse test. (#82025)
Tom Deseyn [Mon, 13 Feb 2023 13:10:06 +0000 (14:10 +0100)]
Console.Tests: extend VerifyInstalledTermInfosParse test. (#82025)

- Run against TERMINFO envvar, and HOME terminfo too.
- Don't stop on first problem, aggregate exceptions.
- Include database file name in the exception.

17 months agoJIT: Relax reg-optionality validity checks (#81614)
Jakob Botsch Nielsen [Mon, 13 Feb 2023 12:45:23 +0000 (13:45 +0100)]
JIT: Relax reg-optionality validity checks (#81614)

JIT: Relax reg-optionality validity checks

This PR does two things:

* Rename the existing IsSafeToContainMem into IsInvariantInRange, and use
  IsInvariantInRange in the places where we are using IsSafeToContainMem today
  as a general-purpose "can move" check. IsSafeToContainMem remains and just
  forwards to IsInvariantInRange. We still use it for the cases where we're
  actually containing a load.

* Relax reg-optionality checking. The checks we have today are much more
  stringent than they need to be, doing a full (and expensive) invariance check.
  Let me copy/paste my comment from the new IsSafeToMarkRegOptional about the
  checking we actually need to do:

Unlike containment, reg-optionality can only rarely introduce new
conflicts, because reg-optionality mostly does not cause the child node
to be evaluated at a new point in time:

1. For LIR edges (i.e. anything that isn't GT_LCL_VAR) reg-optionality
   indicates that if the edge was spilled to a temp at its def, the parent
   node can use it directly from its spill location without reloading it
   into a register first. This is always safe as as spill temps cannot
   interfere.

   For example, an indirection can be marked reg-optional even if there
   is interference between it and its parent; the indirection will still
   be evaluated at its original position, but if the value is spilled to
   stack, then reg-optionality can allow using the value from the spill
   location directly.

2. For GT_LCL_VAR reg-optionality indicates that the node can use the
   local directly from its home location. IR invariants guarantee that the
   local is not defined between its LIR location and the parent node (see
   CheckLclVarSemanticsHelper). That means the only case where it could
   interfere is due to it being address exposed. So this is the only unsafe
   case.

17 months ago[mono] RuntimeHelpers.CreateSpan<T> is now intrinsic. (#81695)
Jan Dupej [Mon, 13 Feb 2023 12:37:33 +0000 (13:37 +0100)]
[mono] RuntimeHelpers.CreateSpan<T> is now intrinsic. (#81695)

* [mono] RuntimeHelpers.CreateSpan is now intrinsic.

* [mono][jit] RuntimeHelpers.CreateSpan intrinsic fixes.

* [mono][jit] RuntimeHelpers.CreateSpan is intrinsic and seems to work.

* [mono] Fixed a warning that broke build.

* [mono] Pointer arithmetic warnings hopefully solved.

* [mono] Fix pointer conversion warning, take 2.

* [mono] RuntimeHelpers.CreateSpan<T> is no longer intrinsic under AOT.

* [mono] RuntimeHelpers.CreateSpan<T> now constructs the result in a safer way.

* [mono][aot] RuntimeHelpers.CreateSpan<T> intrinsic fixed for AOT case.

* [mono] Cleaned up whitespace changes in decompose.c, YAGNI in ir-emit.h.

* [mono] OP_LDTOKEN_FIELD mini opcode introduced for RuntimeHelpers.CreateSpan<T>

* [mono][aot] RuntimeHelpers.CreateSpan<T> intrinsic now emits the correct AOT constant.

* [mono] RuntimeHelpers.CreateSpan intrinsic, removed superfluous sanity checks.

17 months agoTweak NativeAOT repro instructions (#82018)
Austin Wise [Mon, 13 Feb 2023 03:34:57 +0000 (19:34 -0800)]
Tweak NativeAOT repro instructions (#82018)

These work regardless where you copy of dotnet/runtime is checked out.

17 months agoAvoid taking lock for empty bucket in ConcurrentDictionary.TryRemove (#82004)
Stephen Toub [Sun, 12 Feb 2023 23:53:55 +0000 (18:53 -0500)]
Avoid taking lock for empty bucket in ConcurrentDictionary.TryRemove (#82004)

Even when uncontended, the lock represents the most expensive work performed by the method.  We can avoid taking it if we see that the bucket's count is empty.

17 months agoUpdate dependencies from https://github.com/dotnet/roslyn-analyzers build 20230211...
dotnet-maestro[bot] [Sun, 12 Feb 2023 21:36:17 +0000 (16:36 -0500)]
Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230211.1 (#82013)

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23108.2 -> To Version 3.3.5-beta1.23111.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
17 months agoremove test references to archaic Linux versions (#81992)
Tomas Weinfurt [Sun, 12 Feb 2023 21:29:55 +0000 (13:29 -0800)]
remove test references to archaic Linux versions (#81992)

* remove test references to archaic Linux versions

* Fix tests on Nano

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
17 months agoRemove a few char[] allocations from Xml (#82006)
Stephen Toub [Sun, 12 Feb 2023 21:12:37 +0000 (16:12 -0500)]
Remove a few char[] allocations from Xml (#82006)

17 months agoUse span.SplitAny in NetworkInformation.StringParsingHelpers (#82007)
Stephen Toub [Sun, 12 Feb 2023 14:35:10 +0000 (09:35 -0500)]
Use span.SplitAny in NetworkInformation.StringParsingHelpers (#82007)