platform/upstream/dotnet/runtime.git
20 months agoClaims identity and principal debugging update (#87742)
James Newton-King [Mon, 19 Jun 2023 02:05:48 +0000 (10:05 +0800)]
Claims identity and principal debugging update (#87742)

* Claims identity and principal debugging update

* Comment

20 months agoAdd LoggerMessageAttribute constructor's overloads (#87738)
Tarek Mahmoud Sayed [Sun, 18 Jun 2023 22:20:40 +0000 (15:20 -0700)]
Add LoggerMessageAttribute constructor's overloads (#87738)

20 months agoFix the namespace of IServiceCollection.AddMetrics (#87736)
Tarek Mahmoud Sayed [Sun, 18 Jun 2023 16:50:43 +0000 (09:50 -0700)]
Fix the namespace of IServiceCollection.AddMetrics (#87736)

20 months agoJIT: Regularize readbacks for parameters/OSR-locals in physical promotion (#87165)
Jakob Botsch Nielsen [Sat, 17 Jun 2023 18:37:57 +0000 (20:37 +0200)]
JIT: Regularize readbacks for parameters/OSR-locals in physical promotion (#87165)

Handle readbacks for parameters/OSR-locals like any other readback is
handled. Previously they were handled by creating the scratch BB and
then inserting IR after the main replacement had already been done; now,
we instead create the scratch BB eagerly and mark these as requiring a
read back at the beginning of the scratch BB, and leave normal
replacement logic up to handle it.

The main benefit is that this unification makes it easier to ensure that
future smarter handling of readbacks/writebacks (e.g. "resolution")
automatically kicks in for the common case of parameters.

Introduce another invariant, which is that we only ever mark a field as
requiring readback if it is live. Previously we would always mark them
as requiring read backs, but would then check liveness before inserting
the actual IR to do the read back. But we don't always have the liveness
information at the point where we insert IR for readbacks after #86706.

Also expand some debug logging, and address some feedback from #86706.

20 months agoCurrencyNegativePattern can be 16 (#87671)
Alexander Radchenko [Sat, 17 Jun 2023 17:18:31 +0000 (23:18 +0600)]
CurrencyNegativePattern can be 16 (#87671)

20 months agoJIT: Add a check for forward sub store interference (#87615)
Jakob Botsch Nielsen [Sat, 17 Jun 2023 07:45:27 +0000 (09:45 +0200)]
JIT: Add a check for forward sub store interference (#87615)

Forward sub was not taking into account that the source of the candidate
def can contain locals that may be changed by next statement that is
being forward substituted into. For example, it is not legal to forward
substitute V06 in the following case:

```
[000104] DA--G------ ▌  STORE_LCL_VAR short  V06 tmp5
[000109] ----------- └──▌  LCL_VAR   short  V07 tmp6          (last use)

[000139] -A--------- ▌  COMMA     void
[000121] DA--------- ├──▌  STORE_LCL_VAR int    V07 tmp6
[000145] ----------- │  └──▌  CAST      int <- short <- int
[000074] ----------- │     └──▌  CNS_INT   int    1
[000129] UA--------- └──▌  STORE_LCL_FLD short  V00 arg0         [+16]
[000143] -----------    └──▌  CAST      int <- short <- int
[000090] -----------       └──▌  LCL_VAR   int    V06 tmp5          (last use)
```

Fix #87614

20 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220325...
dotnet bot [Sat, 17 Jun 2023 07:35:44 +0000 (09:35 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2203250 (#87714)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2203090

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2203090

20 months agoEnable CS1591 for projects that don't use intellisense package XML file (#84917)
Viktor Hofer [Sat, 17 Jun 2023 07:35:30 +0000 (09:35 +0200)]
Enable CS1591 for projects that don't use intellisense package XML file (#84917)

* Enable CS1591 for projects that don't use intellisense package XML file

* Update Directory.Build.targets

* Update Directory.Build.targets

* Update intellisense.targets

* Update intellisense.targets

* Update Microsoft.NETCore.Platforms.csproj

* Backport docs: Microsoft.Extensions.Hosting.WindowsServices

* Backport docs: Microsoft.Extensions.Hosting.Systemd

* Remove unnecessary full namespaces in triple slash.

* Fix xml comment formatting.

* Update System.Numerics.Tensors.csproj

* Update Microsoft.Extensions.DependencyInjection.Specification.Tests.csproj

* Update System.Threading.RateLimiting.csproj

* Update WindowsServiceLifetimeOptions.cs

* Update SystemdNotifier.cs

* Update Microsoft.Bcl.AsyncInterfaces.csproj

* Update System.Speech.csproj

* Update System.Threading.RateLimiting.csproj

---------

Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
20 months agoCheck Locations length before accessing (#87659)
Sven Boemer [Sat, 17 Jun 2023 02:27:15 +0000 (19:27 -0700)]
Check Locations length before accessing (#87659)

Fixes an `IndexOutOfRangeException` thrown by the analyzer when
analyzing method parameters for the implicitly generated Main
method when using top-level statements. These method parameters
don't have location info because they are not in user code.

This also adds checks in the other places this analyzer accesses
`Locations[0]`, to be safe.

20 months agoInvoke startup hook from ApplyStartupHook diagnostic command (#87490)
Justin Anderson [Sat, 17 Jun 2023 00:20:29 +0000 (17:20 -0700)]
Invoke startup hook from ApplyStartupHook diagnostic command (#87490)

20 months agoFix TLS access on Bionic (#87670)
Michal Strehovský [Fri, 16 Jun 2023 23:49:24 +0000 (08:49 +0900)]
Fix TLS access on Bionic (#87670)

Avoid inlined threadstatics for now.

20 months agoDo not quote rpath passed to linker for Bionic (#87669)
Michal Strehovský [Fri, 16 Jun 2023 23:36:56 +0000 (08:36 +0900)]
Do not quote rpath passed to linker for Bionic (#87669)

* Do not quote rpath passed to linker

Looks like this is preserved literally, with the `'`.

The Android loader doesn't like this: `WARNING: linker: Warning: unable to normalize "'/data/data/com.termux/files/home'" (ignoring)`.

* Update Microsoft.NETCore.Native.Unix.targets

* Apply suggestions from code review

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

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
20 months agoHardcode Debugger.IsAttached to false (#87677)
Michal Strehovský [Fri, 16 Jun 2023 23:36:25 +0000 (08:36 +0900)]
Hardcode Debugger.IsAttached to false (#87677)

Fixes #84736

20 months agoLimit number of tracked values in trim dataflow analysis (#87634)
Sven Boemer [Fri, 16 Jun 2023 23:34:33 +0000 (16:34 -0700)]
Limit number of tracked values in trim dataflow analysis (#87634)

Places a limit on the number of values tracked in our dataflow analysis, to
prevent hangs in the illink analyzer. This avoids hangs when analyzing patterns
that currently lead to an exponential number of tracked values.

20 months agoFix missing assemblyref for typeref only kept for debug info in illink (#87575)
Sven Boemer [Fri, 16 Jun 2023 23:33:31 +0000 (16:33 -0700)]
Fix missing assemblyref for typeref only kept for debug info in illink (#87575)

Fixes https://github.com/dotnet/runtime/issues/86462 by walking
debug info to discover typerefs in the assembly that are only
preserved due to debug info. In this case the assembly has the
'save' action, so the reference to the typeref in the debug info
is not swept. This means that the presence of the typeref in the
final output depends on whether we are linking the PDB. Walking
the typeref will preserve the assemblyref that it refers to,
fixing the issue.

The fix also needs to walk up the parent import scopes,
discovered by reproducing the issue in our test infra.

The behavior needs to depend on whether we are linking debug
symbols, otherwise we will keep the assemblyref (but not the
typeref that uses it) when PDBs are present, and the output
should not depend on the presence of
PDBs. `AssemblyOnlyUsedByUsingSaveAction` tests this case - see
comments in there for more detail.

This includes some unrelated test infra changes (supporting
multiple additional compiler arguments) which were useful for
iterating on this, even though they aren't necessary in the final
version of the testcases.

20 months agoMake JIT-EE interface formatting a little more consistent
Bruce Forstall [Fri, 16 Jun 2023 18:22:12 +0000 (11:22 -0700)]
Make JIT-EE interface formatting a little more consistent

20 months agoRemove slotNum argument from recordRelocation
Bruce Forstall [Fri, 16 Jun 2023 17:56:42 +0000 (10:56 -0700)]
Remove slotNum argument from recordRelocation

20 months agoRemove CORINFO_DESKTOP_ABI
Bruce Forstall [Fri, 16 Jun 2023 17:41:23 +0000 (10:41 -0700)]
Remove CORINFO_DESKTOP_ABI

20 months agoRemove getMethodModule
Bruce Forstall [Fri, 16 Jun 2023 17:34:40 +0000 (10:34 -0700)]
Remove getMethodModule

20 months agoRemove isValidStringRef
Bruce Forstall [Fri, 16 Jun 2023 17:28:44 +0000 (10:28 -0700)]
Remove isValidStringRef

20 months agoRemove isValidToken
Bruce Forstall [Fri, 16 Jun 2023 17:21:25 +0000 (10:21 -0700)]
Remove isValidToken

20 months agoRemove tryResolveToken
Bruce Forstall [Fri, 16 Jun 2023 17:14:43 +0000 (10:14 -0700)]
Remove tryResolveToken

20 months agoRemove isRIDClassDomainID
Bruce Forstall [Thu, 15 Jun 2023 23:43:30 +0000 (16:43 -0700)]
Remove isRIDClassDomainID

20 months agoRemove canAccessFamily
Bruce Forstall [Thu, 15 Jun 2023 23:37:25 +0000 (16:37 -0700)]
Remove canAccessFamily

20 months agoRemove getInlinedCallFrameVptr
Bruce Forstall [Thu, 15 Jun 2023 23:28:31 +0000 (16:28 -0700)]
Remove getInlinedCallFrameVptr

20 months agoRemove findNameOfToken
Bruce Forstall [Thu, 15 Jun 2023 23:23:19 +0000 (16:23 -0700)]
Remove findNameOfToken

20 months agoRemove satisfiesClassConstraints
Bruce Forstall [Thu, 15 Jun 2023 23:14:27 +0000 (16:14 -0700)]
Remove satisfiesClassConstraints

20 months agoRemove mergeClasses
Bruce Forstall [Thu, 15 Jun 2023 23:06:51 +0000 (16:06 -0700)]
Remove mergeClasses

20 months agoRemove isCompatibleDelegate
Bruce Forstall [Thu, 15 Jun 2023 21:54:05 +0000 (14:54 -0700)]
Remove isCompatibleDelegate

20 months agoRemove unused STRESS_PINVOKE_RESTORE_ESP
Bruce Forstall [Thu, 15 Jun 2023 21:23:55 +0000 (14:23 -0700)]
Remove unused STRESS_PINVOKE_RESTORE_ESP

20 months agoClean up JIT flags
Bruce Forstall [Thu, 15 Jun 2023 01:45:13 +0000 (18:45 -0700)]
Clean up JIT flags

1. Remove never set CORJIT_MCJIT_BACKGROUND.
2. Remove never checked CORJIT_PINVOKE_RESTORE_ESP (x86 only). Remove related
`COMPUTED_IS_PRE_V4_ASSEMBLY`, `IS_PRE_V4_ASSEMBLY`, `IsPreV4Assembly()`.
3. Remove unused CORJIT_FEATURE_SIMD.
4. Remove all the "UNUSED" flags, which only cause clutter.
5. Renumber/pack all the remaining flags. Ensure that all flags have unique
numbers, even for different platforms.
6. Add missing flags in a few cases: the JIT/CORJIT equality asserts, mcs "-jitflags"
dumpers, `CorJitFlagToString()`, `CorJitFlag` type.

20 months agoAddress feedback from #87680. (#87695)
Eirik Tsarpalis [Fri, 16 Jun 2023 22:30:41 +0000 (23:30 +0100)]
Address feedback from #87680. (#87695)

* Address feedback from #87680.

* Update src/libraries/System.Text.Json/tests/System.Text.Json.Tests/Serialization/JsonSerializerWrapper.Reflection.cs

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
---------

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
20 months agoEnable async-over-sync FileStream read/writes to be cancelable on Windows (#87103)
Stephen Toub [Fri, 16 Jun 2023 22:07:57 +0000 (18:07 -0400)]
Enable async-over-sync FileStream read/writes to be cancelable on Windows (#87103)

* Enable async-over-sync FileStream read/writes to be cancelable on Windows

Using the same helpers we previously used to enable this in pipe streams on Windows, enable FileStream.Read/WriteAsync on a FileStream created for synchronous I/O to be cancelable.  This also makes some tweaks to those helpers to reduce allocation when a cancelable token is supplied.

* Update src/libraries/Common/src/System/Threading/AsyncOverSyncWithIoCancellation.cs

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
---------

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
20 months agoFully qualify return type on UnreachableException methods (#87661)
Jackson Schuster [Fri, 16 Jun 2023 21:54:02 +0000 (14:54 -0700)]
Fully qualify return type on UnreachableException methods (#87661)

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
20 months agoJIT: Add support for induced field accesses in physical promotion (#87410)
Jakob Botsch Nielsen [Fri, 16 Jun 2023 21:30:03 +0000 (23:30 +0200)]
JIT: Add support for induced field accesses in physical promotion (#87410)

Add support for promoting fields based on the fact that store decomposition
induces new field accesses. To do so we store all struct stores that involve
candidates for physical promotion as part of the initial accounting pass. Then
when picking the replacements we do it as a fixpoint computation, iteratively
expanding the set of replacements based on field accesses induced by store
decomposition with the existing set of replacements.

Fix #87371

20 months agoRestore removed API from Extensions (#85846)
Eric StJohn [Fri, 16 Jun 2023 20:27:26 +0000 (13:27 -0700)]
Restore removed API from Extensions (#85846)

* Restore missing API from Extensions

* Fix a couple missing interfaces

* Fix EventLog test

* Undo interface heirarchy change in hosting

We can't push members down in interfaces.  While this works for implicit
interface implementations, the runtime will fail the type load if the
type explicitly implemented those members in the old interface.

* Add API compat validation for old Extensions baseline

* Bring back less logging API and baseline missing

* Implement obsolete console API

* Fix the download of extensions compat packages

* Remove ConsoleLifetime overload

This method was creating a binding ambiguity for DI.
It has zero usage, so just exclude it.

* Update obsolete message on InplaceStringBuilder

* Fill in implementation of obsolete logging methods

* Update console->config ref dependency

* Update Obsolete messages and make error

* Suppress compat around Obsolete(..., error: true)

* Fix more obsolete messages

* Remove ConsoleLoggerProvider ctor overloads

These don't have much usage and their addition could create problems for
DI Providers.

* Omit ConfigurationSection .ctor overload

This overload has a source compatible replacement, and is only used by
one package in all of nuget.org - which already has assets targeting new
TargetFrameworks which don't depend on this API.

* Remove OptionsWrapper members

These were only available as non-obsolete in 2.0 and there is zero usage
on nuget.org.

* Mark restored obsoleted API as EditorBrowsable=never

* Remove extensions 2.1 compat infrastructure

* Remove unused usings

20 months agoFix invalid lowering for SELECT over mixed neg/not operands (#87674)
SwapnilGaikwad [Fri, 16 Jun 2023 19:18:30 +0000 (20:18 +0100)]
Fix invalid lowering for SELECT over mixed neg/not operands (#87674)

20 months agoUpdate dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimizati...
dotnet-maestro[bot] [Fri, 16 Jun 2023 17:39:30 +0000 (12:39 -0500)]
Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230615.5 (#87686)

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

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
20 months agofix(66900): Adding test for confirm bug fix. (#87167)
Maksim Golev [Fri, 16 Jun 2023 16:32:56 +0000 (20:32 +0400)]
fix(66900): Adding test for confirm bug fix. (#87167)

Co-authored-by: Maksim Golev <mgolev@htc-cs.ru>
20 months ago[hot reload][mono] Implement support for adding static and instance fields to generic...
Aleksey Kliger (λgeek) [Fri, 16 Jun 2023 16:19:17 +0000 (12:19 -0400)]
[hot reload][mono] Implement support for adding static and instance fields to generic classes (#87285)

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

* new test adding a generic field

* workaround roslyn issue to generate generic static field test

   https://github.com/dotnet/roslyn/issues/68293 we get an error if we add a generic field and try to use it during the same edit. workaround is to do two separate edits

* implement hot reload for static fields in generics

   ldsflda seems to be working

* Add a generic instance add instance field test

* add reflection testing to the generic instance added field test

* fixup valuetype loads

* add non-generic valuetype ldflda test

* Mark failing tests for CoreCLR

* light up GenericAddFieldToExistingType capability

* use interp_emit_ldobj for metadata-update; add barrier if volatile

20 months agoFix `File.Copy` onto a symlink on macOS (#87600)
Hamish Arblaster [Fri, 16 Jun 2023 16:05:53 +0000 (02:05 +1000)]
Fix `File.Copy` onto a symlink on macOS (#87600)

* Initial commit

* Fix compile error

* Update SafeFileHandle.Unix.cs

* Fix macOS compilation errors

* Somehow I forgot overwrite = true

* Implement feedback

20 months ago[mono][interp] Fix concurrency issues with publishing transfomed imethod (#87555)
Vlad Brezae [Fri, 16 Jun 2023 15:22:22 +0000 (18:22 +0300)]
[mono][interp] Fix concurrency issues with publishing transfomed imethod (#87555)

* [mono][utils] Move all membar code to single file

* [mono][utils] Redefine write and read memory barriers

Before this change they were doing a full memory barrier, regardless of architecture. We have a beginning of more precise implementation via the *_FENCE defines. Implement mono_memory_write_barrier and mono_memory_read_barrier reusing these defines instead.

The only consequence of this change is that, on x86 and amd64, `mono_memory_write_barrier` and `mono_memory_read_barrier` become a compiler barrier instead of a full mfence.

* [mono][interp] Fix concurrency issues with publishing transfomed imethod

When publishing a transformed InterpMethod*, we first set all relevant fields (like `code`, `alloca_size` etc), we execute a write barrier and finally we set the `transformed` flag. On relaxed memory arches we need to have a read barrier on the consumer, since there is no data dependency between `transformed` and the other fields of `InterpMethod`.

On arm this change does a full barrier (we could get away with just a load acquire but we haven't yet added support for emitting this in the runtime). Still, this doesn't seem to introduce a heavy perf penalty (on my arm64 M1) but we can revisit if necessary. On x86/amd64 this is a compiler barrier so it should have no impact. WASM is single threaded for now.

20 months agoUnblock CI by removing AlmaLinux from libraries tests (#87668)
Andy Gocke [Fri, 16 Jun 2023 14:41:30 +0000 (07:41 -0700)]
Unblock CI by removing AlmaLinux from libraries tests (#87668)

Tracking issue: https://github.com/dotnet/runtime/issues/87667

20 months agoFix broken link in editing-and-debugging.md (#87681)
Eric Mutta [Fri, 16 Jun 2023 13:00:16 +0000 (16:00 +0300)]
Fix broken link in editing-and-debugging.md (#87681)

20 months agoAttempt to fix browser-wasm test failures. (#87680)
Eirik Tsarpalis [Fri, 16 Jun 2023 12:50:21 +0000 (13:50 +0100)]
Attempt to fix browser-wasm test failures. (#87680)

* Attempt to fix browser-wasm test failures.

* Address feedback.

20 months agoFix DependencyModel tests on NativeAOT (#87666)
Eric Erhardt [Fri, 16 Jun 2023 12:40:11 +0000 (07:40 -0500)]
Fix DependencyModel tests on NativeAOT (#87666)

20 months agoFix broken link in CONTRIBUTING.md (#87685)
Eric Mutta [Fri, 16 Jun 2023 12:37:23 +0000 (15:37 +0300)]
Fix broken link in CONTRIBUTING.md (#87685)

Update link to point to the [Pull Request Guide](https://github.com/dotnet/runtime/blob/main/docs/workflow/ci/pr-guide.md) in its current location.

20 months ago[mono][llvm] Fixed personality function on Windows (#87675)
Jan Dupej [Fri, 16 Jun 2023 11:50:19 +0000 (13:50 +0200)]
[mono][llvm] Fixed personality function on Windows (#87675)

* Fixed personality function on Windows.

* Removed unnecessary files.

20 months agoReimplement NegotiateStream using (mostly) public NegotiateAuthenticaton API (#86948)
Filip Navara [Fri, 16 Jun 2023 10:47:47 +0000 (12:47 +0200)]
Reimplement NegotiateStream using (mostly) public NegotiateAuthenticaton API (#86948)

* Reimplement NegotiateStream using (mostly) public NegotiateAuthentication API

* Minor adjustment to NegotiateStreamPal on Android/tvOS to allow NegotiateStream to work

* Remove unrelated ApiCompat
suppression changes

20 months agoFix redundant MethodInfo lookup in UnixNativeCodeManager (#87664)
Jan Kotas [Fri, 16 Jun 2023 08:17:59 +0000 (01:17 -0700)]
Fix redundant MethodInfo lookup in UnixNativeCodeManager (#87664)

Fixes #75807

20 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220232...
dotnet bot [Fri, 16 Jun 2023 07:10:57 +0000 (09:10 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2202323 (#87660)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2202051

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2202051

20 months agoRemove dead code (#87399)
Filip Navara [Fri, 16 Jun 2023 05:43:29 +0000 (07:43 +0200)]
Remove dead code (#87399)

20 months agoBuild integration support for Bionic in NativeAOT (#87595)
Michal Strehovský [Fri, 16 Jun 2023 05:25:31 +0000 (14:25 +0900)]
Build integration support for Bionic in NativeAOT (#87595)

Doesn't actually work E2E because the inline threadstatics work broke our Android support (the one added in https://github.com/dotnet/corert/pull/8323).

```
  C:\Users\michals\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-preview.6.23307.4/r
  untimes/linux-bionic-arm64/\native\libRuntime.WorkstationGC.a(MiscStubs.S.o): In function `RhpGetInlinedThreadStaticB
  ase':
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
```

20 months ago[Mono] Add mono hot reload support for updating parameter name (#85796)
Fan Yang [Fri, 16 Jun 2023 04:53:52 +0000 (00:53 -0400)]
[Mono] Add mono hot reload support for updating parameter name (#85796)

Fixes #56626
Fixes #50978

* Add mono hot reload support for updating parameter name

* Add a debugger test

* Don't invalidate the whole assembly when using hot reload

* don't ignore reflection cache entries when the "no invalidate" flag is set

---------

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
20 months agoAdd DebuggerDisplay to some hosting types (#87599)
James Newton-King [Fri, 16 Jun 2023 04:17:52 +0000 (12:17 +0800)]
Add DebuggerDisplay to some hosting types (#87599)

20 months agoRemove KeyValuePairConverter. (#87637)
Eirik Tsarpalis [Fri, 16 Jun 2023 04:11:07 +0000 (05:11 +0100)]
Remove KeyValuePairConverter. (#87637)

20 months agoFaster optimized frozen dictionary creation (2/n) (#87630)
Adam Sitnik [Fri, 16 Jun 2023 04:10:16 +0000 (06:10 +0200)]
Faster optimized frozen dictionary creation (2/n) (#87630)

* use stackalloc for smaller sizes

* Revert "use stackalloc for smaller sizes", it did not help much

This reverts commit 204e1752d828fac0f772d144b0daaf7dd4ab93ec.

* let the caller of FrozenHashTable.Create provide the hashcodes, it avoids a closure, index boundary checks and helps with inlining (7% gain)

in case of hash set of integers it avoids renting and copying all integers to just have a copy of them

* keys and values are needed for every strategy, lets create them up-front (2-4% gain)

* in CreateLengthBucketsFrozenDictionaryIfAppropriate iterate over array rather than dictionary
* in OrdinalStringFrozenDictionary ctor avoid creating a copy of all entires (we already have a copy of keys)

* refactor: there is no need to pass entriesLength anymore (hashCodes.Length is the replacement)

20 months agoAdd ContainsAny{Except} (#87621)
Miha Zupan [Fri, 16 Jun 2023 04:03:27 +0000 (06:03 +0200)]
Add ContainsAny{Except} (#87621)

* Add ContainsAny{Except}

* Use it everywhere

* Test coverage

* Fix ContainsAny on a string

* Reword summaries on ContainsAny

* Appease older TFMs

* Revert TestFilter.cs changes

* Appease older TFMs part 2

20 months ago[wasm] Fix inclusion of `marshal-ilgen` component (#87629)
Ankit Jain [Fri, 16 Jun 2023 03:00:20 +0000 (23:00 -0400)]
[wasm] Fix inclusion of `marshal-ilgen` component (#87629)

* [wasm] Fix inclusion of `marshal-ilgen`

Issue: `marshal-ilgen` component never included

Reason:
The item inclusion was being done *outside* any targets, which would get
evaluated *before* any targets are run.

But the item that it depends on to decide whether to include
`marshal-ilgen` is in target
`_ScanAssembliesDecideLightweightMarshaler`.

This broke microbenchmarks with:
```
Error: [MONO] * Assertion at /__w/1/s/src/mono/mono/component/marshal-ilgen-stub.c:28, condition `!m_type_is_byref(t)' not met

    at ft (/home/helixbot/work/96640802/w/B9C40A15/e/performance/artifacts/bin/for-running/MicroBenchmarks/fa21f9df-08d0-43a4-b28d-0078821ea492/bin/net8.0/browser-wasm/AppBundle/dotnet.runtime.js:3:12422)
    at mt (/home/helixbot/work/96640802/w/B9C40A15/e/performance/artifacts/bin/for-running/MicroBenchmarks/fa21f9df-08d0-43a4-b28d-0078821ea492/bin/net8.0/browser-wasm/AppBundle/dotnet.runtime.js:3:12676)
    at wasm_trace_logger (wasm://wasm/00a5f7d6:wasm-function[7879]:0x1e41d0)
    at eglib_log_adapter (wasm://wasm/00a5f7d6:wasm-function[581]:0x37fbb)
    at monoeg_g_logv_nofree (wasm://wasm/00a5f7d6:wasm-function[504]:0x35f57)
    at monoeg_assertion_message (wasm://wasm/00a5f7d6:wasm-function[508]:0x36078)
    at mono_assertion_message (wasm://wasm/00a5f7d6:wasm-function[510]:0x360bb)
    at stub_emit_marshal_ilgen (wasm://wasm/00a5f7d6:wasm-function[1300]:0x66db1)
    at mono_emit_marshal (wasm://wasm/00a5f7d6:wasm-function[1820]:0x8990b)
    at emit_native_wrapper_ilgen (wasm://wasm/00a5f7d6:wasm-function[2651]:0xb86de)
```

* [wasm] WBT: Use sdk 8.0.100-preview.6.23314.19

.. to workaround https://github.com/dotnet/runtime/issues/87647 .

* [wasm] Add test for marshal-ilgen - wbt

* add missing file

20 months agoMake virtual delegate targets less costly (#87308)
Michal Strehovský [Fri, 16 Jun 2023 00:55:40 +0000 (09:55 +0900)]
Make virtual delegate targets less costly (#87308)

Saves 1.5% on the Stage2 app.

We make sure delegate targets are reflection visible to support Delegate.GetMethodInfo. When I originally did this work in #70198 I made a shortcut to avoid yet another node kind in the system (with a giant comment explaining what the problem is). But there's a lot of benefit in having this new node for apps with many reflection visible virtual methods.

20 months ago[Mono] Add the capability of trimming IL code of individual methods (#86722)
Fan Yang [Fri, 16 Jun 2023 00:54:31 +0000 (20:54 -0400)]
[Mono] Add the capability of trimming IL code of individual methods (#86722)

* Add the capability of trimming individual methods

* Fix build errors

* Remove printf's

* Add the option to use compiled-methods-outfile

* Avoid trimming shared methods when they are still in use

* Add parameter description

* Add the option to trim compiled methods

* Address review feedback

* Add metadata MethodTokenFile to CompiledAssemblies

* Add GUID checks and use metadata of assemblies

* Create smaller functions and use hex value

* Update src/tasks/AotCompilerTask/MonoAOTCompiler.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Move parameter validation code

* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Add more error handling

* Provide a list of trimmed assemblies as output

* Update src/tasks/MonoTargetsTasks/ILStrip/ILStrip.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Address coding style feedbacks

* Fix var anmes

* Delete trimmed assemblies after copy

---------

Co-authored-by: Ankit Jain <radical@gmail.com>
20 months agoDon't set mark array bits for UOH objects during concurrent marking (#87533)
Maoni Stephens [Thu, 15 Jun 2023 23:01:12 +0000 (16:01 -0700)]
Don't set mark array bits for UOH objects during concurrent marking (#87533)

marking UOH objects was a historical thing from a policy we had a long time ago. and I had been meaning to get rid of it. a recent workitem we needed to do makes this actually a necessity.

20 months agoUpdate dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimizati...
dotnet-maestro[bot] [Thu, 15 Jun 2023 22:53:19 +0000 (17:53 -0500)]
Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build 20230614.6 (#87609)

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

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
20 months agoRe-enable disabled BigInteger tests. (#87640)
Eirik Tsarpalis [Thu, 15 Jun 2023 22:45:21 +0000 (23:45 +0100)]
Re-enable disabled BigInteger tests. (#87640)

20 months agoAdd regression testing for #76802. (#87632)
Eirik Tsarpalis [Thu, 15 Jun 2023 21:26:38 +0000 (22:26 +0100)]
Add regression testing for #76802. (#87632)

20 months agoImplement ExperimentalAttribute (#85444)
Igor Velikorossov [Thu, 15 Jun 2023 21:13:20 +0000 (07:13 +1000)]
Implement ExperimentalAttribute (#85444)

Resolves #77869

20 months agoAdd DOTNET_JitDisasmWithCodeBytes (#87580)
Bruce Forstall [Thu, 15 Jun 2023 21:09:24 +0000 (14:09 -0700)]
Add DOTNET_JitDisasmWithCodeBytes (#87580)

Setting this to non-zero will display the generated code bytes in the disassembly listings.

e.g.,
```
49B910577431FA7F0000 mov      r9, 0x7FFA31745710
```

By default, it is not set and the code bytes are not displayed.

This change splits this off from the DEBUG-only `DOTNET_JitDasmWithAddress` setting.

It is available in Release.

20 months agoIgnore CORJIT_FLAG_VECTOR512_THROTTLING sometimes under stress (#87631)
Bruce Forstall [Thu, 15 Jun 2023 21:09:00 +0000 (14:09 -0700)]
Ignore CORJIT_FLAG_VECTOR512_THROTTLING sometimes under stress (#87631)

20 months agoAdd missing API docs to RateLimiting (#87627)
Brennan [Thu, 15 Jun 2023 19:53:35 +0000 (12:53 -0700)]
Add missing API docs to RateLimiting (#87627)

20 months agoEnsure the JIT consistently does opportunistic queries for its optimizations (#87620)
Tanner Gooding [Thu, 15 Jun 2023 19:35:55 +0000 (12:35 -0700)]
Ensure the JIT consistently does opportunistic queries for its optimizations (#87620)

20 months ago[mono][exceptions] Don't attempt to catch StackOverflowException (#87601)
Vlad Brezae [Thu, 15 Jun 2023 19:18:21 +0000 (22:18 +0300)]
[mono][exceptions] Don't attempt to catch StackOverflowException (#87601)

* [mono][exceptions] Don't attempt to catch StackOverflowException

* [mono][exceptions] Don't invoke ToString when logging StackOveflowException

Invoking ToString can trigger method compilations and put pressure on the stack space. Instead, build the output directly from the `exc->trace_ips` with already existing methods.

* Remove unused variable

20 months ago[mono][interp] Refactor icall opcodes (#87269)
Vlad Brezae [Thu, 15 Jun 2023 19:17:59 +0000 (22:17 +0300)]
[mono][interp] Refactor icall opcodes (#87269)

* [mono][interp] Use MINT_CALLI_NAT_FAST opcode instead of MINT_ICALL_*

MINT_ICALL_* opcodes are pretty much dead and untested

* [mono][interp] Remove duplicated code

* [mono][interp] Add new generic icall opcode

Having the signature hardcoded in the opcode seems overkill for icalls.

* [mono][interp] Remove per signature CALLI opcodes

* Remove code in jiterp

* [mono][interp] Rename defines

* [mono][interp] Opcode data consistency

* [mono][interp] Fix jiterp build

20 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220168...
dotnet bot [Thu, 15 Jun 2023 17:01:09 +0000 (19:01 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201684 (#87613)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201520

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201520

20 months agoSHAKE128 and SHAKE256
Kevin Jones [Thu, 15 Jun 2023 16:49:11 +0000 (12:49 -0400)]
SHAKE128 and SHAKE256

20 months agoFix parameter ordering and value in gtNewColonNode (#87366)
Huo Yaoyuan [Thu, 15 Jun 2023 16:27:27 +0000 (00:27 +0800)]
Fix parameter ordering and value in gtNewColonNode (#87366)

20 months agoStop setting HelixResultsDestinationDir (#86413)
Bruce Forstall [Thu, 15 Jun 2023 15:33:58 +0000 (08:33 -0700)]
Stop setting HelixResultsDestinationDir (#86413)

Use the default, which is `$(BUILD_SOURCESDIRECTORY)\artifacts\helixresults`

Fixes #75169

20 months agoFix mcs missing flags (#87584)
Bruce Forstall [Thu, 15 Jun 2023 15:04:57 +0000 (08:04 -0700)]
Fix mcs missing flags (#87584)

When a new JIT flag is added, it needs to be added to spmidumphelper.cpp as well.

20 months ago[mono][simd] Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64 (#87607)
Milos Kotlar [Thu, 15 Jun 2023 14:54:39 +0000 (16:54 +0200)]
[mono][simd] Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64 (#87607)

* Add MONO_TYPE_I and MONO_TYPE_U types for OP_NEGATION on amd64

* Use TYPE_I64 for MONO_TYPE_I and MONO_TYPE_U types

20 months agoAvoid linking to non-existent System.Net.Security.Native on tvOS (#87605)
Filip Navara [Thu, 15 Jun 2023 14:15:33 +0000 (16:15 +0200)]
Avoid linking to non-existent System.Net.Security.Native on tvOS (#87605)

20 months ago`UnsafeAccessorAttribute` non-generic support (#86932)
Aaron Robinson [Thu, 15 Jun 2023 13:59:49 +0000 (06:59 -0700)]
`UnsafeAccessorAttribute` non-generic support (#86932)

* CoreCLR and NativeAOT

* Add UnsafeAccessorAttribute API

* Implement IL generation for all accessor paths

* Implement static/instance field lookup - non-generic

* Implement static/instance method lookup - non-generic

* Defined ambiguity logic with respect to
custom modifiers.
- First pass ignore custom modifiers
- If ambiguity detected, rerun algorithm but
  require precise matching of custom modifiers.
- If there is no clear match throw AmbiguousImplementationException.

* Cleanup memory management confusion
with ILStubResolver.

* Fix non-standard C++

* Remove CORINFO_MODULE_ALLACCESS scope

* Remove enum METHOD_TYPE.

* Update BOTR on TypeDesc

20 months agoAdd managed entry points for raising Contention events (#87087)
Koundinya Veluri [Thu, 15 Jun 2023 13:36:33 +0000 (06:36 -0700)]
Add managed entry points for raising Contention events (#87087)

* Add managed entry points for raising Contention events

- Added the events similarly to how the PortableThreadPool events are currently set up. They may need further tweaking to make them work from NativeAOT.
- The events are not raised anywhere from the managed side yet, it's expected that they will eventually be raised by a new Lock type and at least by NativeAOT's Lock

20 months agoRemove some unnecessary Substrings (#87479)
Stephen Toub [Thu, 15 Jun 2023 12:40:56 +0000 (08:40 -0400)]
Remove some unnecessary Substrings (#87479)

* Remove some unnecessary Substrings

* Address PR feedback

20 months agoMake the soure generator format enums using their identifiers rather than numeric...
Eirik Tsarpalis [Thu, 15 Jun 2023 12:32:19 +0000 (13:32 +0100)]
Make the soure generator format enums using their identifiers rather than numeric values. (#87557)

* Make the soure generator format enums using their identifiers rather than numeric values.

* Address feedback

20 months ago[RISC-V][JIT] Fix FCVT (#87591)
Dong-Heon Jung [Thu, 15 Jun 2023 11:54:42 +0000 (20:54 +0900)]
[RISC-V][JIT] Fix FCVT (#87591)

20 months ago[RISC-V] Fix struct passing on reflection calls (#87535)
t-mustafin [Thu, 15 Jun 2023 11:53:56 +0000 (14:53 +0300)]
[RISC-V] Fix struct passing on reflection calls (#87535)

20 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 220139...
dotnet bot [Thu, 15 Jun 2023 10:08:46 +0000 (12:08 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201397 (#87570)

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2200838

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2200838

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201000

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201000

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201301

* Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2201301

20 months agoJitdump fixes (#87547)
David Mason [Thu, 15 Jun 2023 07:03:13 +0000 (00:03 -0700)]
Jitdump fixes (#87547)

20 months agoPackage static libraries into NativeAOT runtime pack (#87594)
Michal Strehovský [Thu, 15 Jun 2023 06:27:14 +0000 (15:27 +0900)]
Package static libraries into NativeAOT runtime pack (#87594)

The iOS one only gets them because of the TargetsMobile condition. This condition is not true for bionic.

20 months agoReport warnings for COM interfaces with instance properties or events (#87492)
Jeremy Koritzinsky [Thu, 15 Jun 2023 04:01:05 +0000 (21:01 -0700)]
Report warnings for COM interfaces with instance properties or events (#87492)

20 months agoEnable option to use the Windows ThreadPool (#85373)
Eduardo Velarde [Thu, 15 Jun 2023 01:50:10 +0000 (18:50 -0700)]
Enable option to use the Windows ThreadPool (#85373)

When running on Windows, enable an option to switch between the Portable thread pool and the Windows thread pool.

This change targets NativeAOT, CoreCLR, and Mono.

Windows threadpool remains as the default for NativeAOT on Windows. For any other case the Portable thread pool remains the default.

Tests with the Windows thread pool enabled were added to the System.Threading.Threadpool solution.

Trimming is enabled to remove the unused thread pool.
---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Koundinya Veluri <kouvel@users.noreply.github.com>
20 months ago[wasm] Don't use `_WasmDevel=true` when publishing (#87544)
Ankit Jain [Thu, 15 Jun 2023 01:24:46 +0000 (21:24 -0400)]
[wasm] Don't use `_WasmDevel=true` when publishing (#87544)

* [wasm] Add missing Wasm.Build.Tests.Blazor.AppsettingsTests to list of tests to run

* [wasm] CI: Trigger only wasm jobs on workload-testing.targets changes, since only wasm is using this currently

* [wasm] host: Add `--no-silent` command line parameter

- this is the equivalent to `--verbose`
- The default is "silent" behavior

Cannot use `--verbose` because that conflicts with `dotnet run`.

* [wasm] WBT: Update template tests to use `--no-silent` with `dotnet run`

.. which would be useful in debugging tests.

* [wasm] Don't use _WasmDevel=true whenever publishing

`_WasmDevel=true` causes the optimization flags to be `-O0`.

- This *was* automatically set whenever `Configuration=Debug`, and
`WasmBuildNative=true`, which is useful when relinking in inner loop.
- But when publishing, and relinking/AOT, `-O0` results in larger output.

* Update src/mono/wasm/host/JSEngineHost.cs

* Address feedback from @ilonatommy

20 months agoExtend Task.FromResult default task optimization to 16 byte unmanaged types (#87541)
Stephen Toub [Thu, 15 Jun 2023 01:14:55 +0000 (21:14 -0400)]
Extend Task.FromResult default task optimization to 16 byte unmanaged types (#87541)

* Extend Task.FromResult default task optimization to 16 byte unmanaged types

For years, async methods / Task.FromResult has cached a `Task<T>` for `default(T)`, however it was only used when the result value was null.  Earlier in this release we extended that optimization to also use the default task when the value was 1, 2, 4, or 8 bytes (and not a reference type).  This extends that further to also handle types that are 16 bytes, so as to include types like Decimal, Guid, Int128, and DateTimeOffset.

* Fix tests to accomodate additional use of default cached task

20 months agoFix a warning. (#87573)
Zoltan Varga [Wed, 14 Jun 2023 23:11:01 +0000 (19:11 -0400)]
Fix a warning. (#87573)

20 months ago[iOS][maccatalyst] Reenable MacCatalyst and Simulator CI runs (#84930)
Mitchell Hwang [Wed, 14 Jun 2023 23:05:39 +0000 (19:05 -0400)]
[iOS][maccatalyst] Reenable MacCatalyst and Simulator CI runs (#84930)

This reverts commit 67b6e81d9d2fca8544d37f04998d352bdc0fd69e.

Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
Co-authored-by: Meri Khamoyan <merikhamoyan@microsoft.com>
20 months agoRemove a couple of asserts, which are no longer valid, from getMaxVectorTByteLength...
Tanner Gooding [Wed, 14 Jun 2023 22:30:12 +0000 (15:30 -0700)]
Remove a couple of asserts, which are no longer valid, from getMaxVectorTByteLength (#87504)

20 months agoFix StrictlyBlittable check to work for "source Compilation" references. (#87507)
Jeremy Koritzinsky [Wed, 14 Jun 2023 22:06:53 +0000 (15:06 -0700)]
Fix StrictlyBlittable check to work for "source Compilation" references. (#87507)

20 months agoHandle a null operation type (for example if the null literal is being cast/assigned...
Jeremy Koritzinsky [Wed, 14 Jun 2023 22:06:07 +0000 (15:06 -0700)]
Handle a null operation type (for example if the null literal is being cast/assigned to a ComImport interface type). (#87566)

Co-authored-by: Jackson Schuster <36744439+jtschuster@users.noreply.github.com>
20 months ago[browser][debugger][MT] Make operations on dictionary thread-safe follow-up (#87474)
Ilona Tomkowicz [Wed, 14 Jun 2023 22:05:51 +0000 (00:05 +0200)]
[browser][debugger][MT] Make operations on dictionary thread-safe follow-up (#87474)

* Revert unintentionally removed logging.

* Fix

20 months ago[main] Update dependencies from dotnet/roslyn-analyzers (#87272)
dotnet-maestro[bot] [Wed, 14 Jun 2023 20:12:43 +0000 (15:12 -0500)]
[main] Update dependencies from dotnet/roslyn-analyzers (#87272)

* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230607.1

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23275.7 -> To Version 3.3.5-beta1.23307.1

* Update dependencies from https://github.com/dotnet/roslyn-analyzers build 20230608.2

Microsoft.CodeAnalysis.Analyzers , Microsoft.CodeAnalysis.NetAnalyzers
 From Version 3.3.5-beta1.23275.7 -> To Version 3.3.5-beta1.23308.2

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
20 months ago[Mono] Update Mono build README.md (#87517)
Fan Yang [Wed, 14 Jun 2023 19:58:14 +0000 (15:58 -0400)]
[Mono] Update Mono build README.md (#87517)

Added one more useful switch `-p:KeepNativeSymbols=true`