platform/upstream/dotnet/runtime.git
18 months agoAdd arm64 wasm support (#83677)
Evgeny Karpov [Thu, 27 Apr 2023 00:45:00 +0000 (02:45 +0200)]
Add arm64 wasm support (#83677)

18 months agoJIT: fix phase status for some minimal instrumentation cases (#85411)
Andy Ayers [Wed, 26 Apr 2023 23:48:46 +0000 (16:48 -0700)]
JIT: fix phase status for some minimal instrumentation cases (#85411)

The instrumentation phase may modify the flow graph in anticipation of doing
some instrumentation, but then (because of minimal profiling) decide not to
instrument.

Make sure the phase status properly reflects that the phase made changes in
this case, and a few other cases where we exit early without actually doing
any instrumentation.

Fixes #85061.

18 months agoFix physical promotion scenario name and a couple of bugs (#85343)
Jakob Botsch Nielsen [Wed, 26 Apr 2023 22:43:47 +0000 (00:43 +0200)]
Fix physical promotion scenario name and a couple of bugs (#85343)

This was renamed but I forgot to update these occurrences. The result is
that runtime-jit-experimental is not actually running with physical
promotion enabled.

Also fix a couple of bugs that made it in in the meantime.

18 months agoJIT: Change GTF_ICON_INITCLASS -> GTF_IND_INITCLASS (#85396)
Jakob Botsch Nielsen [Wed, 26 Apr 2023 21:16:02 +0000 (23:16 +0200)]
JIT: Change GTF_ICON_INITCLASS -> GTF_IND_INITCLASS (#85396)

The JIT has a flag GTF_ICON_INITCLASS that represents that accesses off
that address are cctor dependent. Hoisting uses this to avoid hoisting
cctor dependent indirections unless all cctors are also hoisted.
However, local constant prop/VN-based constant prop do not handle this
flag, so we could run into cases where addresses with GTF_ICON_INITCLASS
were propagated and then subsequently hoisted incorrectly.

This change moves the flag to an OperIsIndir() flag instead of being a
flag on the constant. After some digging, I found that the original
reason the flag was not an indir flag was simply that there were no more
indir flags available, but we do have available flags today. This fix
is much simpler than the alternatives which would be to teach VN/local
copy prop to propagate this GTF_ICON_INITCLASS flag.

Also remove GTF_FLD_INITCLASS which is never set.

18 months agoFix stress builds (#85342)
Anton Firszov [Wed, 26 Apr 2023 20:38:54 +0000 (22:38 +0200)]
Fix stress builds (#85342)

Fix #85338, by switching to centos-stream8

18 months agoAdd CompositeFormat.MinimumArgumentCount and remove TryParse (#85348)
Stephen Toub [Wed, 26 Apr 2023 20:30:11 +0000 (16:30 -0400)]
Add CompositeFormat.MinimumArgumentCount and remove TryParse (#85348)

* Add CompositeFormat.MinimumArgumentCount

* Remove CompositeFormat.TryParse

It encourages bad patterns of consumption.

18 months agoFix generic dictionary lookups for param types and function pointers (#85369)
Jan Kotas [Wed, 26 Apr 2023 19:51:27 +0000 (12:51 -0700)]
Fix generic dictionary lookups for param types and function pointers (#85369)

* Fix generic dictionary lookups for param types and function pointers

Fixes #85240

* AllowUnsafeBlocks

* Disable test on Mono

18 months agolet user know working directory will be used as content root path by default (#82445)
Badre BSAILA [Wed, 26 Apr 2023 19:39:02 +0000 (21:39 +0200)]
let user know working directory will be used as content root path by default (#82445)

18 months agoFix totalILArgs for explicithis (#85347)
Michał Petryka [Wed, 26 Apr 2023 19:21:01 +0000 (21:21 +0200)]
Fix totalILArgs for explicithis (#85347)

* Fix totalILArgs for explicithis

* Fix missed places

18 months agoAdd introspection for readelf (#85298)
Adeel Mujahid [Wed, 26 Apr 2023 19:07:58 +0000 (22:07 +0300)]
Add introspection for readelf (#85298)

18 months agoBump main preview version to 5 (#85368)
Carlos Sánchez López [Wed, 26 Apr 2023 19:06:24 +0000 (12:06 -0700)]
Bump main preview version to 5 (#85368)

18 months agoAssemblyBuilder.Save add custom attributes handling. (#84580)
Buyaa Namnan [Wed, 26 Apr 2023 16:28:25 +0000 (09:28 -0700)]
AssemblyBuilder.Save add custom attributes handling. (#84580)

* Initial custom attributes handling

* Pseudo custom attributes handling and tests

* Use ReadOnlySpan for CustomAttribute binaryData

* Update some pseudo attributes handling and apply feedback

* Add one more pseudo attribute and a few small changes

* Move pseudo attributes handling

* Remove type loading logic from CustomAttributes parsing, use constants for some values

* Add MarshalAsAttribute handling and apply other feedbacks

---------

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
18 months ago[mono][jit] Add an option to use an mrgctx for all gshared methods. (#82981)
Zoltan Varga [Wed, 26 Apr 2023 15:01:05 +0000 (11:01 -0400)]
[mono][jit] Add an option to use an mrgctx for all gshared methods. (#82981)

Enable it by default on WASM.

In this mode, all gshared methods get an mrgctx, which means they can access
their data using a simple load from the mrgctx instead of having to call
a rgctx fetch trampoline.

Upsides:
- much simpler.
- faster access to gshared data
- smaller code and data size in the AOT case
- if enabled by default on all platforms, large amount of gshared
  code can be removed

Downsides:
- the methods have to initialize their mrgctx in their prolog
- on non-wasm platforms, indirect calls to gshared methods
  (like virtual calls) will need to use rgctx trampolines more often
  to pass the mrgctx.

18 months ago[wasm][nodejs] enable EH for unit tests (#85387)
Pavel Savara [Wed, 26 Apr 2023 14:24:59 +0000 (16:24 +0200)]
[wasm][nodejs] enable EH for unit tests (#85387)

18 months agoMade helixpublishwitharcade's TargetOS property lowercase. (#85357)
Ivan Diaz Sanchez [Wed, 26 Apr 2023 14:16:19 +0000 (07:16 -0700)]
Made helixpublishwitharcade's TargetOS property lowercase. (#85357)

Fixes #81141. In PR #80164, the build scripts were updated to always require and/or convert the MSBuild `TargetOS` property to lowercase. However, the _helixpublishwitharcade.proj_ file was not included in these efforts, which led to some confusing behavior and misplaced files, as described in issue #81141. This PR addresses and fixes that.

18 months ago[browser] Fix webcil lazy loading and satellite assemblies in Wasm SDK (#85335)
Pavel Savara [Wed, 26 Apr 2023 14:11:22 +0000 (16:11 +0200)]
[browser] Fix webcil lazy loading and satellite assemblies in Wasm SDK (#85335)

Co-authored-by: Marek Fišera <mara@neptuo.com>
18 months ago[mono][jit] Adding Vector128.ConvertXX as intrinsic on arm64. (#85163)
Jan Dupej [Wed, 26 Apr 2023 14:03:37 +0000 (16:03 +0200)]
[mono][jit] Adding Vector128.ConvertXX as intrinsic on arm64. (#85163)

* [mono][jit] Adding Vector128.ConvertXX as intrinsic on arm64.

* Changed rounding model on f->i conversion.

* Disabled f32->i32 casting test.

* Disabled all of failing JIT tests.

18 months agoSkip 84693 test (#85381)
Will Smith [Wed, 26 Apr 2023 13:58:08 +0000 (06:58 -0700)]
Skip 84693 test (#85381)

18 months ago[mono][jit] Add Vector128.WithElement as intrinsic on arm64. (#85158)
Jan Dupej [Wed, 26 Apr 2023 12:47:57 +0000 (14:47 +0200)]
[mono][jit] Add Vector128.WithElement as intrinsic on arm64. (#85158)

* [mono][jit] Add Vector128.WithElement as intrinsic on arm64.

* Fixed store opcode mismatch.

* Optimize the nonconstant case only for Vector128 in mini.

18 months ago[wasm][WBT] Fix pack pattern take two (#85391)
Pavel Savara [Wed, 26 Apr 2023 12:00:30 +0000 (14:00 +0200)]
[wasm][WBT] Fix pack pattern take two (#85391)

18 months agoImplement ICorProfilerInfo14::EnumerateNonGCObjects (#85100)
Egor Bogatov [Wed, 26 Apr 2023 11:06:05 +0000 (13:06 +0200)]
Implement ICorProfilerInfo14::EnumerateNonGCObjects (#85100)

18 months agoJIT: Introduce GT_JTEST and clean up GT_JCMP flags (#85242)
Jakob Botsch Nielsen [Wed, 26 Apr 2023 08:04:03 +0000 (10:04 +0200)]
JIT: Introduce GT_JTEST and clean up GT_JCMP flags (#85242)

* Introduce GT_JTEST to replace GTF_JCMP_TEST
* Stop encoding JCMP conditions in GenTreeFlags by switching GT_JCMP to
  a GenTreeOpCC node. This removes GTF_JCMP_EQ and the
  LoongArch64/RISC-V specific mechanism to communicate condition codes
  to the backend via gtFlags.

18 months agoFix simd12_t size (#85362)
Egor Bogatov [Wed, 26 Apr 2023 07:34:39 +0000 (09:34 +0200)]
Fix simd12_t size (#85362)

18 months agoFold IND(frozenObj, CNS) (#85127)
Egor Bogatov [Wed, 26 Apr 2023 07:21:34 +0000 (09:21 +0200)]
Fold IND(frozenObj, CNS) (#85127)

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
18 months ago[JIT] ARM64 - Fixed regressions for `GT_NEG` containment (#85230)
Will Smith [Wed, 26 Apr 2023 07:08:06 +0000 (00:08 -0700)]
[JIT] ARM64 - Fixed regressions for `GT_NEG` containment (#85230)

* Fixed regressions for 'GT_NEG' containment on ARM64

* Containing NEG is only valid for EQ and NE.

* Update codegenarm64.cpp

* Formatting

18 months agoChange `callvirt` into `calli` for virtual delegates (#83461)
Vlad-Alexandru Ionescu [Wed, 26 Apr 2023 06:27:29 +0000 (08:27 +0200)]
Change `callvirt` into `calli` for virtual delegates (#83461)

JIT delegates do not depend on the target method and an call is used

---------

Signed-off-by: Vlad - Alexandru Ionescu <vlad-alexandruionescu@Vlads-MacBook-Pro-2.local>
Co-authored-by: Vlad - Alexandru Ionescu <vlad-alexandruionescu@Vlads-MacBook-Pro-5.local>
18 months agoDon't re-scan previously visited blocks in helperexpansion.cpp (#85201)
Egor Bogatov [Wed, 26 Apr 2023 05:34:01 +0000 (07:34 +0200)]
Don't re-scan previously visited blocks in helperexpansion.cpp (#85201)

18 months ago[Wasm.Build.Tests] Fixup wildcard matching for runtime packs (#85286)
Aleksey Kliger (λgeek) [Wed, 26 Apr 2023 01:55:38 +0000 (21:55 -0400)]
[Wasm.Build.Tests] Fixup wildcard matching for runtime packs (#85286)

The naming is
`Microsoft.NETCore.App.Runtime.Mono.{variant}.{rid}.{version}.nupkg`

Fixes local WBT builds for non-default runtime variants (eg: build
with `/p:MonoWasmBuildVariant=multithread` then run WBT)

18 months agoGuard DynamicDependency processing against `TypeSystemException`s (#85285)
Michal Strehovský [Wed, 26 Apr 2023 01:09:13 +0000 (10:09 +0900)]
Guard DynamicDependency processing against `TypeSystemException`s (#85285)

Works around https://github.com/dotnet/fsharp/issues/15140 and it's also just good hygiene.

18 months agoRe-enable PGO for linux (#85355)
Sven Boemer [Wed, 26 Apr 2023 00:55:36 +0000 (17:55 -0700)]
Re-enable PGO for linux (#85355)

18 months ago[hot_reload] assorted hot reload fixes for cumulative property updates (#85351)
Aleksey Kliger (λgeek) [Tue, 25 Apr 2023 23:58:51 +0000 (19:58 -0400)]
[hot_reload] assorted hot reload fixes for cumulative property updates (#85351)

* [hot_reload] remove unneeded assertion

`is_addition` is already defined as `token_index-1 >=
delta_info->count[token_table].prev_gen_rows` so:

1. the assertion as written is wrong for cumulative updates that add
new properties or events
2. the assertion would be trivially true if it was updated to use
`delta_info->count[token_table].prev_gen_rows`.

Fixes the ability to cumulatively add new properties

* Update generation on MonoClassMetadataUpdateInfo when adding members

Give recompute_ginst_update_info something to work with.

* assert that generic instances don't call hot_reload_get_property

token-based lookup should only happen for class defs or GTDs

* update regression test

18 months agoJIT: improve profile update for loop inversion (#85265)
Andy Ayers [Tue, 25 Apr 2023 23:52:56 +0000 (16:52 -0700)]
JIT: improve profile update for loop inversion (#85265)

If the loop test block has multiple predecessors we will not do proper
profile updates. This can lead to downstream problems with block layout
(say leaving a cold block in a loop).

Fix by changing how we compute the amount of profile that should remain
in the test block.

Fixes #84319.

18 months agoJIT: add ssa accounting to morph's div opts (#85332)
Andy Ayers [Tue, 25 Apr 2023 23:50:22 +0000 (16:50 -0700)]
JIT: add ssa accounting to morph's div opts (#85332)

RBO triggered a morph opt that cloned an SSA local, throwing off the SSA
accounting. Fix by invoking the accounting helper after the morph expansion.

Closes #85226.

18 months agoDirectory.Build.props: don't overwrite PackageOS from source-build. (#85350)
Tom Deseyn [Tue, 25 Apr 2023 23:44:39 +0000 (01:44 +0200)]
Directory.Build.props: don't overwrite PackageOS from source-build. (#85350)

18 months agoAdd Winforms as consultant on ComponentModel (#85363)
Eric StJohn [Tue, 25 Apr 2023 21:59:52 +0000 (14:59 -0700)]
Add Winforms as consultant on ComponentModel (#85363)

18 months agoFix a few downlevel TimeProvider issues (#85346)
Stephen Toub [Tue, 25 Apr 2023 21:59:15 +0000 (17:59 -0400)]
Fix a few downlevel TimeProvider issues (#85346)

- Consistently null check the Timer stored in the state object
- Complete the a task canceled due to the CancellationToken with the CancellationToken
- Avoid an unnecessary closure in Delay
- Make TimeProvider.System.CreateTimer use Timer's ctor that takes duration/period rather than making a separate call to Change

18 months ago[wasm] Disable `Wasm.Build.Tests.Blazor.BuildPublishTests.BugRegression_60479_WithRaz...
Marek Fišera [Tue, 25 Apr 2023 20:08:10 +0000 (22:08 +0200)]
[wasm] Disable `Wasm.Build.Tests.Blazor.BuildPublishTests.BugRegression_60479_WithRazorClassLib` (#85356)

* Add active issue on blazor lazy load test

* Add active issue on blazor lazy load test

18 months agoUse CollectionsMarshal.SetCount in LINQ to deduplicate ToArray/ToList implementations...
Stephen Toub [Tue, 25 Apr 2023 20:05:30 +0000 (16:05 -0400)]
Use CollectionsMarshal.SetCount in LINQ to deduplicate ToArray/ToList implementations (#85288)

* Use CollectionsMarshal.SetCount in LINQ to deduplicate ToArray/ToList implementations

* Fix BinaryFormatter test

The test was implemented using ToList, and `List<T>` serialization serializes out its version field.  As a result, because we're now optimizing creation and not incrementing the version as much in ToList, the blob didn't match.

18 months agoFix Avx2 helpers (#85275)
Sven Boemer [Tue, 25 Apr 2023 19:56:57 +0000 (12:56 -0700)]
Fix Avx2 helpers (#85275)

Unblocks dotnet-optimization flow and
https://github.com/dotnet/runtime/issues/84711. Includes a
dotnet-optimization update to confirm this it avoids the issue
discussed in https://github.com/dotnet/runtime/pull/84635. This
fixes that issue by preventing R2R for any Avx2 helpers which
assume they are called with Avx2 enabled.

18 months agoinit-distro-rid.sh: fix unbound error when VERSION_ID is not defined. (#85319)
Tom Deseyn [Tue, 25 Apr 2023 19:50:19 +0000 (21:50 +0200)]
init-distro-rid.sh: fix unbound error when VERSION_ID is not defined. (#85319)

18 months ago[mono][NativeAOT] System.Globalization.Native build improvements (#82393)
Filip Navara [Tue, 25 Apr 2023 18:46:56 +0000 (20:46 +0200)]
[mono][NativeAOT] System.Globalization.Native build improvements (#82393)

Fixes #82389

- Fixes build of System.Globalization.Native for iOS-like, browser, and wasi platforms
- Removes ICU shim from static builds of Mono runtime and builds it as part of libs.native subset
- Switches browser/wasi to use the static libraries

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
18 months agoJIT: Create side effect commas as TYP_VOID in block morph (#85320)
Jakob Botsch Nielsen [Tue, 25 Apr 2023 18:13:58 +0000 (20:13 +0200)]
JIT: Create side effect commas as TYP_VOID in block morph (#85320)

This code could create IR shapes like

COMMA struct
  ...
  ASG struct
    dst
    src

After liveness that would sometimes result in

COMMA struct
  ...
  NOP void

which could confuse optimization phases when JitOptRepeat was enabled.

The more canonical shape for these side-effecting GT_COMMA nodes has
them TYP_VOID typed as shown by gtExtractSideEffList, so do the same in
block morph.

Fix #85037

18 months agoExpose various Convert intrinsics for Avx512F, Avx512BW, and Avx512DQ (#85281)
Tanner Gooding [Tue, 25 Apr 2023 18:11:09 +0000 (11:11 -0700)]
Expose various Convert intrinsics for Avx512F, Avx512BW, and Avx512DQ (#85281)

* Expose various Convert intrinsics for Avx512F and Avx512DQ

* Expose various integer conversion APIs for Avx512F and Avx512BW

* Ensure special instructions are handled in codegen

* Apply formatting patch

* Ensure the AVX512F_VL variant is picked for simdSize=16/32

* Ensure conversion instructions are handled in PERFSCORE

* Ensure instructions use the right tuple type

* Removing an invalid API and fix more PERFSCORE entries

* Resolve additional failures masked by #85056

* Ensure TieredCompilation=0 is also passing

* Apply formatting patch

* Fixing some more test edge cases

* Ensure uint64->double and uint64->Float masks the input

18 months agoSPMI: Always add authenticated pip feed for test job runs (#85327)
Jakob Botsch Nielsen [Tue, 25 Apr 2023 17:33:37 +0000 (19:33 +0200)]
SPMI: Always add authenticated pip feed for test job runs (#85327)

We always try to upload the collections for the tests, even on failures,
so we should also add the authed feed on failures.

18 months agoEnC Support for Generics (#85269)
mikelle-rogers [Tue, 25 Apr 2023 17:32:19 +0000 (10:32 -0700)]
EnC Support for Generics (#85269)

* EnC non-functional changes
- Update inappropriate naming
- Update many logging statements
- Remove unused code

* EnC support for fields on generic types

* EnC support for methods on generic types

* Fix use after free introduced in EnC breakpoint.
Fix off by one for string logging.

* update new feature capabilities, JIT GUID

* Fix non-enc build

* Fix EnCFieldIndex check

* Remove IsFdPrivate assert

---------

Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
Co-authored-by: Tom McDonald <tommcdon@microsoft.com>
18 months agoNativeAOT ComWrappers: fix race condition in when creating native wrapper (#85235)
Austin Wise [Tue, 25 Apr 2023 16:26:32 +0000 (09:26 -0700)]
NativeAOT ComWrappers: fix race condition in when creating native wrapper (#85235)

18 months agoPopulating JSON properties support (#83669)
Krzysztof Wicher [Tue, 25 Apr 2023 16:26:03 +0000 (18:26 +0200)]
Populating JSON properties support (#83669)

* Populating JSON properties support

* apply review feedback

* Attempt to fix build by reducing stack frame

* Fix docs

* Remove unnecessary properties from ReadStackFrame.

* Move source gen tests to the source gen test project.

* Improve test helper method name.

* Add argument validation to JsonPropertyInfo.ObjectCreationHandling & extend unit testing for the new metadata APIs.

* Add test coverage for invalid attribute annotations.

---------

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
18 months ago[NativeAOT] Do not strip exported symbols from executables on Apple platforms (#85293)
Ivan Povazan [Tue, 25 Apr 2023 16:09:40 +0000 (18:09 +0200)]
[NativeAOT] Do not strip exported symbols from executables on Apple platforms (#85293)

* Do not strip exported symbols from executables when explicitly specified

* Add '_' prefix to StripFlag internal project property

18 months agoMake Guid.HexsToChars aggressively inlined (#85322)
Stephen Toub [Tue, 25 Apr 2023 16:03:33 +0000 (12:03 -0400)]
Make Guid.HexsToChars aggressively inlined (#85322)

To help mono cope with the genericized implementation.  This method is only used when Ssse3 or AdvSimd.Arm64 are not supported, or when formatting the rarely-used "X" format, but currently mono AOT without LLVM doesn't enable those intrinsics.

18 months agoRetry compat Random.NextSingle in case rounding from double produces 1.0f (#85321)
Stephen Toub [Tue, 25 Apr 2023 16:02:20 +0000 (12:02 -0400)]
Retry compat Random.NextSingle in case rounding from double produces 1.0f (#85321)

The compat implementation behind Random just casts a double to a float to produce the result of NextSingle.  Some double values close to 1.0 might round up to 1.0f, which is out of range for NextSingle.  In that case, reject it and retry.  This approach is consistent with how fairness is handled elsewhere in the implementation, and avoids changing the sequence of values returned for a fixed seed in cases where an illegal value wasn't being returned.

18 months agoFix publishing relinked dotnet.worker.js (#85314)
Marek Fišera [Tue, 25 Apr 2023 15:56:02 +0000 (17:56 +0200)]
Fix publishing relinked dotnet.worker.js (#85314)

18 months agoAdd TargetHostName to QuicConnection (#84976)
Radek Zikmund [Tue, 25 Apr 2023 15:50:34 +0000 (17:50 +0200)]
Add TargetHostName to QuicConnection (#84976)

* Add TargetHostName to QuicConnection
Fixes #80508

* Make TargetHostName not nullable

* Fix build

* Fix build of tests

* Fix failing tests

* Code review feedback

* Use unencoded hostname in user-facing properties/params

* Fix failing tests

* Revert unwanted changes

* Add test for IDN cert validation

* Fix test again

* Fix trailing dot in hostname

18 months ago[wasm] Add more PackedSimd methods, logic ops (#85303)
Radek Doulik [Tue, 25 Apr 2023 15:33:11 +0000 (17:33 +0200)]
[wasm] Add more PackedSimd methods, logic ops (#85303)

* [wasm] Add more PackedSimd methods

* Fix doc comments

18 months agoFix the TimeProvider test (#85268)
Tarek Mahmoud Sayed [Tue, 25 Apr 2023 14:32:51 +0000 (07:32 -0700)]
Fix the TimeProvider test (#85268)

* Fix the TimeProvider test

* remove the assert

18 months agoFix coreclr-release-outerloop-nightly pipeline (#85278)
Tomáš Rylek [Tue, 25 Apr 2023 14:30:53 +0000 (16:30 +0200)]
Fix coreclr-release-outerloop-nightly pipeline (#85278)

18 months ago[RISC-V] Add RISC-V CI (#85289)
Dong-Heon Jung [Tue, 25 Apr 2023 14:28:27 +0000 (23:28 +0900)]
[RISC-V] Add RISC-V CI (#85289)

- Add RISC-V Checked Build CI
- https://github.com/dotnet/runtime/issues/84834

18 months agoJIT: Support some assignment decomposition in physical promotion (#85105)
Jakob Botsch Nielsen [Tue, 25 Apr 2023 13:57:48 +0000 (15:57 +0200)]
JIT: Support some assignment decomposition in physical promotion (#85105)

Add support for directly initializing and copying into replacements
instead of doing a struct local and read back. Physically promoted
struct locals used as sources are still handled conservatively (by first
writing them back to stack, then doing the copy).

For example, for a case like

```
void Foo()
{
    S s = _field;
    s.A = s.B + 3;
    Consume(s);
}

struct S
{
    public int A, B;
}
```

We see the following:

```
STMT00000 ( 0x000[E-] ... 0x006 )
               [000003] -A-XG------                         ▌  ASG       struct (copy)
               [000002] D------N---                         ├──▌  LCL_VAR   struct<Program+S, 8> V01 loc0
               [000001] ---XG------                         └──▌  FIELD     struct Program:_field
               [000000] -----------                            └──▌  LCL_VAR   ref    V00 this          (last use)
Processing block operation [000003] that involves replacements
New statement:
STMT00000 ( 0x000[E-] ... 0x006 )
               [000029] -A-XG------                         ▌  COMMA     int
               [000021] -A-XG------                         ├──▌  ASG       int
               [000015] D------N---                         │  ├──▌  LCL_VAR   int    V03 tmp1
               [000020] ---XG------                         │  └──▌  IND       int
               [000018] -----------                         │     └──▌  ADD       ref
               [000016] -----------                         │        ├──▌  LCL_VAR   ref    V00 this
               [000017] -----------                         │        └──▌  CNS_INT   long   8
               [000028] -A-XG------                         └──▌  ASG       int
               [000022] D------N---                            ├──▌  LCL_VAR   int    V04 tmp2
               [000027] ---XG------                            └──▌  IND       int
               [000025] -----------                               └──▌  ADD       ref
               [000023] -----------                                  ├──▌  LCL_VAR   ref    V00 this
               [000024] -----------                                  └──▌  CNS_INT   long   12
```

The logic is currently quite rudimentary when it comes to
holes/uncovered parts of the struct. For example, in the above case if
we add another unused field at the end of S then the result is:

```
STMT00000 ( 0x000[E-] ... 0x006 )
               [000003] -A-XG------                         ▌  ASG       struct (copy)
               [000002] D------N---                         ├──▌  LCL_VAR   struct<Program+S, 12> V01 loc0
               [000001] ---XG------                         └──▌  FIELD     struct Program:_field
               [000000] -----------                            └──▌  LCL_VAR   ref    V00 this          (last use)
Processing block operation [000003] that involves replacements
Struct operation is not fully covered by replaced fields. Keeping struct operation.
New statement:
STMT00000 ( 0x000[E-] ... 0x006 )
               [000030] -A-XG------                         ▌  COMMA     struct
               [000021] -A-XG------                         ├──▌  ASG       int
               [000015] D------N---                         │  ├──▌  LCL_VAR   int    V03 tmp1
               [000020] ---XG------                         │  └──▌  IND       int
               [000018] -----------                         │     └──▌  ADD       ref
               [000016] -----------                         │        ├──▌  LCL_VAR   ref    V00 this
               [000017] -----------                         │        └──▌  CNS_INT   long   8
               [000029] -A-XG------                         └──▌  COMMA     struct
               [000028] -A-XG------                            ├──▌  ASG       int
               [000022] D------N---                            │  ├──▌  LCL_VAR   int    V04 tmp2
               [000027] ---XG------                            │  └──▌  IND       int
               [000025] -----------                            │     └──▌  ADD       ref
               [000023] -----------                            │        ├──▌  LCL_VAR   ref    V00 this
               [000024] -----------                            │        └──▌  CNS_INT   long   12
               [000003] -A-XG------                            └──▌  ASG       struct (copy)
               [000002] D------N---                               ├──▌  LCL_VAR   struct<Program+S, 12> V01 loc0
               [000001] ---XG------                               └──▌  FIELD     struct Program:_field
               [000000] -----------                                  └──▌  LCL_VAR   ref    V00 this
```

In this case it would be significantly more efficient to copy only the
remainder, which is just a small part of the struct. However, in the
general case it is not easy to predict the most efficient way to do
this, and in some cases we cannot even represent the hole in JIT IR (if
it involves GC pointers), so I have left this for a future change for
now. Liveness should also be beneficial for that as there are many cases
where we would expect the remainder to be dead.

18 months agoRemove useless serializability checks (#80957)
madelson [Tue, 25 Apr 2023 13:47:38 +0000 (09:47 -0400)]
Remove useless serializability checks (#80957)

18 months ago[mono] Remove mono_dl_open_runtime_lib() (#85253)
Alexander Köplinger [Tue, 25 Apr 2023 13:45:51 +0000 (15:45 +0200)]
[mono] Remove mono_dl_open_runtime_lib() (#85253)

It was only used to load the profiler from an "installed" path, but that is no longer a thing in modern .NET

18 months ago[mono][interp] Fix il_offset of inserted instructions (#85305)
Vlad Brezae [Tue, 25 Apr 2023 13:02:54 +0000 (16:02 +0300)]
[mono][interp] Fix il_offset of inserted instructions (#85305)

After the original codegen happens, where instructions have the associated il_offset set, we might still generate new instruction as part of various optimizations. They would have the associated il_offset of the end of the method which is incorrect and was screwing up mapping from native_offset to il_offset.

18 months agoAdd function pointer type support to type loader (#85287)
Michal Strehovský [Tue, 25 Apr 2023 08:51:41 +0000 (17:51 +0900)]
Add function pointer type support to type loader (#85287)

So that we can create new function pointer types at runtime within the context of `MakeGenericXXX`.

18 months agoJIT: Allow spill-at-single-def for pure defs (#85251)
Jakob Botsch Nielsen [Tue, 25 Apr 2023 08:47:09 +0000 (10:47 +0200)]
JIT: Allow spill-at-single-def for pure defs (#85251)

Allow the spill-at-single-def logic to kick in for defs without subsequent uses before the spill.

18 months agoAdd authenticated PIP feed before its use in internal JIT pipelines (#85292)
Jakob Botsch Nielsen [Tue, 25 Apr 2023 08:45:57 +0000 (10:45 +0200)]
Add authenticated PIP feed before its use in internal JIT pipelines (#85292)

This unblocks internal JIT pipelines.

18 months agoFix edge case in stack overflow handling (#85272)
Jan Vorlicek [Tue, 25 Apr 2023 08:16:02 +0000 (10:16 +0200)]
Fix edge case in stack overflow handling (#85272)

There is a problematic case when the stack overflow happens in native code
and there is an explicit frame between the managed and native code. Some
time ago, I have added a fix for a problem when the stack overflow
happened in native code, but I haven't found that it actually works only
in case there is no explicit frame between the managed code and the
failing native code frame. That fix makes the `FaultingExceptionFrame`
that is created for the stack overflow to contain context of the managed
code frame, so the stack walker uses that to move to the next frame. But
while doing so, it hits the other explicit frame that it doesn't expect
there and fires an assert.

This fix handles the problematic case correctly.

18 months ago[main] Update dependencies from dotnet/runtime (#85249)
dotnet-maestro[bot] [Tue, 25 Apr 2023 07:51:48 +0000 (09:51 +0200)]
[main] Update dependencies from dotnet/runtime (#85249)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoDisable gcstress and jitstress for tracing tests (#85186)
David Mason [Tue, 25 Apr 2023 06:51:20 +0000 (23:51 -0700)]
Disable gcstress and jitstress for tracing tests (#85186)

* Disable gcstress and jitstress

* Fix EventListenerThreadPool proj

---------

Co-authored-by: Juan Hoyos <19413848+hoyosjs@users.noreply.github.com>
18 months agoEmit GC info into a COMDAT section (#83371)
Michal Strehovský [Tue, 25 Apr 2023 06:24:05 +0000 (15:24 +0900)]
Emit GC info into a COMDAT section (#83371)

Saves 3.14% on BasicWebApi. 🤯

We run linker with COMDAT folding enabled. Generating this data into COMDAT foldable section allows linker to deduplicate these.

18 months agoSpecify -z notext on linux-musl-x86 and riscv64 (#83682)
Adeel Mujahid [Tue, 25 Apr 2023 05:46:16 +0000 (08:46 +0300)]
Specify -z notext on linux-musl-x86 and riscv64 (#83682)

* Specify -z notext on linux-musl-x86

* Fix riscv64 build with clang/lld v15+

* Inline visibility attribute

* Fix gcc build

18 months agorefactor the g_SyncBlockCacheInstance for aligned (#85241)
Qiao Pengcheng [Tue, 25 Apr 2023 05:45:43 +0000 (13:45 +0800)]
refactor the g_SyncBlockCacheInstance for aligned (#85241)

18 months agoEnable ComWrappers for NativeAOT on non-Windows (#85000)
Jeremy Koritzinsky [Tue, 25 Apr 2023 03:46:39 +0000 (20:46 -0700)]
Enable ComWrappers for NativeAOT on non-Windows (#85000)

18 months agoBuild Mono LLVM legs on the CBL-Mariner images, but run the AOTing steps on CentOS...
Jeremy Koritzinsky [Tue, 25 Apr 2023 03:33:48 +0000 (20:33 -0700)]
Build Mono LLVM legs on the CBL-Mariner images, but run the AOTing steps on CentOS Stream 8 with binutils (#85273)

18 months agoAdd Parallel.ForAsync (#84804)
Stephen Toub [Tue, 25 Apr 2023 02:51:18 +0000 (22:51 -0400)]
Add Parallel.ForAsync (#84804)

* Add Parallel.ForAsync

* Apply suggestions from code review

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
18 months agoFix perf regressions in Utf8Formatter for integers (#85277)
Stephen Toub [Tue, 25 Apr 2023 02:50:59 +0000 (22:50 -0400)]
Fix perf regressions in Utf8Formatter for integers (#85277)

When I added UTF8 support to the core numeric types, I also just routed Utf8Formatter to use the public TryFormat API on each type.  That, however, regressed some microbenchmarks due to a) going from `StandardFormat` to a `ReadOnlySpan<char>` format and then parsing it back out and b) removing some of the inlining that was there previously.  This change puts back into Utf8Formatter.TryFormat the handling of the format and then delegating to the relevant helpers that already exist rather than always going through the public entrypoint (it doesn't do so for 'n', but that's also much rarer to use on a hot path and is also in general more expensive).

18 months agoAdd CollectionsMarshal.SetCount(list, count) (#82146)
Michał Petryka [Tue, 25 Apr 2023 01:14:10 +0000 (03:14 +0200)]
Add CollectionsMarshal.SetCount(list, count) (#82146)

* Add CollectionsMarshal.SetCount(list, count)

Adds the ability to resize lists, exposed in
CollectionsMarshal due to potentially risky
behaviour caused by the lack of element initialization.

Supersedes #77794.

Fixes #55217.

* Update XML doc

* Add missing using

* Fix test

* Update CollectionsMarshalTests.cs

* Update CollectionsMarshal.cs

* Update CollectionsMarshalTests.cs

* Update CollectionsMarshalTests.cs

18 months ago[native-library] If a dllimport is specified with an absolute path, look for it first...
Aleksey Kliger (λgeek) [Tue, 25 Apr 2023 00:49:02 +0000 (20:49 -0400)]
[native-library] If a dllimport is specified with an absolute path, look for it first (#85255)

The unmanaged native library probing documentation says to try
absolute paths without variations

https://learn.microsoft.com/en-us/dotnet/core/dependency-loading/default-probing#unmanaged-native-library-probing

18 months agoAdd parsing error information to composite format string parsing exceptions (#85106)
Stephen Toub [Tue, 25 Apr 2023 00:29:35 +0000 (20:29 -0400)]
Add parsing error information to composite format string parsing exceptions (#85106)

* Add parsing error information to composite format string parsing exceptions

* Update src/libraries/System.Private.CoreLib/src/System/Text/CompositeFormat.cs

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
18 months agoAdd TextWriter.FlushAsync(CancellationToken) (#84325)
Stephen Toub [Tue, 25 Apr 2023 00:28:43 +0000 (20:28 -0400)]
Add TextWriter.FlushAsync(CancellationToken) (#84325)

* Add TextWriter.FlushAsync(CancellationToken)

* Update src/libraries/System.Private.CoreLib/src/System/CodeDom/Compiler/IndentedTextWriter.cs

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
18 months agoPass resource item to workload task (#85264)
Jacques Eloff [Mon, 24 Apr 2023 23:32:16 +0000 (16:32 -0700)]
Pass resource item to workload task (#85264)

18 months agoAdd exceptions to TAR extended attribute constructors to disallow '=' and '\n' charac...
Carlos Sánchez López [Mon, 24 Apr 2023 23:24:29 +0000 (16:24 -0700)]
Add exceptions to TAR extended attribute constructors to disallow '=' and '\n' characters in keys and values. (#82812)

* Prevent adding extended attribute keys containing '=', '\n', or values containing '\n'.

* Add tests to verify that the PaxTarEntry and PaxGlobalExtendedAttributesTarEntry constructors that take an extended attributes dictionary, throw when a disallowed character is found.

* Apply CR suggestions

* Use enumerator to iterate items in the specified enumeration, and insert them to the lazily created dictionary if they pass the validations.

* Change IndexOf with Contains

---------

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
18 months agoJIT: Move some BasicBlock methods into block.cpp (#85224)
Andy Ayers [Mon, 24 Apr 2023 22:48:17 +0000 (15:48 -0700)]
JIT: Move some BasicBlock methods into block.cpp (#85224)

Collect up a few `BasicBlock` methods that were scattered about in other files.

18 months agoUse double VectorTableLookup on ARM in ProbabilisticMap (#85189)
Miha Zupan [Mon, 24 Apr 2023 22:33:45 +0000 (00:33 +0200)]
Use double VectorTableLookup on ARM in ProbabilisticMap (#85189)

* Avoid scalar fallback for logical right shift on Arm

* Use double VectorTableLookup on ARM in ProbabilisticMap

* Revert 3bfd7d3f82c8256c2d7d7ce9371de679d961df96

18 months agoSkip covariant checks for ldelema T[] with T exact
Egor Bogatov [Mon, 24 Apr 2023 21:27:15 +0000 (23:27 +0200)]
Skip covariant checks for ldelema T[] with T exact

18 months ago[browser] Enable threads in Wasm SDK (#85109)
Marek Fišera [Mon, 24 Apr 2023 19:54:29 +0000 (21:54 +0200)]
[browser] Enable threads in Wasm SDK (#85109)

Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
18 months agoAdd metadata update for overrides (#85182)
Fan Yang [Mon, 24 Apr 2023 19:52:25 +0000 (15:52 -0400)]
Add metadata update for overrides (#85182)

18 months agoOptimize >>> to ShiftRightLogical on arm64 (#85258)
Egor Bogatov [Mon, 24 Apr 2023 19:35:38 +0000 (21:35 +0200)]
Optimize >>> to ShiftRightLogical on arm64 (#85258)

18 months agoAdding TimeProvider CreateCancellationTokenSource extension method (#85131)
Tarek Mahmoud Sayed [Mon, 24 Apr 2023 18:47:16 +0000 (11:47 -0700)]
Adding TimeProvider CreateCancellationTokenSource extension method (#85131)

18 months agoFix superpmi.py to not cache local MCH files (#85187)
Bruce Forstall [Mon, 24 Apr 2023 18:11:43 +0000 (11:11 -0700)]
Fix superpmi.py to not cache local MCH files (#85187)

When an MCH file is specified via the `-mch_file` argument,
if that file is local (not on a UNC Windows share, on Windows),
then don't copy it to the MCH file cache.

This behavior -- to avoid caching local files -- was altered
with https://github.com/dotnet/runtime/pull/56871, but it's
not clear from that PR if it was required for something or
was something used for testing that wasn't reverted before merge.
I'm guessing the latter since the code was simply commented out.

18 months agoExpose AVX512 variants of AVX, AVX2, and FMA instructions (#85228)
Tanner Gooding [Mon, 24 Apr 2023 18:08:17 +0000 (11:08 -0700)]
Expose AVX512 variants of AVX, AVX2, and FMA instructions (#85228)

* Expose various Broadcast methods for Avx512F, Avx512BW, and Avx512DQ

* Expose ExtractVector128/256 and InsertVector128/256 methods for Avx512F and Avx512DQ

* Expose ShiftLeftLogicalVariable, ShiftRightArithmeticVariable, and ShiftRightLogicalVariable on Avx512F and Avx512BW

* Expose various FusedMultiplyAdd APIs for Avx512F

* Expose various Permute intrinsics for Avx512F, Avx512F.VL, Avx512BW, and Avx512BW.VL

* Add a cpuid check for AVX512_VBMI

* Add various Permute intrinsics for Avx512Vbmi and Avx512Vbmi.VL

* Apply formatting patch

* Ensure Avx512Vbmi is recognized

* Fixup the InstructionSetDesc for Avx512Vbmi

* Update JIT/EE Version Identifier

* Fix casing in InstructionSetDesc

18 months ago[wasm] System.Net.WebSockets.Client.Tests timeouts (#85167)
Pavel Savara [Mon, 24 Apr 2023 16:51:08 +0000 (18:51 +0200)]
[wasm] System.Net.WebSockets.Client.Tests timeouts (#85167)

Co-authored-by: Marek Fišera <mara@neptuo.com>
18 months ago[wasm] Add PackedSimd saturating integer arith. (#85043)
Radek Doulik [Mon, 24 Apr 2023 16:50:09 +0000 (18:50 +0200)]
[wasm] Add PackedSimd saturating integer arith. (#85043)

* [wasm] Add PackedSimd saturating integer arith.

* Add doc comments

18 months ago[mono][debugger] Improving debugger functionaties (#85050)
Thays Grazia [Mon, 24 Apr 2023 16:11:24 +0000 (13:11 -0300)]
[mono][debugger] Improving debugger functionaties (#85050)

* Improve debugger functionalites

* Fix step over in the end of a method

* Implement MDBGPROT_CMD_TYPE_SET_VALUES_BY_FIELD_TOKEN

* removing unrelated change.

* Remove mscordbi from CI

* remove mscordbi from ci

* fixing tests because the behavior was changed

* Revert this change

18 months agoRemove unused code for PBKDF2 on Android (#83639)
Kevin Jones [Mon, 24 Apr 2023 15:46:05 +0000 (11:46 -0400)]
Remove unused code for PBKDF2 on Android (#83639)

18 months agoSpecial-case enums in Utf8.TryWrite handler (#85196)
Stephen Toub [Mon, 24 Apr 2023 15:37:30 +0000 (11:37 -0400)]
Special-case enums in Utf8.TryWrite handler (#85196)

Until we implement the Enum.TryFormat overload that targets UTF8, special-case enums in Utf8.TryWrite's handler to use the UTF16 TryFormat in order to avoid boxing the enum.

18 months agoUpdate dependencies from https://github.com/dotnet/roslyn-analyzers build 20230423...
dotnet-maestro[bot] [Mon, 24 Apr 2023 14:51:52 +0000 (09:51 -0500)]
Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230423.2 (#85248)

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23222.2 -> To Version 3.3.5-beta1.23223.2

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoUpdate dependencies from https://github.com/dotnet/arcade build 20230424.1 (#85247)
dotnet-maestro[bot] [Mon, 24 Apr 2023 14:50:24 +0000 (09:50 -0500)]
Update dependencies from https://github.com/dotnet/arcade build 20230424.1 (#85247)

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.23222.1 -> To Version 8.0.0-beta.23224.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
18 months agoUse emit-based invoke for all of WASM including DI (#85065)
Steve Harter [Mon, 24 Apr 2023 14:09:28 +0000 (09:09 -0500)]
Use emit-based invoke for all of WASM including DI (#85065)

18 months ago[mono] refactor metadata update code (#85177)
Fan Yang [Mon, 24 Apr 2023 13:33:55 +0000 (09:33 -0400)]
[mono] refactor metadata update code (#85177)

* WIP: remove mono_class_set_metadata_update_info generics blocker

* Allow GTDs to store MonoClassMetadataUpdateInfo

   allow generic type definitions to can contain added members

* [loader] Use iterator in find_method_in_class

   Instead of using a for-loop, use an interator that will also pick up added methods from hot reload.

   There's an issue here compared to the old code: the old code could cope with MonoClass:methods containing null pointers.  But the iterator approach signals that iteration is finished by returning NULL.

   Need to check whether the old code is reachable on modern .NET

* Get method add/update info for generic instance classes

* Cleanup the codepath of calling hot_reload_find_method_by_name

* Add reflection support for property of generic instance

* Fix ios build failure

* Add new capabilities

Fixes https://github.com/dotnet/runtime/issues/82792
Fixes https://github.com/dotnet/runtime/issues/82791

---------

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
18 months agoRemove common tests from the Roslyn3.11 test project. (#85165)
Eirik Tsarpalis [Mon, 24 Apr 2023 13:19:41 +0000 (14:19 +0100)]
Remove common tests from the Roslyn3.11 test project. (#85165)

* Remove shared tests from the Roslyn3.11 test project.

* Decouple Roslyn3.11 smoke tests from shared test classes.

* Fix project file order.

18 months agoFix compiling errors within LoongArch64 and RISCV64 for `ins_Move_Extend`. (#85216)
Qiao Pengcheng [Mon, 24 Apr 2023 11:08:13 +0000 (07:08 -0400)]
Fix compiling errors within LoongArch64 and RISCV64 for `ins_Move_Extend`. (#85216)

* Fix compiling errors within LA64 and RISCV64 for `ins_Move_Extend`.

* update for CR.

18 months ago[mono] remove unneeded PKG_CONFIG_PATH for FreeBSD (#84062)
Thefrank [Mon, 24 Apr 2023 10:41:57 +0000 (03:41 -0700)]
[mono] remove unneeded PKG_CONFIG_PATH for FreeBSD (#84062)