platform/upstream/dotnet/runtime.git
15 months ago[wasm] WBT: Renable blazor lazy loading test (#85685)
Ankit Jain [Wed, 3 May 2023 01:18:01 +0000 (21:18 -0400)]
[wasm] WBT: Renable blazor lazy loading test (#85685)

.. and fix test to work for non-webcil case.

Fixes issue: https://github.com/dotnet/runtime/issues/85354

15 months agooffers the synchronous part of start and stop in IHostedService to run concurrently...
Badre BSAILA [Wed, 3 May 2023 01:00:40 +0000 (03:00 +0200)]
offers the synchronous part of start and stop in IHostedService to run concurrently (#85191)

* offers the synchronous part of start and stop in IHostedService to run concurrently

* pass cancellation token to Task.Run

* fix cancellation token  issue and eliminate a lambda

15 months ago[wasm] Disable some System.Net.Http.Functional.Tests (#85678)
Ankit Jain [Wed, 3 May 2023 00:58:53 +0000 (20:58 -0400)]
[wasm] Disable some System.Net.Http.Functional.Tests (#85678)

.. for AOT.

https://github.com/dotnet/runtime/issues/71877

15 months agoFix add/edit for generic methods scenario (#85655)
Aaron Robinson [Tue, 2 May 2023 21:37:05 +0000 (14:37 -0700)]
Fix add/edit for generic methods scenario (#85655)

Ensure the canonical MethodTable is always used.

15 months ago[mono] Implement Vector128.Shuffle using tbl1 on arm64. (#85553)
Zoltan Varga [Tue, 2 May 2023 21:04:55 +0000 (23:04 +0200)]
[mono] Implement Vector128.Shuffle using tbl1 on arm64. (#85553)

15 months agoJIT: Fix modelling of exceptions thrown by INDEX_ADDR (#85646)
Jakob Botsch Nielsen [Tue, 2 May 2023 20:28:23 +0000 (22:28 +0200)]
JIT: Fix modelling of exceptions thrown by INDEX_ADDR (#85646)

15 months agoMove assignment rationalization to before the late helper expansion phases (#85585)
SingleAccretion [Tue, 2 May 2023 20:09:53 +0000 (23:09 +0300)]
Move assignment rationalization to before the late helper expansion phases (#85585)

* Flags dump for STOREIND

* gtNewAssignNode assert

* Call morphing

* GenTree::GetLayout fixup

* If Conversion

* Tail duplication

* Costing

* Move assignment rationalization before GC Poll insertion

* Block morphing (part 1)

* Block morphing: switch dst<->src around

* Finish block morphing

* Helper expansion phases

* Fix formatting

15 months agoenable ntlm tests on RHEL7 again (#85633)
Tomas Weinfurt [Tue, 2 May 2023 19:50:39 +0000 (12:50 -0700)]
enable ntlm tests on RHEL7 again (#85633)

15 months ago[wasi] Combine `main` function for the default and single file bundle (#85617)
Ankit Jain [Tue, 2 May 2023 18:39:46 +0000 (14:39 -0400)]
[wasi] Combine `main` function for the default and single file bundle (#85617)

.. case.

This was prompted by https://github.com/dotnet/runtime/issues/85616
where running `Invariant.Tests` breaks with:

```
Running /root/helix/work/correlation/wasmtime/wasmtime --dir=. --env=DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true dotnet.wasm WasmTestRunner managed/Invariant.Tests.dll -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing

Unhandled Exception:
System.ArgumentException: Invalid argument 'managed/Invariant.Tests.dll'.
   at SimpleWasmTestRunner.Main(String[] args)
   at SimpleWasmTestRunner.<Main>(String[] args)
```

- This broke because of a recent change due to which setting
  `InvariantGlobalization=true` meant `WasmBuildNative=true`
- But this did not trigger single file bundle
- And the build ended up relinking a dotnet.wasm but using the
  single-file bundle `main` function.

Instead, we combine the two main functions and switch between the
behavior depending on compile time defines.

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

15 months agoRemove SelfContained from pack (#85636)
Marek Fišera [Tue, 2 May 2023 18:38:27 +0000 (20:38 +0200)]
Remove SelfContained from pack (#85636)

15 months agoImplement ICorProfilerInfo14::GetNonGCHeapBounds (#85434)
Egor Bogatov [Tue, 2 May 2023 18:10:44 +0000 (20:10 +0200)]
Implement ICorProfilerInfo14::GetNonGCHeapBounds (#85434)

15 months ago[main] Update dependencies from dnceng/internal/dotnet-optimization (#85470)
dotnet-maestro[bot] [Tue, 2 May 2023 17:27:38 +0000 (19:27 +0200)]
[main] Update dependencies from dnceng/internal/dotnet-optimization (#85470)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
15 months agoRemove unnecessary dependency in M.Bcl.TimeProvider (#85639)
Viktor Hofer [Tue, 2 May 2023 16:48:09 +0000 (18:48 +0200)]
Remove unnecessary dependency in M.Bcl.TimeProvider (#85639)

see https://github.com/dotnet/runtime/pull/84235/files#r1182370236

15 months agoUpdate dependencies from https://github.com/dotnet/arcade build 20230426.4 (#85459)
dotnet-maestro[bot] [Tue, 2 May 2023 16:39:55 +0000 (18:39 +0200)]
Update dependencies from https://github.com/dotnet/arcade build 20230426.4 (#85459)

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.23224.5 -> To Version 8.0.0-beta.23226.4

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
15 months agoAddress misc feedback for config binder implementation (#84737)
Layomi Akinrinade [Tue, 2 May 2023 15:18:41 +0000 (11:18 -0400)]
Address misc feedback for config binder implementation (#84737)

* Move type graph specs into subfolder

* Address misc feedback for config binder implementation

15 months agoRemove unnecessary dependencies in System.Text.Json (#85640)
Viktor Hofer [Tue, 2 May 2023 14:28:08 +0000 (16:28 +0200)]
Remove unnecessary dependencies in System.Text.Json (#85640)

* Remove unnecessary dependencies in System.Text.Json

The `System.ValueTuple` dependency is already provided in-box in .NET Standard and therefore the down-level applicable package doesn't need to be referenced.

* Update System.Text.Json.csproj

* Update Versions.props

15 months ago[JIT] X64 Fix - Handle 'imul' instruction variants to determine if a register was...
Will Smith [Tue, 2 May 2023 14:22:58 +0000 (07:22 -0700)]
[JIT] X64 Fix - Handle 'imul' instruction variants to determine if a register was written to (#85610)

15 months ago[mono][debugger] Support step over and pause multiple times in same line but differen...
Thays Grazia [Tue, 2 May 2023 12:51:17 +0000 (09:51 -0300)]
[mono][debugger] Support step over and pause multiple times in same line but different columns (#85484)

* Support step over and pause multiple times in a like like this: for (int i = 0; i < 10; i++)

* Fix name on wasm code.

* Adding support to new message MDBGPROT_CMD_STACK_FRAME_GET_COUNT

* Changing position of create_file_to_check_memory_address function

* Adding another command   MDBGPROT_CMD_STACK_FRAME_GET_PARAMETERS_COUNT

* Fix arguments count

15 months agoEnsure zroSimd12Elm3 is explicitly nulled out (#85625)
Tanner Gooding [Tue, 2 May 2023 11:34:35 +0000 (04:34 -0700)]
Ensure zroSimd12Elm3 is explicitly nulled out (#85625)

15 months agoComWrappers test that allocate object can't inline (#85583)
Aaron Robinson [Tue, 2 May 2023 10:35:24 +0000 (03:35 -0700)]
ComWrappers test that allocate object can't inline (#85583)

* ComWrappers test that allocate object can't inline

There are some JIT stress settings that aggressively
inline functions, regardless of size/complexity. This
inlining can perturb the subtle GC assumptions
inherent in the COM wrappers tests.

15 months agoJIT: Prefer block copies for unenregisterable locals even with GC pointers (#85620)
Jakob Botsch Nielsen [Tue, 2 May 2023 10:29:09 +0000 (12:29 +0200)]
JIT: Prefer block copies for unenregisterable locals even with GC pointers (#85620)

This comment seems outdated/wrong, the backend's block copy strategy
when GC pointers are involved is highly tuned and often no helper is
necessary at all.

15 months ago[mono][jit] ArmBase methods are now intrinsic. (#85458)
Jan Dupej [Tue, 2 May 2023 09:19:46 +0000 (11:19 +0200)]
[mono][jit] ArmBase methods are now intrinsic. (#85458)

* ArmBase methods are now intrinsic.

* Arm.Yield maps to a NOP.

* Adding hint operation for arm64's yield.

15 months agoAllow emitting function pointers in TypeSystemMetadataEmitter (#85626)
Michal Strehovský [Tue, 2 May 2023 06:41:32 +0000 (15:41 +0900)]
Allow emitting function pointers in TypeSystemMetadataEmitter (#85626)

This is handled. It's unclear to me why it was disallowed.

Unfortunately, this means `IlcGenerateMstatFile` is going to be completely broken in .NET 8 Preview 4.

15 months agoMake generic composition information more efficient (#85623)
Michal Strehovský [Tue, 2 May 2023 06:40:30 +0000 (15:40 +0900)]
Make generic composition information more efficient (#85623)

Before this PR, we tracked information about generic composition of a `MethodTable` this way:

* Each generic instance `MethodTable` had a pointer to the generic definition `MethodTable`.
* Each generic instance `MethodTable` had a pointer to its generic composition: a variable sized data structure that had a small header (number of elements, a flag whether it's variant), followed by pointers to `MethodTable`s of components, optionally followed by variance information for each argument.

This works, but it's not particularly efficient, especially in light of some facts that didn't exist at the time this scheme was introduced.

In particular:

* The number of generic parameters can be obtained from the generic definition, no need to duplicate it into instances.
* The variance information can be obtained from the generic definition, no need to duplicate it into instances.
* It makes no sense to indirect to a single-element list - the list can be bypassed if arity is 1.

This PR addresses all of the above.

Saves about 0.5% in size for BasicMinimalApi, improves startup (the composition no longer needs to be dehydrated because it's relative pointers now), and improves working set (the composition stuff accounted for 100 kB of private dehydrated working set in BasicMinimalApi).

15 months agoFix new warnings found with CA1854 improvement. (#85613)
Buyaa Namnan [Tue, 2 May 2023 04:25:00 +0000 (21:25 -0700)]
Fix new warnings found with CA1854 improvement. (#85613)

* Fix new warnings found with CA1854 improvement

15 months agoFix Helix command lines error code handling (#85622)
Bruce Forstall [Tue, 2 May 2023 04:13:17 +0000 (21:13 -0700)]
Fix Helix command lines error code handling (#85622)

The `HelixCommandLines` group must not call `exit` on the script
or the HelixPostCommands and potentially other injected commands
will not run.

Instead, figure out what the exit code should be, and set it properly
(as `ERRORLEVEL` on Windows or `$?` on non-Windows).

Fixes #85621

15 months agoCleanup some xarch emit logic (#85536)
Tanner Gooding [Tue, 2 May 2023 00:34:35 +0000 (17:34 -0700)]
Cleanup some xarch emit logic (#85536)

* Ensure floating-point codegen uses the VEX aware path

* Fix `IF_RRW_RRW_CNS` to be `IF_RWR_RRD_CNS`

* Fixup emitfmtsxarch.h to have a more consistent layout

* Allow querying the scheduling info for an insFormat

* Ensure the new insFormats are handled

* Ensure we consistently use `emitInsModeFormat`

* Ensure instructions which write to a mask register are EVEX only

* Improve REX.W handling for EVEX only instructions

* Ensure that instructions use the right update mode and tuple type

* Apply formatting patch

* Ensure DstSrcSrc is still handled correctly

* Ensure BLSI/BLSR are still handled in emitOutputAM

* Use static_assert_no_msg

* Fixing the disassembly for IF_RRW_SHF

* Fixing the IF check for shld/shrd on x86

* Use the correct name: inst_RV_TT_IV

* Ensure the 4 operand insFormats include the necessary constant

* Resolve an insFormat check on x86

* Ensure other SIMD code paths are VEX aware

* Improve throughput by using a less expensive emitSizeOfInsDsc

* Apply formatting patch

* Ensure emitSizeOfInsDsc_CNS is used for RWR_RRD_*RD_CNS

* Ensure genSimd12UpperClear uses `andps` for the pre-SSE4.1 path

15 months agoDependencyGraphViewer: Fix catastrophic designer fail for NodeForm (#84539)
Mitch Capper (they, them) [Mon, 1 May 2023 22:42:06 +0000 (15:42 -0700)]
DependencyGraphViewer: Fix catastrophic designer fail for NodeForm (#84539)

Fixes experimental designer failure due to having multiple classes in
NodeForm.cs.

Fixes #84538

15 months agoSupport encoding `TypedReference`s in signatures. (#85360)
Theodore Tsirpanis [Mon, 1 May 2023 22:26:58 +0000 (01:26 +0300)]
Support encoding `TypedReference`s in signatures. (#85360)

* Add `SignatureTypeEncoder.TypedReference`.

* Stop failing when encoding a `PrimitiveTypeCode.TypedReference`.
Since we have a dedicated method for typed references, there is no reason to prohibit it.

* Update the documentation of `SignatureTypeEncoder`.

Co-authored-by: Buyaa Namnan <buyankhishig.namnan@microsoft.com>
15 months agoRemove a RequiresProcessIsolation which is not required. (#85606)
Zoltan Varga [Mon, 1 May 2023 22:14:38 +0000 (00:14 +0200)]
Remove a RequiresProcessIsolation which is not required. (#85606)

15 months agoFix typo in SafeHandle.cs (#85607)
Edouard Choinière [Mon, 1 May 2023 21:33:58 +0000 (17:33 -0400)]
Fix typo in SafeHandle.cs (#85607)

Fixes #85593
Change `providng` to `providing` in a comment.

15 months agoSave interfaces implementations and nested types (#85596)
Buyaa Namnan [Mon, 1 May 2023 20:52:13 +0000 (13:52 -0700)]
Save interfaces implementations and nested types (#85596)

* Save interfaces implemented and nested type

15 months agoNativeAOT instruction for NixOS (#81485)
WhiteBlackGoose [Mon, 1 May 2023 20:30:06 +0000 (22:30 +0200)]
NativeAOT instruction for NixOS (#81485)

* NativeAOT instruction for NixOS

* Update compiling.md

* Reworded

* Update src/coreclr/nativeaot/docs/compiling.md

---------

Co-authored-by: Andy Gocke <angocke@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
15 months agoEnsure that IF_*WR_RRD formats support 4-byte SIMD instructions (#85594)
Tanner Gooding [Mon, 1 May 2023 20:22:55 +0000 (13:22 -0700)]
Ensure that IF_*WR_RRD formats support 4-byte SIMD instructions (#85594)

* Ensure that IF_*WR_RRD formats support 4-byte SIMD instructions

* Apply formatting patch

15 months agoCompare host using OrdinalIgnoreCase instead of InvariantCultureIgnoreCase (#85574)
Gérald Barré [Mon, 1 May 2023 19:43:38 +0000 (15:43 -0400)]
Compare host using OrdinalIgnoreCase instead of InvariantCultureIgnoreCase (#85574)

15 months agoJIT: one phi arg per pred (#85546)
Andy Ayers [Mon, 1 May 2023 18:56:14 +0000 (11:56 -0700)]
JIT: one phi arg per pred (#85546)

Revise SSA to add one phi arg per pred instead of one phi arg per ssa def.
This unlocks some cases for redundant branch opts.

In some pathological cases we may see extremely long phi arg lists. Will
keep an eye out for that and perhaps modify the strategy if we end up
with hundreds or thousands of phi args.

Addresses an issue noted in #48115.

15 months agoReenable a test which doesn't seem to fail any more. (#85576)
Zoltan Varga [Mon, 1 May 2023 18:34:58 +0000 (20:34 +0200)]
Reenable a test which doesn't seem to fail any more. (#85576)

Re: https://github.com/dotnet/runtime/pull/82663.

15 months agoUpdate dependencies from https://github.com/dotnet/roslyn build 20230426.15 (#85460)
dotnet-maestro[bot] [Mon, 1 May 2023 18:20:45 +0000 (13:20 -0500)]
Update dependencies from https://github.com/dotnet/roslyn build 20230426.15 (#85460)

15 months agoSet lvSingleDef for non TYP_REF locals (#85398)
Michał Petryka [Mon, 1 May 2023 17:54:00 +0000 (19:54 +0200)]
Set lvSingleDef for non TYP_REF locals (#85398)

* Set lvSingleDef for non TYP_REF locals

* Apply suggestions from code review

Co-authored-by: Andy Ayers <andya@microsoft.com>
* Rewrite an if

---------

Co-authored-by: Andy Ayers <andya@microsoft.com>
15 months agoFix trimmability issues in Quic test (#85579)
Michal Strehovský [Mon, 1 May 2023 16:58:14 +0000 (01:58 +0900)]
Fix trimmability issues in Quic test (#85579)

15 months agoEnable regex to use IndexOf(..., OrdinalIgnoreCase) for prefix searching (#85438)
Stephen Toub [Mon, 1 May 2023 16:56:20 +0000 (12:56 -0400)]
Enable regex to use IndexOf(..., OrdinalIgnoreCase) for prefix searching (#85438)

As one of its many ways of finding the next possible match starting location, Regex recognizes a string known to start the expression and uses IndexOf to find it.  With this change, it can also do so for OrdinalIgnoreCase.  With improvements to IndexOf(..., OrdinalIgnoreCase), this now yields significantly faster searches through longer inputs, in addition to leading to simpler code in source generated regexes.

15 months agofix: Change severity for SYSLIB1006 to Info instead of warning (#85581)
Shreyas Jejurkar [Mon, 1 May 2023 15:45:46 +0000 (21:15 +0530)]
fix: Change severity for SYSLIB1006 to Info instead of warning (#85581)

15 months agoRevert "[mono][llvm] Enable the cold calling conv on osx/linux. (#83519)" (#85554)
Zoltan Varga [Mon, 1 May 2023 15:42:23 +0000 (17:42 +0200)]
Revert "[mono][llvm] Enable the cold calling conv on osx/linux. (#83519)" (#85554)

This reverts commit a2acc6c6529fc25ed350b239efe459b08b0310a6.

Revert this as it causes an assert on osx.

15 months agoImprove vectorization of IndexOf(chars, StringComparison.OrdinalIgnoreCase) (#85437)
Stephen Toub [Mon, 1 May 2023 14:36:52 +0000 (10:36 -0400)]
Improve vectorization of IndexOf(chars, StringComparison.OrdinalIgnoreCase) (#85437)

* Improve vectorization of IndexOf(chars, StringComparison.OrdinalIgnoreCase)

Use the same general "Algorithm 1: Generic SIMD" that we do for StringComparison.Ordinal, adapter for OrdinalIgnoreCase.

* Fix duplicate local

15 months agoDo not set pre-decided consecutive registers as busy (again) (#85566)
Kunal Pathak [Mon, 1 May 2023 12:29:50 +0000 (05:29 -0700)]
Do not set pre-decided consecutive registers as busy (again) (#85566)

15 months agoFix processing of x86 test results (#82301)
SwapnilGaikwad [Mon, 1 May 2023 12:29:28 +0000 (13:29 +0100)]
Fix processing of x86 test results (#82301)

15 months agoRemove cached Type instances (#85557)
Huo Yaoyuan [Mon, 1 May 2023 11:57:34 +0000 (19:57 +0800)]
Remove cached Type instances (#85557)

* Remove the Type cache in Convert

* Remove Type cache in MaskedTextProvider

* Remove Type cache in DataSetUtil

* Remove Type cache in ResourceManager

* Remove Type cache in XmlBinaryReader

* Remove Type cache in XsltConvert

* Remove Type cache in DataTypeImplementation

* Introduce a local variable for typeof(string)

15 months agoTranslate AV in RhpByRefAssignRef to NullReferenceException (#85575)
Michal Strehovský [Mon, 1 May 2023 11:56:46 +0000 (20:56 +0900)]
Translate AV in RhpByRefAssignRef to NullReferenceException (#85575)

Fixes dotnet/runtimelab#197.

Ran into this again when curiosity made my try a newly added JIT test with NativeAOT.

15 months ago[mono][aot] Refactor deduplication to use enum instead of flags (#85384)
Milos Kotlar [Mon, 1 May 2023 11:36:32 +0000 (14:36 +0300)]
[mono][aot] Refactor deduplication to use enum instead of flags (#85384)

* Use enum instead of multiple dedup flags

15 months agoDelete finally blocks in EcmaSignatureParser (#85577)
Michal Strehovský [Mon, 1 May 2023 10:17:01 +0000 (19:17 +0900)]
Delete finally blocks in EcmaSignatureParser (#85577)

These lightweight structs are not meant to be reusable.

15 months agoEmission and reading of custom modifiers (#85504)
Michal Strehovský [Mon, 1 May 2023 10:16:39 +0000 (19:16 +0900)]
Emission and reading of custom modifiers (#85504)

Fixes #71883.

* Emit custom modifiers to the native metadata format
* Read custom modifiers at runtime
* Bugfix in the type loader

15 months agoSplit assignment rationalization into a separate phase (#85180)
SingleAccretion [Mon, 1 May 2023 10:04:12 +0000 (13:04 +0300)]
Split assignment rationalization into a separate phase (#85180)

* General IR support

* Introduce GTK_STORE

And make "OperIsStore" means exactly these opers:
 GT_STORE_LCL_VAR
 GT_STORE_LCL_FLD
 GT_STOREIND
 GT_STORE_BLK

Notable: GT_STORE_DYN_BLK is excluded as it does
not follow conventions of all other stores (e. g.
is VOID-typed) and acts more like opaque atomic
operations instead.

Also fix an old bug with gtNodeHasSideEffects.

* Fix OperExceptions

* Introduce and use gtNewStoreLclFldNode

* gtNewStoreLclVar -> gtNewStoreLclVarNode

* Use OperIsAnyLocal in more places

* Introduce ASG rationalization phase

* Introduce switch for stress-morphing

* Fix formatting

15 months agoJIT: Make optAssertionPropGlobal_RelOp less conservative for side-effects (#85532)
Egor Bogatov [Mon, 1 May 2023 08:37:51 +0000 (10:37 +0200)]
JIT: Make optAssertionPropGlobal_RelOp less conservative for side-effects (#85532)

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
15 months agoDelete more type equivalence logic (#85507)
Michal Strehovský [Mon, 1 May 2023 04:40:42 +0000 (13:40 +0900)]
Delete more type equivalence logic (#85507)

* Delete more type equivalence logic

In .NET Native times we could have a situation where two different `MethodTable` pointers represented the same type. This could happen for cloned types, or structurally equivalent parameterized types. The cloned type concept was never used in Native AOT. The structural equivalence disappeared in https://github.com/dotnet/runtimelab/commit/0ef7bd6cfe129f4c308f5d6dae1eccf48c3cdff4. Neither of those seems useful. So getting rid of some of the vestiges.

* Delete more stuff

* Remember statically present pointer and mdarrays

15 months agoDelete `arrayArgumentsFound` logic from type loader (#85509)
Michal Strehovský [Mon, 1 May 2023 04:39:37 +0000 (13:39 +0900)]
Delete `arrayArgumentsFound` logic from type loader (#85509)

I think this was handling a situation where we're trying to find an existing `MethodTable` for `Foo<SomeType[]>` and such `MethodTable` does statically exist but we didn't have a mapping table entry for `SomeType[]` and we couldn't get a `MethodTable` for it, even though it statically exists in the image. Since the compiler optimization to skip emitting this mapping got commented out, it wasn't actually possible to end up in a situation where we wouldn't know how to find a `MethodTable` for an existing array at runtime. We therefore don't need the slow path that tries to find the type without having `MethodTable`s for all generic arguments.

15 months agoReplace InvariantCulture comparison with Ordinal (#85572)
Gérald Barré [Sun, 30 Apr 2023 23:12:57 +0000 (19:12 -0400)]
Replace InvariantCulture comparison with Ordinal (#85572)

15 months agoReduce overheads of Regex.Replace with a text replacement string (#85564)
Stephen Toub [Sun, 30 Apr 2023 22:59:34 +0000 (18:59 -0400)]
Reduce overheads of Regex.Replace with a text replacement string (#85564)

* Reduce overheads of Regex.Replace with a text replacement string

If the replacement string doesn't contain any backreferences, we can reduce the overheads involved in processing the replacement.  Rather than storing a list of `ReadOnlyMemory<char>` segments for every portion of the original string or replacement, we can just store a list of `(int offset, int count)` pairs; if the offset is non-negative it refers to the original string, and if it's negative, it means to use the whole replacement.  We can also avoid evaluating the rules each time, and since we're not storing string references into the arrays, we don't need to clear the arrays before returning them to the pool.

* Replace builders with more generic StructListBuilder

15 months agoDelete `OBJ(LCL_ADDR)` args handling from local morph ref counting (#85544)
SingleAccretion [Sun, 30 Apr 2023 18:17:41 +0000 (21:17 +0300)]
Delete `OBJ(LCL_ADDR)` args handling from local morph ref counting (#85544)

* Delete OBJ args handling from local morph

* Delete outdated comments

15 months agoFix/31527 invalid currentculture applying (#85297)
Maksim Golev [Sun, 30 Apr 2023 16:58:26 +0000 (20:58 +0400)]
Fix/31527 invalid currentculture applying (#85297)

Co-authored-by: Maksim Golev <mgolev@htc-cs.ru>
15 months agoSimplify some importer code (#84656)
SingleAccretion [Sat, 29 Apr 2023 20:32:21 +0000 (23:32 +0300)]
Simplify some importer code (#84656)

15 months ago[LoongArch64] fix the errors when reverse GT_JCC. (#85555)
Qiao Pengcheng [Sat, 29 Apr 2023 16:36:15 +0000 (00:36 +0800)]
[LoongArch64] fix the errors when reverse GT_JCC. (#85555)

* [LoongArch64] fix the errors when reverse GT_JCC.

* just modify the LA64's files for CRs.

15 months ago[mono][jit] Emit a null check when storing to valuetype fields. (#82663)
Zoltan Varga [Sat, 29 Apr 2023 04:23:29 +0000 (06:23 +0200)]
[mono][jit] Emit a null check when storing to valuetype fields. (#82663)

* [mono][jit] Emit a null check when storing to valuetype fields.

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

* Add a test.

* Disable the test on coreclr.

15 months agoFix volatility checks in VN and loop side effects code (#85467)
SingleAccretion [Fri, 28 Apr 2023 22:02:43 +0000 (01:02 +0300)]
Fix volatility checks in VN and loop side effects code (#85467)

* Fix volatile check in loop side effects code

* Restore the volatility logic in VN

Volatile stores should be processed at the point of ASG.

15 months agoJIT: enhance SSA checker to check some PHI properties (#85533)
Andy Ayers [Fri, 28 Apr 2023 21:26:09 +0000 (14:26 -0700)]
JIT: enhance SSA checker to check some PHI properties (#85533)

* Ensure PhiArgs have the right local number.
* Ensure PhiArgs have unique `gtPredBB` (for most blocks)
* Verify phidef/non-phidef order

Handler entries may have multiple PhiArgs with the same `gtPredBB`. This
is by design, to model exceptional flow from the middle of the block to a
handler.

Jump threading relies on there being just a single PhiArg per pred.
So exclude handler entry blocks from jump threading.

Prep work for possibly changing SSA to produce one PhiArg per pred, instead
of one PhiArg per ssa def.

15 months agoFix exception leaking from filter in nativeAOT (#85366)
Jan Vorlicek [Fri, 28 Apr 2023 21:12:27 +0000 (23:12 +0200)]
Fix exception leaking from filter in nativeAOT (#85366)

* Fix exception leaking from filter in nativeAOT

There is a bug in handling exceptions that occur in exception filters in
nativeAOT. If such exception is not handled in the filter, it needs to
be swallowed and the filter should behave as if it returned `false`.
Instead of that, the current behavior is that debug build of the runtime
asserts and the release build fails fast without any message.

This change fixes it by catching the exception in the exception handling
code. It was also necessary to modify the stack frame iterator to let it
unwind past the filter funclet instead of failing fast.

* Reenable tests disabled due to the issue

15 months agoFix XUnit Log Fixer Irregularities (#85183)
Ivan Diaz Sanchez [Fri, 28 Apr 2023 20:39:49 +0000 (13:39 -0700)]
Fix XUnit Log Fixer Irregularities (#85183)

* Fixed the log tags regular expressions.

* Added test exit code to the XUnit Log Checker, and made it return it as well for Helix to process it.

* Finished fixes.

* Decoupled the test's exit code from the XUnit Log Checker.

15 months agoAdd documentation for merge on red, build analysis, and v1/v2 tests (#84982)
Juan Hoyos [Fri, 28 Apr 2023 20:39:16 +0000 (13:39 -0700)]
Add documentation for merge on red, build analysis, and v1/v2 tests (#84982)

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
15 months ago[wasm-mt] Support async JS interop on threadpool threads (#84494)
Aleksey Kliger (λgeek) [Fri, 28 Apr 2023 19:54:14 +0000 (15:54 -0400)]
[wasm-mt] Support async JS interop on threadpool threads (#84494)

This is the last part of #84489 - initial runtime support for async JS interop on threadpool threads in multi-threaded WebAssembly.

Conceptually there are a few things here:

* A mechanism for the native runtime to start some threads as "exitable" so that we don't clean up when they return from their thread start function. (we will clean up when the pthreads TLS dtor runs)
* A change to make JSHostImplementation.s_csOwnedObjects a thread-static in multithreaded builds. This is because the map keys on a small integer handle that is allocated per-thread on the JS side as a handle for JS objects that are to be kept alive because managed code depends on them. (This is needed in general, but also makes the new smoke test work)
* A version of the PortableThreadPool.WorkerThread that starts as an exitable thread and uses asynchronous callbacks to wait for available threadpool work items and returns to the JS event loop periodically in order to allow JS promises to settle.
* A smoke test that does a background JS fetch and some async callbacks on it.

---

* [wasm-mt] Enable JSInterop on threadpool workers

   Implement PortableThreadPool loop using semaphore callbacks

   manage emscripten event loop from PortableThreadPool.WorkerThread

   make sure to keep the thread alive after setting up the semaphore wait.
   Cleanup the thread when exiting

   minimal sample - fetch on a background thread works

   Add WebWorkerEventLoop internal class to managed event loop keepalive

   Start threadpool threads with keepalive checks

   Add a flag to mono's thread start wrappers to keep track of threads that may not want cleanup to run after the Start function returns.

   Use the flag when starting threadpool threads.

   make minimal FetchBackground sample more like a unit test

   Set WorkerThread.IsIOPending when the current thread has unsettled JS interop promises.

   When IsIOPending is true, the worker will not exit even if it has no more work to do.  Instead it will repeatedly wait for more work to arrive or for all promises to settle.

   change minimal sample's fetch helper to artificially delay

   the delay is longer that the threadpool worker's semaphore timeout, in order to validate that the worker stays alive while there are unsettled promises

* [wasm-mt] Add background interop to smoketest

* update to use the LowLevelLifoAsyncWaitSemaphore

* adjust to renamed PortableThreadPool helper methods

* adjust to renamed WebWorkerEventLoop.HasJavaScriptInteropDependents

* extend and rationalize the smoke test a bit

   Add a test that just starts a thread and asserts that it has a different thread ID than the main thread.  This should allow us to rule out accidentally having the test pass on a single-threaded runtime

* hide some debug output

* smoke test: dispose of the ImportAsync result after the task is done

* [wasm-mt] make JSHostImplementation.s_csOwnedObjects ThreadStatic

   The integer jsHandles are not global - they are essentially indices into a JS array. So the mapping from a jsHandle to a JSObject must be per-thread.

   This fixes the thread affinity assertions in the smoketest (which were false positives - we looked up a worker's jsHandle and got back the main thread's JSObject - and then asserted that it was accessed from the wrong thread)

* remove locking on JSHostImplementation.CsOwnedObjects

   In single-threaded wasm, there is no need to lock since there is only one caller at a time.

   In multi-threaded wasm, the underlying dictionary is thread-static

* [threads] make the "external eventloop" platform independent

   It only does something on WASM, but in principle if other platforms allow us to run some code after returning from a thread start function, we could do it there, too.

* Add a Thread.HasExternalEventLoop managed property

   Set it from WebWorkerEventLoop.StartExitable.
   In native code, use it to set the `MONO_THREAD_CREATE_FLAGS_EXTERNAL_EVENTLOOP` flag when starting the thread.

* rename JSHostImplementation.ThreadCsOwnedObjects

   (used to be CsOwnedObjects)

   Rename to make it clear that it's objects owned by the current thread, not the runtime globally

* [checked] assert GC Safe mode, when returning to external eventloop

15 months agoSkip methods in test-merging if they use the named argument 'Skip' for the Fact attri...
Will Smith [Fri, 28 Apr 2023 19:22:08 +0000 (12:22 -0700)]
Skip methods in test-merging if they use the named argument 'Skip' for the Fact attributes (#85495)

* Skip methods in test-merging if they use the named argument 'Skip'

* Use ActiveIssueAttribute instead of FactAttribute with Skip. Add documentation about FactAttribute and Skip.

15 months ago[Mono] Intrinsify Vector128.Create on Arm64 for mini JIT (#85404)
Fan Yang [Fri, 28 Apr 2023 19:13:57 +0000 (15:13 -0400)]
[Mono] Intrinsify Vector128.Create on Arm64 for mini JIT (#85404)

* Intrinsify Vector128.Create

* Hopefully fix the test failure

* Increase maximal instruction length

15 months ago[mono][llvm] Assert on unhandled opcodes instead of falling back to the mini JIT...
Zoltan Varga [Fri, 28 Apr 2023 19:05:13 +0000 (21:05 +0200)]
[mono][llvm] Assert on unhandled opcodes instead of falling back to the mini JIT. (#85454)

15 months agoRemove redundant dictionary lookup in XPathDocument (#85534)
Stephen Toub [Fri, 28 Apr 2023 18:50:39 +0000 (14:50 -0400)]
Remove redundant dictionary lookup in XPathDocument (#85534)

15 months agoRemove Base64 value length limit from Utf8JsonWriter (#85334)
Stephen Toub [Fri, 28 Apr 2023 18:50:25 +0000 (14:50 -0400)]
Remove Base64 value length limit from Utf8JsonWriter (#85334)

* Remove Base64 value length limit from Utf8JsonWriter

* Address PR feedback by adding some more asserts

15 months agoAbstract out ParameterBuilder and implement it (#85446)
Buyaa Namnan [Fri, 28 Apr 2023 17:43:06 +0000 (10:43 -0700)]
Abstract out ParameterBuilder and implement it (#85446)

* Save parameters into assembly and test it

* Add MarshalAs pseduo attribute handling and other refactoring

* Apply suggestions from code review

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

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
15 months agoReduce some collection sizes in the System.Collections.Immutable tests. (#85508)
Zoltan Varga [Fri, 28 Apr 2023 16:46:56 +0000 (18:46 +0200)]
Reduce some collection sizes in the System.Collections.Immutable tests. (#85508)

The previous sizes caused timeouts when running on wasm+interpreter on CI.

15 months agoAdd ImmutableCollectionsMarshal type and AsImmutableArray/AsArray APIs (#85526)
Sergio Pedri [Fri, 28 Apr 2023 16:38:49 +0000 (09:38 -0700)]
Add ImmutableCollectionsMarshal type and AsImmutableArray/AsArray APIs (#85526)

* Add ImmutableCollectionsMarshal type

* Add ImmutableCollectionsMarshal to ref assembly

* Add ImmutableCollectionsMarshal unit tests

* Use ImmutableCollectionsMarshal in System.Reflection.Metadata

* Remove ImmutableArrayFactory and use new API

* Leverage internal members in ImmutableCollectionsMarshal

* Remove leftover unsafe modifier in ImmutableCollectionsMarshal

15 months agoUpdate dependencies from https://github.com/dotnet/xharness build 20230428.3 (#85519)
dotnet-maestro[bot] [Fri, 28 Apr 2023 16:36:32 +0000 (12:36 -0400)]
Update dependencies from https://github.com/dotnet/xharness build 20230428.3 (#85519)

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

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
15 months ago[wasm] PackedSimd, add comparison methods (#85512)
Radek Doulik [Fri, 28 Apr 2023 16:31:45 +0000 (18:31 +0200)]
[wasm] PackedSimd, add comparison methods (#85512)

15 months ago[mono] Invoke AssemblyLoad hooks from RuntimeAssemblyBuilder:.ctor () instead from...
Zoltan Varga [Fri, 28 Apr 2023 16:22:19 +0000 (18:22 +0200)]
[mono] Invoke AssemblyLoad hooks from RuntimeAssemblyBuilder:.ctor () instead from native code. (#85307)

The call from native code is made before the manifest module was created, causing errors if the
hook tried to access Assembly.ManifestModule.

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

15 months ago[browser] cleanup of early startup code (#83411)
Pavel Savara [Fri, 28 Apr 2023 15:37:47 +0000 (17:37 +0200)]
[browser] cleanup of early startup code (#83411)

15 months agoMake preinitialized delegates reflection-visible (#85506)
Michal Strehovský [Fri, 28 Apr 2023 13:53:53 +0000 (22:53 +0900)]
Make preinitialized delegates reflection-visible (#85506)

Frozen delegate instances were bypassing the callback to metadata manager that lets metadata manager inject reflection dependencies on delegate construction. Introduce a spot for the callback.

Fixes dotnet/aspnetcore#47941.

15 months ago[NativeAOT] Use 8.1 atomics, if available, in RhpCheckedXchg/RhpCheckedLockCmpXchg...
Vladimir Sadov [Fri, 28 Apr 2023 13:33:49 +0000 (06:33 -0700)]
[NativeAOT] Use 8.1 atomics, if available, in RhpCheckedXchg/RhpCheckedLockCmpXchg (#85283)

* use atomics when available

* exch win

* conditional atomics

* moving ARM64_ATOMICS_FEATURE_FLAG_BIT to AsmOffsets.h and adding a static assert.

* enable lse locally in the asm helpers

15 months ago[NativeAOT] Allow reverse pinvoke in DoNotTriggerGc thread state regardless of coop...
Vladimir Sadov [Fri, 28 Apr 2023 13:32:49 +0000 (06:32 -0700)]
[NativeAOT] Allow reverse pinvoke in DoNotTriggerGc thread state regardless of coop mode. (#85435)

* Allow reverse pinvoke in DoNotTriggerGc thread state regardless of coop mode.

* do not attach DoNotTriggerGc threads in reverse pinvoke

* propagate useful msbuild arguments to the build

* more PR feedback.

* a nit - more consistent formatting

* Do not pass through StripSymbols

15 months agoJIT: ARR_LENGTH(new T[CNS]) --> CNS (#85496)
Egor Bogatov [Fri, 28 Apr 2023 13:10:42 +0000 (15:10 +0200)]
JIT: ARR_LENGTH(new T[CNS]) --> CNS (#85496)

15 months agoUpdate dependencies from https://github.com/dotnet/xharness build 20230428.2 (#85513)
dotnet-maestro[bot] [Fri, 28 Apr 2023 12:56:20 +0000 (12:56 +0000)]
Update dependencies from https://github.com/dotnet/xharness build 20230428.2 (#85513)

[main] Update dependencies from dotnet/xharness

15 months ago[mono][tests] Enable runtime tests for local aliasing on Mono Interpreter (#85250)
Milos Kotlar [Fri, 28 Apr 2023 10:42:00 +0000 (12:42 +0200)]
[mono][tests] Enable runtime tests for local aliasing on Mono Interpreter (#85250)

* Enable runtime tests when a local can be modified indirectly

* Split the test project into two

* Disable test in issues.targets

15 months ago[browser] Expanding timeouts for long running test projects (#85313)
Pavel Savara [Fri, 28 Apr 2023 09:13:18 +0000 (11:13 +0200)]
[browser] Expanding timeouts for long running test projects (#85313)

15 months ago[HTTP/3] Stress hack for msquic dropping connections (#84793)
Marie Píchová [Fri, 28 Apr 2023 08:37:08 +0000 (10:37 +0200)]
[HTTP/3] Stress hack for msquic dropping connections (#84793)

* Implement the same hack as for functional tests to prevent msquic from dropping connections

* Feedback: removed code sharing and used reflaction

* Try to fix missing build dependency

* Feedback - removed test only function and replaced with shared code + some reflection

* fix argument handling in build-local.ps1

* do not use MsQuicLibraryVersion

* copy msquic interop utils to the SDK base image

* use LinkBase in Functional.Tests.csproj for wildcard include

* Use MsQuicLibraryVersion in out internal logging and as a side-effect avoid the property being trimmed

* Comment

* also copy files to the Linux container

---------

Co-authored-by: antonfirsov <antonfir@gmail.com>
15 months agoComment out support for mtag extension in libunwind (#85474)
Vladimir Sadov [Fri, 28 Apr 2023 04:10:17 +0000 (21:10 -0700)]
Comment out support for mtag extension in libunwind (#85474)

Works around build breaks with some compiler versions.

Fixes https://github.com/dotnet/source-build/issues/3424

* added a commit reference to libunwind-version.txt

* move commit to the right file

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
15 months agoDisable crossgen on riscv64 (#85499)
Adeel Mujahid [Fri, 28 Apr 2023 04:08:03 +0000 (07:08 +0300)]
Disable crossgen on riscv64 (#85499)

15 months agoAdd better fix for UnhandledExceptionHandlerUnix (#85497)
Adeel Mujahid [Fri, 28 Apr 2023 04:05:50 +0000 (07:05 +0300)]
Add better fix for UnhandledExceptionHandlerUnix (#85497)

15 months agoEnable AVX-512 for block unrollings (both copying and zeroing) (#85389)
Egor Bogatov [Thu, 27 Apr 2023 23:47:58 +0000 (01:47 +0200)]
Enable AVX-512 for block unrollings (both copying and zeroing) (#85389)

15 months ago[PERF] Add Android BenchmarkDotNet test (#85282)
Parker Bibus [Thu, 27 Apr 2023 22:53:57 +0000 (15:53 -0700)]
[PERF] Add Android BenchmarkDotNet test (#85282)

* Setup testing and add missing depends on.
Shift perflab dependencies to the app build through insertion rather than being in the Maui repo.
Add PERFLAB_INLAB preprocessor constant to include the environment variables section of the Maui app in the build.
Switch to using the main branch of the perf repo.
Hardcoded in the output path to avoid unused variable error when building the Maui App.
* Print runtime pack locations after updating the locations to allow verification of correct package usage.
* Up timeout time for the BDN app test as they take a little bit of time.

15 months agoTry to fix _MergedWrapperMarker (#85476)
Bruce Forstall [Thu, 27 Apr 2023 22:51:07 +0000 (15:51 -0700)]
Try to fix _MergedWrapperMarker (#85476)

Don't include markers without execution scripts

15 months agoFix createdump arg parsing for signal-based exceptions (#85422)
Juan Hoyos [Thu, 27 Apr 2023 22:06:22 +0000 (15:06 -0700)]
Fix createdump arg parsing for signal-based exceptions (#85422)

15 months ago[wasm] GenerateWasmBootJson - close file handles (#85480)
Ankit Jain [Thu, 27 Apr 2023 22:03:58 +0000 (18:03 -0400)]
[wasm] GenerateWasmBootJson - close file handles (#85480)

Close files opened with `File.OpenRead` by utilizing the `using`
pattern.

15 months ago[wasi] Fix support for paths with spaces (#85022)
Ankit Jain [Thu, 27 Apr 2023 20:07:31 +0000 (16:07 -0400)]
[wasi] Fix support for paths with spaces (#85022)

* [wasi] Fix disabling wasi build for projects

* [wasi] Fix quoting in Wasi targets

* [wasi] WBT: don't run wasi targets for the tests project

15 months agoReduce calli address spilling (#85349)
Michał Petryka [Thu, 27 Apr 2023 17:52:36 +0000 (19:52 +0200)]
Reduce calli address spilling (#85349)

15 months agoJIT: Handle GT_RETFILT in fgInsertStmtNearEnd (#85420)
Jakob Botsch Nielsen [Thu, 27 Apr 2023 17:41:50 +0000 (19:41 +0200)]
JIT: Handle GT_RETFILT in fgInsertStmtNearEnd (#85420)

Also add some logging for read backs in physical promotion.

Fix #85088

15 months agoJIT: Propagate some more indir flags in physical promotion (#85453)
Jakob Botsch Nielsen [Thu, 27 Apr 2023 17:16:33 +0000 (19:16 +0200)]
JIT: Propagate some more indir flags in physical promotion (#85453)

When physical promotion creates multiple indirections for arbitrary
BLK/FIELD sources, make sure we propagate all relevant flags.

Fix #85449