platform/upstream/dotnet/runtime.git
12 months agoJIT: Set method context for delegate GDV (#89499)
Jakob Botsch Nielsen [Thu, 27 Jul 2023 08:47:55 +0000 (10:47 +0200)]
JIT: Set method context for delegate GDV (#89499)

Instead of passing through the IL context, update the method context to
be the exact method that were recorded in the delegate (which will
include the full instantiation).

Also do a bit of clean up.

Fix #89495

12 months agoRemove unused suppressions for System.Linq.Expressions (#89524)
Eric StJohn [Thu, 27 Jul 2023 07:36:50 +0000 (00:36 -0700)]
Remove unused suppressions for System.Linq.Expressions (#89524)

12 months agoFlush the gclog after GC (#88222)
Andrew Au [Thu, 27 Jul 2023 05:26:32 +0000 (22:26 -0700)]
Flush the gclog after GC (#88222)

12 months agoEnsure that `EqualsAny(x & y, Zero)` uses the right `GenCondition` (#89544)
Tanner Gooding [Thu, 27 Jul 2023 05:03:12 +0000 (22:03 -0700)]
Ensure that `EqualsAny(x & y, Zero)` uses the right `GenCondition` (#89544)

* Adding more tests covering specialzied vector comparisons against zero

* Ensure that `EqualsAny(x & y, Zero)` uses the right `GenCondition`

12 months agoIUnknown is also valid for IClassFactory (#89540)
Aaron Robinson [Thu, 27 Jul 2023 04:08:48 +0000 (21:08 -0700)]
IUnknown is also valid for IClassFactory (#89540)

12 months agoDisable networking in XML resolver in AOT compilers (#89489)
Michal Strehovský [Thu, 27 Jul 2023 03:31:53 +0000 (12:31 +0900)]
Disable networking in XML resolver in AOT compilers (#89489)

Use the switch introduced in #84169. The AOT compilers don't need this. Speeds up the build by a couple seconds because we no longer compile garbage. Shrinks size of ilc.exe from 15.2 MB to 11.1 MB.

One the Native AOT side, this will only kick in once we update the SDK used to build the repo to something that has this (RC1?). On the crossgen2 side this takes effect immediately.

12 months agoFix hits for additional case added to analyzer CA2249 (#89542)
Carlos Sánchez López [Thu, 27 Jul 2023 02:29:08 +0000 (19:29 -0700)]
Fix hits for additional case added to analyzer CA2249 (#89542)

12 months agoTrim trailing space (#89541)
Andrew Au [Thu, 27 Jul 2023 01:49:10 +0000 (18:49 -0700)]
Trim trailing space (#89541)

12 months agoFix hits for new analyzer CA1862 (#89539)
Carlos Sánchez López [Thu, 27 Jul 2023 01:33:39 +0000 (18:33 -0700)]
Fix hits for new analyzer CA1862 (#89539)

12 months agohandle QUIC_STATUS_ADDRESS_NOT_AVAILABLE (#89362)
Tomas Weinfurt [Thu, 27 Jul 2023 00:16:37 +0000 (17:16 -0700)]
handle QUIC_STATUS_ADDRESS_NOT_AVAILABLE (#89362)

* handle QUIC_STATUS_ADDRESS_NOT_AVAILABLE

* Update src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic.cs

Co-authored-by: Marie Píchová <11718369+ManickaP@users.noreply.github.com>
---------

Co-authored-by: Marie Píchová <11718369+ManickaP@users.noreply.github.com>
12 months agoCheck for dotnet.dll when enumerating SDK paths (#89333)
Elinor Fung [Wed, 26 Jul 2023 22:32:59 +0000 (15:32 -0700)]
Check for dotnet.dll when enumerating SDK paths (#89333)

The host treats the existence of a versioned folder under sdk as a valid SDK path. We've seen this cause confusion as users can end up in this state without their knowledge (for example, uninstall leaves an empty folder - which would normally be harmless, except when we try to use it as a valid SDK).

This adds a check for dotnet.dll instead of just the existence of the directory.

12 months agoFix TraceSwitch to synchronize the Value and Level properties (#89278)
Tarek Mahmoud Sayed [Wed, 26 Jul 2023 21:36:33 +0000 (14:36 -0700)]
Fix TraceSwitch to synchronize the Value and Level properties (#89278)

12 months ago[LoongArch64] fix the compiling errors within the CLFS linux (#89422)
Qiao Pengcheng [Wed, 26 Jul 2023 21:00:34 +0000 (05:00 +0800)]
[LoongArch64] fix the compiling errors within the CLFS linux (#89422)

* [LoongArch64] fix the compiling errors after
the linux-kernel and llvm had supported the LoongArch.

* amend code for CR.

* fix the error for code formate.

12 months agoImprove case-insensitive prefix extraction in Regex (#89449)
Stephen Toub [Wed, 26 Jul 2023 20:29:06 +0000 (16:29 -0400)]
Improve case-insensitive prefix extraction in Regex (#89449)

I hit this when writing a benchmark I expected to work well and found that it didn't. In .NET 8 we now extract a prefix to search for even if it's OrdinalIgnoreCase, but we weren't skipping over zero-width assertions, which meant a simple search like "\bword\b" with IgnoreCase would not find the text "word".

12 months agoImprove Http test timeout exception information (#89505)
Miha Zupan [Wed, 26 Jul 2023 19:54:38 +0000 (21:54 +0200)]
Improve Http test timeout exception information (#89505)

* Improve Http test timeout exception information

* Fix TestHelper references

12 months agoAvoid some rune iteration in GetEncodedTruncatedBytesFromString (#89458)
Stephen Toub [Wed, 26 Jul 2023 17:59:24 +0000 (13:59 -0400)]
Avoid some rune iteration in GetEncodedTruncatedBytesFromString (#89458)

When the Zip/TarArchive is using UTF8 as an encoding, it iterates through all the runes in the input to determine how much of the encoded text it can fit in the specified limit. We don't need to do that in the common case where the input is guaranteed to fit because the maximum length of a UTF8 payload is under the specified max.

12 months ago[browser] enable mono_gc_is_critical_method for MT build (#88735)
Pavel Savara [Wed, 26 Jul 2023 17:55:30 +0000 (19:55 +0200)]
[browser] enable mono_gc_is_critical_method for MT build (#88735)

12 months agoSPMI: Fix a couple of replay/record bugs (#89443)
Jakob Botsch Nielsen [Wed, 26 Jul 2023 17:29:32 +0000 (19:29 +0200)]
SPMI: Fix a couple of replay/record bugs (#89443)

* Avoid mutating constrained token in CEEInfo::getCallInfo

For certain calls the EE would modify the constrained token passed to
getCallInfo. This token is an in-argument, and SPMI does not expect it
to be modified. Fix the EE to make a local copy when it needs to mutate
it.

* SPMI: Fix treatment of CORINFO_FLG_BAD_INLINEE during replay

- Save union of method attributes set by the JIT from
  recSetMethodAttribs calls
- Fix bit handling in repGetMethodAttribs
- Add the same method attribs handling to repGetCallInfo that
  repGetMethodAttribs has

This fixes an issue where we could have recorded an old result of
getCallInfo without CORINFO_FLG_DONT_INLINE set. If the JIT then calls
repSetMethodAttribs(CORINFO_FLG_BAD_INLINEE) this would not be reflected
in subsequent calls to getCallInfo, causing possible misses.

12 months agoAdd System.IO.Packaging test that checks with reflection that the ZipArchiveEntry...
Carlos Sánchez López [Wed, 26 Jul 2023 16:58:31 +0000 (09:58 -0700)]
Add System.IO.Packaging test that checks with reflection that the ZipArchiveEntry general purpose bit flag unicode value is unset. (#88978)

12 months agoSet the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE (#88072)
Jan Vorlicek [Wed, 26 Jul 2023 16:48:32 +0000 (18:48 +0200)]
Set the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE (#88072)

* Set the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE

This change makes setting the `CORINFO_EH_CLAUSE_SAMETRY` on
`CORINFO_EH_CLAUSE` to happen for coreclr to. It is a prerequisity for the
port of exception handling from nativeaot to coreclr and it is a noop on
coreclr with the old exception handling.

* Fix comments

* Add clr-abi note and r2rdump support for the flag

* Fix markdown LINT error

* Update docs/design/coreclr/botr/clr-abi.md

* Update docs/design/coreclr/botr/clr-abi.md

* Update the ABI doc

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
12 months agoFix STJ source gen support for System.BinaryData. (#89454)
Eirik Tsarpalis [Wed, 26 Jul 2023 15:54:13 +0000 (16:54 +0100)]
Fix STJ source gen support for System.BinaryData. (#89454)

* Fix STJ source gen support for System.BinaryData.

* remove redundant sealed keyword from converter overrides

* Generate compatibility suppressions

* Add comment to compatibility suppressions

12 months ago[HTTP] Catch and ignore exception from an external server (#89452)
Marie Píchová [Wed, 26 Jul 2023 14:29:36 +0000 (16:29 +0200)]
[HTTP] Catch and ignore exception from an external server (#89452)

* Catch and ignore exception from an external server

* Update src/libraries/Common/tests/System/Net/Http/HttpClientHandlerTest.RemoteServer.cs

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
* Fixed framework build

---------

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
12 months agoAdd test case for RavenDB's AV issue (#89493)
Egor Bogatov [Wed, 26 Jul 2023 14:17:12 +0000 (16:17 +0200)]
Add test case for RavenDB's AV issue (#89493)

12 months ago[wasm][debugger] Adding test for #42421 (#89395)
Thays Grazia [Wed, 26 Jul 2023 14:04:04 +0000 (11:04 -0300)]
[wasm][debugger] Adding test for #42421 (#89395)

* Adding test for #42421

* Remove pdb to simulate the same scenario that a customer has.

* Fix tests that have a different behavior without system.private.corelib.pdb

12 months ago[wasm] Do not set -msimd128 in the default rsp (#89433)
Radek Doulik [Wed, 26 Jul 2023 12:58:58 +0000 (14:58 +0200)]
[wasm] Do not set -msimd128 in the default rsp (#89433)

* [wasm] Do not set -msimd128 in the default rsp

This is the first part of changes to make wasm/SIMD optional again,
https://github.com/dotnet/runtime/issues/89302

* Feedback

* Feedback

* Update the tests, we force relink with SIMD disabled now

12 months ago[mono] MarshalingPInvokeScanner tolerates DLLs without metadata (#89430)
Jan Dupej [Wed, 26 Jul 2023 11:48:29 +0000 (13:48 +0200)]
[mono] MarshalingPInvokeScanner tolerates DLLs without metadata (#89430)

* Acquire MetadataReader under try.

* Logging failed metadata access.

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

Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
---------

Co-authored-by: Theodore Tsirpanis <teo@tsirpanis.gr>
12 months agoFix outerloop.yml (#89497)
Alexander Köplinger [Wed, 26 Jul 2023 11:39:39 +0000 (13:39 +0200)]
Fix outerloop.yml (#89497)

12 months agoGenerates a guid for activity id (#88838)
Lakshan Fernando [Wed, 26 Jul 2023 09:19:09 +0000 (02:19 -0700)]
Generates a guid for activity id (#88838)

* Fixes the way activity id is generated

* FB

* FB

* FB

* Apply suggestions from code review

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* letting each library specify the config.h

* Add needed constants to minipalconfig

* triggering random constants in configure.cmake

* FB

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
12 months ago[Android] Enable skipped networking tests (#89232)
Šimon Rozsíval [Wed, 26 Jul 2023 09:12:08 +0000 (11:12 +0200)]
[Android] Enable skipped networking tests (#89232)

12 months agoUse proper context in initClass for GDV (#87847)
Egor Bogatov [Wed, 26 Jul 2023 08:42:30 +0000 (10:42 +0200)]
Use proper context in initClass for GDV (#87847)

Co-authored-by: David Wrighton <davidwr@microsoft.com>
12 months agoFix issue references in ConvertToLibraryImportAnalyzerTests (#89225)
Jeremy Koritzinsky [Wed, 26 Jul 2023 00:02:55 +0000 (17:02 -0700)]
Fix issue references in ConvertToLibraryImportAnalyzerTests (#89225)

12 months agoInclude TypeNameBuilder.cs from CoreLib instead of copying the file over (#89144)
Buyaa Namnan [Tue, 25 Jul 2023 23:23:47 +0000 (16:23 -0700)]
Include TypeNameBuilder.cs from CoreLib instead of copying the file over (#89144)

12 months agoDelete an unused Span class from object.h (#89464)
SingleAccretion [Tue, 25 Jul 2023 22:40:47 +0000 (01:40 +0300)]
Delete an unused Span class from object.h (#89464)

12 months agoFix failure to generate ngen pdb in crossgen (#89415)
David Wrighton [Tue, 25 Jul 2023 21:30:50 +0000 (14:30 -0700)]
Fix failure to generate ngen pdb in crossgen (#89415)

* Fix issue in R2R compilation where we would compile a method we could not generate a name for
- This is caused by the the type of a parameter having a generic parameter which derived from a type not found in the compilation information
- There are 2 fixes here
  1. Change the logic for computing the set of compilable methods to require that all parameters are loadable
  2. Change the implementation of loadable types to check generic instantiations for loadability
    - This required implementing a stack system to check types for loadability, as loading can require circular references to be resolved.
    - Add a check that the instantiation types of an instantiated generic are loadable.
    - Generic interfaces on arrays work now, so enable the the constraint checking logic.

12 months ago[mono] Disable gsharing when Unsafe.ReadUnaligned/WriteUnaligned () is used with...
Zoltan Varga [Tue, 25 Jul 2023 21:26:43 +0000 (17:26 -0400)]
[mono] Disable gsharing when Unsafe.ReadUnaligned/WriteUnaligned () is used with generic structures. (#89417)

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

For a method like
```
    static void Write<T>(ref byte b, T value) => Unsafe.WriteUnaligned<T>(ref b, value);
```
And an instance ```Write<GStruct<string>>```, generic sharing will create a ```Write<T_INST>```
instance where T_INST is constrained to GStruct<T_REF>. The JIT currently calls
```mini_get_underlying_type ()``` in many places which transform T_INST into GStruct<T_REF>.
This causes problems at runtime in the generic sharing code, which expects to find T_INST.
I.e. ```inflate_info ()``` can inflate ```T_INST``` to ```GStruct<string>```, but it can't inflate
```GStruct<T_REF>``` to ```GStruct<string>```.

As a workaround, disable gsharing in (some) of these cases.

12 months agoAddress unused suppressions (#89216)
Eric StJohn [Tue, 25 Jul 2023 20:31:37 +0000 (13:31 -0700)]
Address unused suppressions (#89216)

* Address unused suppressions

* Remove unnecssary MaybeNullAttribute

* Ensure ApiCompatSuppressionFile is set in outer build

12 months agoAllow multiple kmask registers to be allocated and cleanup some codegen around them...
Tanner Gooding [Tue, 25 Jul 2023 20:14:21 +0000 (13:14 -0700)]
Allow multiple kmask registers to be allocated and cleanup some codegen around them (#89059)

* Allow multiple kmask registers to be allocated and cleanup some codegen around them

* Apply formatting patch

* Fix an assert to include TYP_STRUCT

* Ensure kmask registers aren't in the default killset

* Apply formatting patch

* Move the kmask optimizations up to morph

* Ensure unique VN for ConvertMaskToVector

* Ensure some basic other handling for kmask testing is handled

* Improve the implementation for some managed Vector512 code paths

* Apply formatting patch

* Ensure that the knot intrinsic is inserted into the IR

* Apply formatting patch

* Ensure the conversion of CompareEqualMask(x, zero) to Test(x, x) doesn't happen for floating-point

* Have callee/callerSaveRegs() use an array based lookup

* Respond to PR feedback and try to reduce TP regression more

* Ensure PTEST doesn't try to handle something utilizing embedded broadcast

12 months ago[browser] detect SIMD and EH support (#89387)
Pavel Savara [Tue, 25 Jul 2023 19:04:35 +0000 (21:04 +0200)]
[browser] detect SIMD and EH support (#89387)

Co-authored-by: Ankit Jain <radical@gmail.com>
12 months ago[browser] only trace ExitStatus stack trace if `diagnosticTracing` is true (#89432)
Pavel Savara [Tue, 25 Jul 2023 19:01:23 +0000 (21:01 +0200)]
[browser] only trace ExitStatus stack trace if `diagnosticTracing` is true (#89432)

12 months agoRemove nullable return from ConstructorInvoker.Invoke() (#89448)
Steve Harter [Tue, 25 Jul 2023 18:32:36 +0000 (13:32 -0500)]
Remove nullable return from ConstructorInvoker.Invoke() (#89448)

12 months agoSupport non-ascii in fgVNBasedIntrinsicExpansionForCall_ReadUtf8 (#89383)
Egor Bogatov [Tue, 25 Jul 2023 17:59:52 +0000 (19:59 +0200)]
Support non-ascii in fgVNBasedIntrinsicExpansionForCall_ReadUtf8  (#89383)

12 months agoGet the normal event accessors generated (#89441)
Mike Voorhees [Tue, 25 Jul 2023 17:50:53 +0000 (13:50 -0400)]
Get the normal event accessors generated (#89441)

Because System.Threading.dll was not referenced, this led to Roslyn generating the Delegate.Combine based accessor which does not have any locals.  https://github.com/dotnet/roslyn/blob/520e2f10078ab0e5f85c78fdd95d786d78b9676a/src/Compilers/CSharp/Portable/Compiler/MethodBodySynthesizer.cs#L323-L520

In our UnityLinker test framework we have 2 cases currently.  Mono, which will reference mscorlib.dll, and Roslyn will find `System.Threading.Interlocked.CompareExchange` and use the normal approach.

And currently I have our coreclr tests referencing System.Threading.dll for no great reason.  This is how I stumbled on this.

While this change isn't strictly necessary, I think it's better to have coverage on the `System.Threading.Interlocked.CompareExchange` approach because that's what would normally be generated.  It's also the more complex case for the linker to handle since it has to clear the locals.

12 months agoFixes for outerloop-mono.yml (#88743)
Alexander Köplinger [Tue, 25 Jul 2023 17:39:04 +0000 (19:39 +0200)]
Fixes for outerloop-mono.yml (#88743)

Consolidate configurations and disable failing tests with ActiveIssue.

12 months ago[Mono] UnsafeAccessor: Support ambiguous method match (#89217)
Fan Yang [Tue, 25 Jul 2023 17:25:55 +0000 (13:25 -0400)]
[Mono] UnsafeAccessor: Support ambiguous method match (#89217)

* Support Ambiguous Match

* Stop unsafe accessor method lookup from walking the type hierarchy. And address the review feedback

* Handle the AmbiguousMatchException

* Fix test failure

* Adjust Mono function pointer comparison behavior to match with CoreCLR

* Fix ambiguous match

* Enable Verify_InheritanceMethodResolution

* Remove redundant curly braces

* Address review feedback

12 months agoDisable failing test. (#89442)
Eirik Tsarpalis [Tue, 25 Jul 2023 16:49:48 +0000 (17:49 +0100)]
Disable failing test. (#89442)

12 months agoEnable Mono for using faster invoke stubs (#89108)
Steve Harter [Tue, 25 Jul 2023 15:46:11 +0000 (10:46 -0500)]
Enable Mono for using faster invoke stubs (#89108)

12 months ago[wasm] WBT fixes, and rationalization to allow improved testing (#89360)
Ankit Jain [Tue, 25 Jul 2023 15:32:39 +0000 (11:32 -0400)]
[wasm] WBT fixes, and rationalization to allow improved testing (#89360)

* Move DotNetFileName.cs, and TestUtils.cs to Common

* Move some types from BuildTestBase.cs to separate files

- FileStat
- BuildPaths
- BlazorBuildOptions
- GlobalizationMode

* Move AssertTestMainJsAppBundleOptions.cs to Common

* Instead of globalizationMode=null use GlobalizationMode.Default

* Merge behaviors for the various project types

- Move parsing bootjson, checking icu assets, symbols to ProviderBase, so it can
  be used by all the project types. These come from WasmAppBuilder which
  is shared by all the projects.

- Instead of multiple separate ways to build the project, use one
  `BuildTestBase.BuildWithoutAssert` method that uses `DotNetCommand` to
  build. And all the project types can use this.
  - This allows having any build customizations or fixes to be in once
    place, and the outputs to be consistent.

- Instead of having `UseWebcil` in various option types, use it directly
  as needed, because this setting is *not* changed per test, rather it
  is fixed per run.

- Rationalize figuring out bin framework directories

Known limitations:
- Wasm template tests use a TestMainJs provider to assert the bundle
  because the templates are not yet based on wasm sdk.
- Blazor has a bug due to which all the icu assets get deployed
  irrespective of settings, so asserting that is disabled.
- Also, blazor does not yet support symbols file.

* Update tests to track api changes
* CI: don't trigger jobs when WasmBuild.sln changes

* Address feedback from @ilonatommy
* Address feedback from @ilonatommy - simplify icu assert code

12 months agoAdding test for #80049 (#89399)
Thays Grazia [Tue, 25 Jul 2023 15:21:58 +0000 (12:21 -0300)]
Adding test for #80049 (#89399)

12 months agoRun Antigen/Fuzzlyn on Saturdays too (#89426)
Jakob Botsch Nielsen [Tue, 25 Jul 2023 14:57:51 +0000 (16:57 +0200)]
Run Antigen/Fuzzlyn on Saturdays too (#89426)

Up the frequency of the Antigen and Fuzzlyn runs to also run on
Saturdays during these last weeks of .NET 8 development.

12 months agoFix System.BinaryData tests failing in AOT. (#89381)
Eirik Tsarpalis [Tue, 25 Jul 2023 11:29:56 +0000 (12:29 +0100)]
Fix System.BinaryData tests failing in AOT. (#89381)

12 months ago[NativeAOT] Refactor Linq feature switches (#89308)
Ivan Povazan [Tue, 25 Jul 2023 11:27:31 +0000 (13:27 +0200)]
[NativeAOT] Refactor Linq feature switches (#89308)

12 months agofix NodeJS fetch detection (#89393)
Pavel Savara [Tue, 25 Jul 2023 10:52:49 +0000 (12:52 +0200)]
fix NodeJS fetch detection (#89393)

12 months ago[wasm] Make PackedSimd.Shuffle internal (#89401)
Radek Doulik [Tue, 25 Jul 2023 10:39:31 +0000 (12:39 +0200)]
[wasm] Make PackedSimd.Shuffle internal (#89401)

We don't want it public until we fix the llvm/aot compiler crash

12 months agoBump timeout in runtime-extra-platforms-ioslike.yml (#89400)
Alexander Köplinger [Tue, 25 Jul 2023 09:16:47 +0000 (11:16 +0200)]
Bump timeout in runtime-extra-platforms-ioslike.yml (#89400)

12 months agoRemove InstructionSet_VectorT256 if AVX2 is disabled via env var
Egor Bogatov [Tue, 25 Jul 2023 08:20:10 +0000 (10:20 +0200)]
Remove InstructionSet_VectorT256 if AVX2 is disabled via env var

12 months agoEnable events for LogAlways (#89326)
Nickolas McDonald [Tue, 25 Jul 2023 08:06:07 +0000 (04:06 -0400)]
Enable events for LogAlways (#89326)

12 months agoMake textual stack trace metadata smaller (#89377)
Michal Strehovský [Tue, 25 Jul 2023 04:49:44 +0000 (13:49 +0900)]
Make textual stack trace metadata smaller (#89377)

When we need to generate a textual stack trace in NativeAOT, we rely on two things - reflection metadata for methods, or a supplementary stack trace metadata format.

The reflection metadata case is simple - reflection keeps track of method addresses and the associated metadata like names and signatures. We ask for metadata handles (tokens, basically) and we get the handles back. We then walk the metadata and format textual strings.

When reflection metadata is not available, we have to emit some other metadata in the compiler. We use the same metadata format and conceptually the closest thing were unresolvable `MemberReference`s, so we basically generated a pair of method pointer + MemberReference handle for each method body that doesn't have reflection metadata. It's a lot less metadata than for a resolvable definition, but is still quite a bit wasteful.

This change avoids generating full `MemberReference` and instead inlines owning type/name/signature handle/token into the mapping table. We also do it in a way that avoids emitting owning type/name/signature if it's the same as the record before that.

12 months agoDelete NativeAOT_StaticInitialization (#89291)
Michal Strehovský [Tue, 25 Jul 2023 00:56:24 +0000 (09:56 +0900)]
Delete NativeAOT_StaticInitialization (#89291)

Undoes workaround from dotnet/runtimelab#270. Since bootstrapper no longer ships as a static library (it's an object file instead), we should no longer need this hack to force linker into looking at the archive.

12 months agoFixed python warning: DeprecationWarning: There is no current event loop (#89404)
Will Smith [Tue, 25 Jul 2023 00:17:50 +0000 (17:17 -0700)]
Fixed python warning: DeprecationWarning: There is no current event loop (#89404)

* Fixed python warning: DeprecationWarning: There is no current event loop

* Update superpmi.py

12 months agoDo not show a pop-up dialog when an assertion occurs in SuperPMI collection (#89336)
Will Smith [Mon, 24 Jul 2023 23:41:40 +0000 (16:41 -0700)]
Do not show a pop-up dialog when an assertion occurs in SuperPMI collection (#89336)

12 months agoFix config src-gen issues with binding nullable values (#89397)
Layomi Akinrinade [Mon, 24 Jul 2023 23:18:26 +0000 (16:18 -0700)]
Fix config src-gen issues with binding nullable values (#89397)

12 months ago[browser][mt] Release all proxies of C# and JS objects (#88052)
Pavel Savara [Mon, 24 Jul 2023 20:03:13 +0000 (22:03 +0200)]
[browser][mt] Release all proxies of C# and JS objects (#88052)

12 months agoTweak and fix physical promotion test environments (#89380)
Jakob Botsch Nielsen [Mon, 24 Jul 2023 18:32:52 +0000 (20:32 +0200)]
Tweak and fix physical promotion test environments (#89380)

- Physical promotion is enabled by default now, so switch the scenario to one
  that tests physical promotion without old promotion

- JitStressModeNames was missing from DOTNETVariables, which meant that after
  the switch from JitEnablePhysicalPromotion to JitStressModeNames we stopped
  testing the right thing

12 months agoDisable mock test on aot (#89390)
Natalia Kondratyeva [Mon, 24 Jul 2023 18:20:27 +0000 (19:20 +0100)]
Disable mock test on aot (#89390)

12 months agoDependencyGraphViewer: Feature add same window navigation for NodeForm (#84542)
Mitch Capper (they, them) [Mon, 24 Jul 2023 18:18:35 +0000 (11:18 -0700)]
DependencyGraphViewer: Feature add same window navigation for NodeForm (#84542)

* DependencyGraphViewer: Feature add same window navigation for NodeForm

Add ability to reuse current window rather than open new, added history
(forward/back) and arrow key accelerators as well.

* Fix code formatting

---------

Co-authored-by: David Wrighton <davidwr@microsoft.com>
12 months agoAdded 'DOTNET_JitDisasmTesting' knob. (#89373)
Will Smith [Mon, 24 Jul 2023 17:07:29 +0000 (10:07 -0700)]
Added 'DOTNET_JitDisasmTesting' knob. (#89373)

* Added 'DOTNET_JitDisasmTesting' knob.

* Formatting

12 months agoImplement new streaming APIs for the `System.Net.Http.Json` extensions (#89258)
David Pine [Mon, 24 Jul 2023 16:51:40 +0000 (11:51 -0500)]
Implement new streaming APIs for the `System.Net.Http.Json` extensions (#89258)

* Contributes to #87577

* More updates

* Added unit tests, generated ref, and minor clean up

* Added missing triple slash comments

* Update src/libraries/System.Net.Http.Json/tests/FunctionalTests/HttpClientJsonExtensionsTests.cs

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* Correct the preprocessor directives, and delegate to JsonTypeInfo overload - per peer feedback.

* Refactor for deferred execution, remove helper methods since they're no longer needed

* Add test to ensure deferred execution semantics, updates from Miha.

* Apply suggestions from code review

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
* Update src/libraries/System.Net.Http.Json/src/System/Net/Http/Json/HttpClientJsonExtensions.Get.AsyncEnumerable.cs

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* Update test per Miha's feedback

* A few more updates from peer review, Eirik's nits.

* No need for the length limit read stream.

* Add limit per invocation, not element. Share length limit read stream logic.

---------

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
12 months agoMake checks for compiler-generated types more specific (#89327)
Sven Boemer [Mon, 24 Jul 2023 16:29:43 +0000 (09:29 -0700)]
Make checks for compiler-generated types more specific (#89327)

The only types we want to consider for the compiler-generated
state handling are lambda display classes, and state machine
types. We used to treat all types with compiler-generated names
this way, but this was too broad of a filter because it would
include file-scoped classes (which get names like
`<GeneratedConfigurationBinder_g>F86B5F805A26B32373DA5BA80136649730AD5F76CC2979BFEE086BEB55048B927__CoreBindingHelper`,
for the configuration binder source generator).

12 months agoUse JIT intrinsic for UTF8 encoding in Utf8.TryWrite's AppendLiteral (#89376)
Stephen Toub [Mon, 24 Jul 2023 16:23:56 +0000 (12:23 -0400)]
Use JIT intrinsic for UTF8 encoding in Utf8.TryWrite's AppendLiteral (#89376)

* Use JIT intrinsic for UTF8 encoding in Utf8.TryWrite's AppendLiteral

* Remove IsKnownConstant

12 months ago[mono][ios] Drop marshal-ilgen from iOS builds if it is not needed (#88903)
Jan Dupej [Mon, 24 Jul 2023 15:48:12 +0000 (17:48 +0200)]
[mono][ios] Drop marshal-ilgen from iOS builds if it is not needed (#88903)

* MarshallingPInvokeScanner is applied to Apple toolchains.

* HelloiOS example uses simpler string marshaling.

* Removing marshal-ilgen from HelloWorld.

* Runtime components and runtime library paths are now decided in the correct order relative to building the native runtime.

* RuntimeComponents is manipulated through an ItemGroup.

* Cleaned up commented old code.

* Reordered runtime components section.

* Addressed more feedback.

12 months agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 222704...
dotnet bot [Mon, 24 Jul 2023 15:14:50 +0000 (17:14 +0200)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 2227046 (#89321)

12 months ago[NativeAOT] Replace GVMLookupForSlot internal cache with generic cache similar to...
Vladimir Sadov [Mon, 24 Jul 2023 13:14:23 +0000 (06:14 -0700)]
[NativeAOT] Replace GVMLookupForSlot internal cache with generic cache similar to CastCache (#89331)

* factored out CastCache to be able create several.

* Cache impl

* generic cache

* some refactoring

* separated GenericCache

* comments

* less refs

* do not store hash

* fix CoreCLR and some more refactoring

* PR feedback

* remove no longer needed CastCache wrapping constructor

* remove auto-inserted unused usings.

* remove unused ActivatorCreateInstanceAny

12 months agoBump word-wrap from 1.2.3 to 1.2.4 in /src/mono/sample/wasm/node-webpack (#89198)
dependabot[bot] [Mon, 24 Jul 2023 10:19:13 +0000 (12:19 +0200)]
Bump word-wrap from 1.2.3 to 1.2.4 in /src/mono/sample/wasm/node-webpack (#89198)

12 months agoAvoid BYREF trees in ByteOffset (#89324)
Michał Petryka [Mon, 24 Jul 2023 08:50:31 +0000 (10:50 +0200)]
Avoid BYREF trees in ByteOffset (#89324)

Solves the particular problematic case from #84291.

12 months ago[mono][jit] Enabled more intrinsics for V4 on arm64 (#88912)
Vlad-Alexandru Ionescu [Mon, 24 Jul 2023 08:46:36 +0000 (10:46 +0200)]
[mono][jit] Enabled more intrinsics for V4 on arm64 (#88912)

* Enabled more intrinsics for V4

Signed-off-by: Vlad - Alexandru Ionescu <vlad-alexandruionescu@Vlads-MacBook-Pro-5.local>
---------

Signed-off-by: Vlad - Alexandru Ionescu <vlad-alexandruionescu@Vlads-MacBook-Pro-5.local>
Co-authored-by: Vlad - Alexandru Ionescu <vlad-alexandruionescu@Vlads-MacBook-Pro-5.local>
12 months agoDon't always do optimistic HW intrinsic expansion (#89282)
Michal Strehovský [Mon, 24 Jul 2023 01:54:30 +0000 (10:54 +0900)]
Don't always do optimistic HW intrinsic expansion (#89282)

"Optimistic" expansion means we generate a method body for `IsSupported` that returns true/false depending on the currently running CPU. Don't do this when `--instruction-set:native` was specified because native should mean "exactly this". Also don't do this when optimizing for size (saves 0.6% on hello world). I was going back and forth whether to do this when user specifies instruction sets manually, but decided it would be a "breaking" change.

12 months ago[Mono] [RISCV] Fix abi issues (Monthly pr) (#88649)
VincentWu [Mon, 24 Jul 2023 01:17:07 +0000 (11:17 +1000)]
[Mono] [RISCV] Fix abi issues (Monthly pr) (#88649)

* update makefile

* add format file

* use mul inst instead of emulate mul
process stack size larger than imm32

* emit get_throw_trampoline

* mono_riscv_throw_exception

* fix error of stack trace

* test case

* output inst idiv
fix mono_riscv_emit_branch_exc

* implement mono_arch_get_throw_corlib_exception

* fix rdiv

* move ArgOnStack arg at prologue
lowering OP_XOR_IMM&OP_IXOR_IMM

* fix emit_imm

* test imm

* update test case

* use swich to process return value

* fix unwind inst def_cfa

* fmt

* lowering OP_LMUL_IMM

* make file for webapiclient

* lowerng&output
- OP_FCONV_TO_I8
- OP_LXOR_IMM
- OP_ISHR

* lowerng&output
- relaxed_nop
- float_cle
- long_shl
- OP_ICONV_TO_R_UN
- OP_LCONV_TO_I2
- OP_FBGE
- OP_IDIV_IMM

* fix this_pointer in vcall with valuetype returned
- The ABI specify that If the reture value would have been passed by reference, the caller will allocates memory for the return value, and passes the address as an implicit first parameter.
- The Mono will treat first parameter as this_pointer reference to `mono_vcall_trampoline()`.  They are conflict a bit.

* process param type: ArgVtypeOnStack & ArgVtypeByRef

* lowering OP_LCONV_TO_I2

* OP_IREM_UN_IMM
OP_ATOMIC_LOAD_U1
OP_IREM_UN_IMM

* fix output of OP_IREM & OP_IREM_UN
OP_IREM -> riscv_remw
OP_IREM_UN -> riscv_remuw

* use `lw` to load u4 value on the stack
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#integer-calling-convention

* optmise lw+zext -> lwu

* fix patch_full
use mono_riscv_emit_loadu to emit lwu
fix rem

* fix `mono_arch_build_imt_trampoline` when `item->is_equals==false`

* FIXME: reg got crashed wetween `this` and return ref

* fix `mono_arch_build_imt_trampoline`

* float_sub & float_div

* OP_FNEG,OP_LADD_OVF,OP_FBEQ, OP_COND_EXC_OV

* fix mono_arch_emit_outarg_vt

* process ArgVtypeOnStack in emit_move_args

* add sample status

* fix valid imm check of OP_L.*_IMM

* OP_LCONV_TO_R_UN

* update

* fix the param order stored o stack

* fix the param size of MONO_TYPE_I & MONO_TYPE_U when RV64

* add test task for makefile

* update .clang-format

* fmt

* fix merge

* TMP

* clean pr

* keep  this_pointer always be RISCV_A0

12 months agoJIT: Intrinsify UTF16->UTF8 conversion for string literals (Encoding.UTF8.TryGetBytes...
Egor Bogatov [Sun, 23 Jul 2023 21:45:14 +0000 (23:45 +0200)]
JIT: Intrinsify UTF16->UTF8 conversion for string literals (Encoding.UTF8.TryGetBytes) (#85328)

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
12 months agoFix potential BitCast bug for platforms without unaligned reads (#89364)
Michał Petryka [Sun, 23 Jul 2023 18:20:38 +0000 (20:20 +0200)]
Fix potential BitCast bug for platforms without unaligned reads (#89364)

BitCast could potentially make an invalid read when reinterpreting a type to another that requires higher alignment, which could possibly cause a fault on Mono ARMv6.

12 months agoFix EventPipe utf8 conversion methods to match between JIT and AOT (#89353)
Jan Kotas [Sun, 23 Jul 2023 16:27:36 +0000 (09:27 -0700)]
Fix EventPipe utf8 conversion methods to match between JIT and AOT (#89353)

12 months agoIntrinsify Unsafe.Read/Write/Copy, handle struct BitCast (#85562)
Michał Petryka [Sun, 23 Jul 2023 14:51:47 +0000 (16:51 +0200)]
Intrinsify Unsafe.Read/Write/Copy, handle struct BitCast (#85562)

Co-authored-by: Egor Bogatov <egorbo@gmail.com>
12 months agoUnify hardware feature detection between CoreCLR JIT and AOT (#89342)
Jan Kotas [Sun, 23 Jul 2023 04:13:29 +0000 (21:13 -0700)]
Unify hardware feature detection between CoreCLR JIT and AOT (#89342)

Follow up on #87865

12 months agoProperly close PKCS12 files when enumerating stores
Kevin Jones [Sun, 23 Jul 2023 03:42:40 +0000 (23:42 -0400)]
Properly close PKCS12 files when enumerating stores

12 months agoUpdate PAL and GC `BitScanForward` to use `__builtin_clz` (#89350)
Andy Ayers [Sat, 22 Jul 2023 22:20:55 +0000 (15:20 -0700)]
Update PAL and GC `BitScanForward` to use `__builtin_clz` (#89350)

The existing PAL code was using `__builtin_clzl` which is intended for platforms
where `long` is 64 bits. Instead use `__builtin_clz`.

The GC version had a similar issue so I've changed that too. The JIT version
was already using `__builtin_clz`.

Fixes #89340.

12 months agoSet BaseSize of interfaces to 0 (#89343)
Michal Strehovský [Sat, 22 Jul 2023 12:54:19 +0000 (21:54 +0900)]
Set BaseSize of interfaces to 0 (#89343)

We were computing these as the minimum object size. This number is meaningless because they don't get allocated on the GC heap. A zero compresses better. Surprisingly saves like 0.1% on Hello World despite being such an insignificant thing.

12 months agoFix exe size for Mach-O files (#89325)
Andy Gocke [Sat, 22 Jul 2023 06:44:11 +0000 (23:44 -0700)]
Fix exe size for Mach-O files (#89325)

The extra size appears to be the export list, which is zeroed
but not removed when the file is stripped. Exes shouldn't have
any exported symbols by default, but ld will include everything
by default. We'll fix it up using an ld flag.

Fixes #86707

12 months agoRemove incorrect flag setting (#88878)
Michal Strehovský [Sat, 22 Jul 2023 06:19:11 +0000 (15:19 +0900)]
Remove incorrect flag setting (#88878)

This was added in https://github.com/dotnet/runtime/pull/85743#discussion_r1215117945. Setting this flag is not the right thing to do. It sweeps issues under the carpet. Also, we're only doing it for signature type variables, not method variable. And since no tests seem to be failing, it might not even be necessary.

12 months agoFix TestGenericAddStaticField (#89145)
mikelle-rogers [Fri, 21 Jul 2023 21:39:12 +0000 (14:39 -0700)]
Fix TestGenericAddStaticField (#89145)

* Fix TestGenericAddStaticField

* use the correct Method Table to gather fields

12 months agoUpstream some changes to portable allocation helpers (#89269)
SingleAccretion [Fri, 21 Jul 2023 20:53:06 +0000 (23:53 +0300)]
Upstream some changes to portable allocation helpers (#89269)

12 months ago[RISC-V][JIT] Fix NaN canonicalization issue (#88510)
Dong-Heon Jung [Fri, 21 Jul 2023 20:31:35 +0000 (05:31 +0900)]
[RISC-V][JIT] Fix NaN canonicalization issue (#88510)

* [RISC-V][JIT] Fix canonical NaN issue

* [RISC-V][JIT] Update to use helpers

* [RISC-V][JIT] Update conversion functions

* [RISC-V][JIT] Update

12 months agoBlock inlining of IntroSort (#89310)
Andy Ayers [Fri, 21 Jul 2023 20:06:10 +0000 (13:06 -0700)]
Block inlining of IntroSort (#89310)

With PGO and (via #88749) one level of recursive inlining enabled, the jit sees
the recursive call made by `IntroSort` as an attractive inline candidate,
but it isn't.

Fixes #89106.

12 months agoJIT: Fix handling of filter successors (#89275)
Jakob Botsch Nielsen [Fri, 21 Jul 2023 20:04:58 +0000 (22:04 +0200)]
JIT: Fix handling of filter successors (#89275)

Filters are run during the first pass of EH which makes determining
their successors complicated, and the JIT did not get this right.  In
particular, after running filters as part of first-pass EH, control may
flow to any enclosed finally or fault handler as part of second-pass EH.
Thus, these should be considered as EH successors. This adds a
BasicBlock::VisitEHSecondPassSuccs to visit these successors.

The logic was mostly extracted from liveness that (almost) got it right:
there was a condition that meant the logic did not run for top-level
try-filter clauses. This change folds in Bruce's change to fix this
scenario as well.

There was one more bug in the logic in liveness: to determine the
enclosed fault/finally blocks, the logic iterates backwards in the EH
table while looking for enclosed clauses. However, this was only
checking for clauses enclosed in the try region when it should also
check for clauses enclosed in the handler region.

Fix #86538
Fix #88168

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
12 months agoCopy tool build fix from performance repo to runtime repo. (#89323)
Parker Bibus [Fri, 21 Jul 2023 19:46:37 +0000 (12:46 -0700)]
Copy tool build fix from performance repo to runtime repo. (#89323)

This doesn't include any changes to non-runtime-perf infra and changes have been tested in the performance pipeline, merging.

12 months agoRemove etw --exclude-feature tests. (#89107)
Mike Voorhees [Fri, 21 Jul 2023 19:04:23 +0000 (15:04 -0400)]
Remove etw --exclude-feature tests. (#89107)

`--exclude-feature` logic was removed.  If there is no intent to support this with coreclr bcl then we won't worry about it either.

While we do need UnityLinker to continue to handle mono class libraries for awhile longer, the `--exclude-feature` functionality is a niche thing we can drop now.

12 months agoUse utf conversions from minipal (#89036)
Lakshan Fernando [Fri, 21 Jul 2023 18:46:14 +0000 (11:46 -0700)]
Use utf conversions from minipal (#89036)

* Support for utf conversion

* cast fix

* FB

* FB

* Update src/coreclr/nativeaot/Runtime/eventpipe/ep-rt-aot.h

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Apply suggestions from code review

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

* FB

* FB

---------

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
12 months agoEmit a diagnostic when attributes deriving from JsonConverterAttribute are being...
Eirik Tsarpalis [Fri, 21 Jul 2023 16:23:44 +0000 (17:23 +0100)]
Emit a diagnostic when attributes deriving from JsonConverterAttribute are being used. (#89199)

* Emit a diagnostic when attributes deriving from JsonConverterAttribute are being used.

* Address feedback.

12 months agoFix System.Net.Http.Json tests in AOT (#89307)
Eirik Tsarpalis [Fri, 21 Jul 2023 16:21:47 +0000 (17:21 +0100)]
Fix System.Net.Http.Json tests in AOT (#89307)

12 months agoMove full facade assemblies into src/libraries/shims (#89184)
Viktor Hofer [Fri, 21 Jul 2023 15:58:42 +0000 (17:58 +0200)]
Move full facade assemblies into src/libraries/shims (#89184)

* Move full facade assemblies into src/libraries/shims

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

1. Move all full facade assemblies (which only contain type forwards)
   into src/libraries/shims.
2. Merge assemblies (ref+src) which typeforward to the same
   destination.
3. They inherently now don't produce a documentation file anymore (as
   shims only contain type forwards).

This minimizes the build graph (makes the libs build faster) and moves
the focus away from full facade assemblies that need to be kept for
compat reasons.

* Trigger CI for all legs

* Remove obsolete slns and undo CI change

* PR feedback from Eric

* Change System.ValueTuple type fowrard dest

* Collapse ref and src shims further

As discussed with Eric offline, typeforwarding to System.Runtime and
System.Xml.ReaderWriter makes it possible to collapse the following
ref and src projects into just src:

System.AppContext
System.Buffers
System.Diagnostics.Debug
System.Diagnostics.Tools
System.Globalization
System.Globalization.Calendars
System.IO.UnmanagedMemoryStream
System.Reflection
System.Resources.ResourceManager
System.Runtime.CompilerServices.Unsafe
System.Runtime.Extensions
System.Security.Principal
System.Text.Encoding
System.Threading.Timer
System.Xml.XmlDocument

The destination then handles the type fowarding to the private assembly
implementation.

12 months ago[mono][tests] Parallel AOT compilation of runtime tests on iOS platforms (#86089)
Milos Kotlar [Fri, 21 Jul 2023 15:56:47 +0000 (17:56 +0200)]
[mono][tests] Parallel AOT compilation of runtime tests on iOS platforms  (#86089)

The Helix payload is generated using the runtime pipeline. Then, the libraries pipeline is utilized to AOT compile and execute the tests on Helix. The build-runtime-tests-and-send-to-helix.yml is updated with the compileOnHelix parameter, which if set, uses the libraries/helix.yml template instead of the runtime send-to-helix-step.yml template. The runtime and libraries pipelines are updated to support AOT compilation of runtime tests on Helix.

12 months agoVectorize Enumerable.Range initialization, take 2 (#87992)
neon-sunset [Fri, 21 Jul 2023 15:10:47 +0000 (18:10 +0300)]
Vectorize Enumerable.Range initialization, take 2 (#87992)

* Vectorize Enumerable.Range initialization

* Address PR feedback

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>