platform/upstream/dotnet/runtime.git
15 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

15 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.

15 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.

15 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

15 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.

15 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

15 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)

15 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

15 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.

15 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>
15 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.

15 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.

15 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>
15 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.

15 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)

15 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.

15 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.

15 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>
15 months agoOptimize MemoryMarshal.ToEnumerable for arrays and strings (#89274)
Stephen Toub [Fri, 21 Jul 2023 13:32:48 +0000 (09:32 -0400)]
Optimize MemoryMarshal.ToEnumerable for arrays and strings (#89274)

15 months ago[wasm] Add index of string span measurement (#89294)
Radek Doulik [Fri, 21 Jul 2023 13:26:09 +0000 (15:26 +0200)]
[wasm] Add index of string span measurement (#89294)

15 months agoRemove feature exclude xml tests (#89111)
Mike Voorhees [Fri, 21 Jul 2023 12:22:03 +0000 (08:22 -0400)]
Remove feature exclude xml tests (#89111)

illink dropped the exclude feature functionality, so will we.

I believe Unity was the last user of these tests so it's safe to delete them now.

15 months ago[RISC-V] Fix GetArgLoc (#88657)
t-mustafin [Fri, 21 Jul 2023 11:04:50 +0000 (14:04 +0300)]
[RISC-V] Fix GetArgLoc (#88657)

15 months agoUse RegDeleteTree in RegistryKey.DeleteSubKeyTree (#82598)
Huo Yaoyuan [Fri, 21 Jul 2023 09:12:59 +0000 (17:12 +0800)]
Use RegDeleteTree in RegistryKey.DeleteSubKeyTree (#82598)

* Use RegDeleteTree in RegistryKey.DeleteSubKeyTree

* Restore self delete behavior

* Call RegDeleteTree on subkey to simulate permission behavior.

* Adjust comment and add tests.

15 months agoVirt call unsafe accessor tests (#89220)
Aaron Robinson [Fri, 21 Jul 2023 02:13:24 +0000 (19:13 -0700)]
Virt call unsafe accessor tests (#89220)

* UnsafeAccessors are limited to lookup on
the defined typed.

* Update documentation for attribute.

---------

Co-authored-by: vitek-karas <10670590+vitek-karas@users.noreply.github.com>
16 months agoAdd HttpMethod.Parse (#89270)
Stephen Toub [Thu, 20 Jul 2023 21:47:50 +0000 (17:47 -0400)]
Add HttpMethod.Parse (#89270)

16 months agoJIT: Cache memory dependencies for VN map selects (#89241)
Jakob Botsch Nielsen [Thu, 20 Jul 2023 21:04:37 +0000 (23:04 +0200)]
JIT: Cache memory dependencies for VN map selects (#89241)

Hoisting relies on being able to look at which memory dependencies a
candidate is dependent upon. VN tracks these during the map select
logic; however, it fails to do so when the map selection hits the cache.
This changes the logic to make sure the memory dependencies are cached.

Fix #75442

16 months agoJIT: Expand inlined delegate calls in correct order (#89175)
Jakob Botsch Nielsen [Thu, 20 Jul 2023 20:29:46 +0000 (22:29 +0200)]
JIT: Expand inlined delegate calls in correct order (#89175)

The access of the target instance was incorrectly inserted right after
the location of the delegate instance. Since this indirection can throw
a NRE this is incorrect; to get the proper inlined behavior, the
indirection must happen only after all arguments have been evaluated.

Fix #75832

16 months agoFire AssemblyUnloadStarted event (#87890)
Eduardo Velarde [Thu, 20 Jul 2023 20:08:02 +0000 (13:08 -0700)]
Fire AssemblyUnloadStarted event (#87890)

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

AssemblyUnloadStarted event is now being fired

16 months ago[main] Update dependencies from dotnet/arcade dotnet/xharness (#89235)
dotnet-maestro[bot] [Thu, 20 Jul 2023 20:00:12 +0000 (15:00 -0500)]
[main] Update dependencies from dotnet/arcade dotnet/xharness (#89235)

* Update dependencies from https://github.com/dotnet/arcade build 20230719.2

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.23364.2 -> To Version 8.0.0-beta.23369.2

Dependency coherency updates

Microsoft.DotNet.XliffTasks
 From Version 1.0.0-beta.23360.1 -> To Version 1.0.0-beta.23368.1 (parent: Microsoft.DotNet.Arcade.Sdk

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

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 8.0.0-prerelease.23363.3 -> To Version 8.0.0-prerelease.23370.1

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
16 months ago[mono][interp] Add lock when allocating from method mempool (#89231)
Vlad Brezae [Thu, 20 Jul 2023 18:02:40 +0000 (21:02 +0300)]
[mono][interp] Add lock when allocating from method mempool (#89231)

MonoMemPool does not support multithreaded allocation. We lock on default jit_mm lock for convenience, since it is widely used in interpreter. We might want to consider using a separate lock.

16 months agoWorkaround a C++/CLI bug involving DIMs (#89253)
Tanner Gooding [Thu, 20 Jul 2023 17:24:11 +0000 (10:24 -0700)]
Workaround a C++/CLI bug involving DIMs (#89253)

16 months agoFilter list of candidate invocations for parsing in binding generator (#89226)
Layomi Akinrinade [Thu, 20 Jul 2023 17:13:51 +0000 (10:13 -0700)]
Filter list of candidate invocations for parsing in binding generator (#89226)

16 months ago[JIT] Fix - Do not remove `CAST` nodes on store if the `LCL_VAR` is a parameter or...
Will Smith [Thu, 20 Jul 2023 16:22:37 +0000 (09:22 -0700)]
[JIT] Fix - Do not remove `CAST` nodes on store if the `LCL_VAR` is a parameter or struct field (#85734)

* Do not remove CAST nodes on assignment if the LCL_VAR is a parameter.

* Added NormalizeOnLoad rules from SingleAccretion. Added description of why we cannot remove CAST nodes from parameters.

* Remove morph optimization for NormalizeOnLoad in fgMorphLocalVar. Update test.

* Do not OptimizeCastOnStore for params and struct fields

* Update src/coreclr/jit/morph.cpp

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
* Formatting

---------

Co-authored-by: Jakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
16 months ago[PERF] Finish fixing PerfBDNApp, continuation of #89057 (#89135)
Parker Bibus [Thu, 20 Jul 2023 16:12:05 +0000 (09:12 -0700)]
[PERF] Finish fixing PerfBDNApp, continuation of #89057 (#89135)

Move performance repo clone to before the csproj update and pull out the BDNVersion value from the performance Versions.props.

16 months agoEnable CLS Compliance on Diagnostics Libraries (#89214)
Tarek Mahmoud Sayed [Thu, 20 Jul 2023 15:53:48 +0000 (08:53 -0700)]
Enable CLS Compliance on Diagnostics Libraries (#89214)

16 months agoBump main version to RC1 (#89151)
Carlos Sánchez López [Thu, 20 Jul 2023 15:12:37 +0000 (08:12 -0700)]
Bump main version to RC1 (#89151)

16 months agoRemove more duplicate assets from NativeAOT runtime pack build (#89239)
Alexander Köplinger [Thu, 20 Jul 2023 15:08:12 +0000 (17:08 +0200)]
Remove more duplicate assets from NativeAOT runtime pack build (#89239)

16 months agoFix service accessor scope validation for the emit-based version
Pavel Ivanov [Thu, 20 Jul 2023 13:57:55 +0000 (18:57 +0500)]
Fix service accessor scope validation for the emit-based version

16 months agoFix incorrect nativeaot event thread / sequence number on shutdown (#88941)
Elinor Fung [Thu, 20 Jul 2023 13:44:01 +0000 (06:44 -0700)]
Fix incorrect nativeaot event thread / sequence number on shutdown (#88941)

16 months agoSBLK_MASK_LOCK_THREADID allow tid up to 65535 (#88772)
DIcKeNs [Thu, 20 Jul 2023 13:31:12 +0000 (21:31 +0800)]
SBLK_MASK_LOCK_THREADID allow tid up to 65535 (#88772)

* SBLK_MASK_LOCK_THREADID allow tid up to 65535

* copy comment from NativeAOT ObjectHeader.cs

---------

Co-authored-by: dickens <dickens.tam@pulsartradingcap.com>
16 months agoBroaden use of SearchValues in TryFindNextPossibleStartingPosition in Regex (#89205)
Stephen Toub [Thu, 20 Jul 2023 13:23:23 +0000 (09:23 -0400)]
Broaden use of SearchValues in TryFindNextPossibleStartingPosition in Regex (#89205)

SearchValues has been updated to have an ASCII fast-path for inputs that are not only ASCII.  This means we can simplify TryFindNextPossibleStartingPosition in Regex to not track AsciiSet specially and instead just increase the number of characters we query the set for (from 5 to 128).  That way, we'll use SearchValues rather than emitting our own helper up until a (semi-arbitrary) point where we deem it impossible or infeasible to enumerate all the chars that make up the set.

16 months ago[AndroidAppBuilder] add missing includes to template (#89197)
Aleksey Kliger (λgeek) [Thu, 20 Jul 2023 13:03:51 +0000 (09:03 -0400)]
[AndroidAppBuilder] add missing includes to template (#89197)

* [AndroidAppBuilder] add missing includes to template

Treat missing protoype warnings as errors so this doesn't happen again.

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

* also fixup library mode template

16 months ago[browser] Allow download retry+throttling in unified code with Blazor (#88910)
Marek Fišera [Thu, 20 Jul 2023 12:51:07 +0000 (14:51 +0200)]
[browser] Allow download retry+throttling in unified code with Blazor (#88910)

16 months agoAdd support for `--instruction-set:native` (#87865)
Michal Strehovský [Thu, 20 Jul 2023 08:15:02 +0000 (17:15 +0900)]
Add support for `--instruction-set:native` (#87865)

This allows compiling for the ISA extensions that the currently running CPU supports.

16 months agoReduce ProbabilisticWithAsciiCharSearchValues overhead on non-ASCII texts (#89224)
Miha Zupan [Thu, 20 Jul 2023 03:01:07 +0000 (05:01 +0200)]
Reduce ProbabilisticWithAsciiCharSearchValues overhead on non-ASCII texts (#89224)

16 months agoPoint ActiveIssues to moved issues (#89158)
Michal Strehovský [Thu, 20 Jul 2023 00:49:49 +0000 (09:49 +0900)]
Point ActiveIssues to moved issues (#89158)

We moved some issues from runtimelab to runtime. Re-point the tests to those.

16 months agoAdd more tests for complex dict element binding by generator (#89210)
Layomi Akinrinade [Thu, 20 Jul 2023 00:26:18 +0000 (17:26 -0700)]
Add more tests for complex dict element binding by generator (#89210)

16 months agoUpdate UserTypeMarshallingV2.md (#89222)
Jeremy Koritzinsky [Wed, 19 Jul 2023 23:49:40 +0000 (16:49 -0700)]
Update UserTypeMarshallingV2.md (#89222)

16 months agoFix the default behavior to trim the RCW interop by default (#89128)
Jeremy Koritzinsky [Wed, 19 Jul 2023 22:59:34 +0000 (15:59 -0700)]
Fix the default behavior to trim the RCW interop by default (#89128)

16 months agoAdd a SearchValues ProbabilisticMap implementation that uses an ASCII fast path ...
Miha Zupan [Wed, 19 Jul 2023 22:08:01 +0000 (00:08 +0200)]
Add a SearchValues ProbabilisticMap implementation that uses an ASCII fast path (#89155)

* Add a SearchValues ProbabilisticMap implementation that uses an ASCII fast path

* Add comments and asserts around IOptimizations selection

* Unused using

16 months agoAdd support for default implementation of static virtuals with method constraints...
David Wrighton [Wed, 19 Jul 2023 21:53:48 +0000 (14:53 -0700)]
Add support for default implementation of static virtuals with method constraints (#89061)

- The major problem was the logic which incorrectly would instantiate the methods when it wasn't necessary
- As the number of flags to the implementation functions has grown very large, this change also includes logic converting them all to a single flags variable when passing them around

Fixes #73658
Fixes #78865

16 months agoBuild less of libs for CoreCLR tools tests (#89154)
Michal Strehovský [Wed, 19 Jul 2023 21:38:47 +0000 (06:38 +0900)]
Build less of libs for CoreCLR tools tests (#89154)

Similar to #89153. I don't think we need System.Speech & co for tools tests.

16 months agoFix duplicated assets in official build (#89188)
Alexander Köplinger [Wed, 19 Jul 2023 20:52:53 +0000 (22:52 +0200)]
Fix duplicated assets in official build (#89188)

The additional osx-x64 and osx-arm64 legs added for NativeAOT in https://github.com/dotnet/runtime/pull/89018 caused the `runtime.osx-*.Microsoft.DotNet.ILCompiler` and runtime.osx-*.runtime.native.System.IO.Ports` packages to be duplicated.

This change makes sure we only publish them from one leg (the CoreCLR one).

16 months agoShare SourceWriter between JSON & config binding generators (#89150)
Layomi Akinrinade [Wed, 19 Jul 2023 19:56:50 +0000 (12:56 -0700)]
Share SourceWriter between JSON & config binding generators (#89150)

* Share SourceWriter between JSON & config binding generators

* Fix failing test, clean up impl, and address feedback

16 months agoAdd Driver.Context setter (#89081)
Mike Voorhees [Wed, 19 Jul 2023 19:41:57 +0000 (15:41 -0400)]
Add Driver.Context setter (#89081)

We implement our own `Driver.SetupContext`.  Our command line parsing logic is different and we have additional command line options.

In our very old revision of the upstream linker there was
```
protected LinkContext context;
```

Which we would set.  This would ensure that if one of the helper methods that uses the context were called that things would all work.
The most common scenario seems to be for error logging.  There are many helper methods that will call `Context.LogError` and if we haven't set the `context` field by then we have a problem.

We are syncing up and now the `context` field is private and there is a protected property getter, but no setter.

Adding a setter was the easiest way to get our context stored in the `context` field.

16 months agoClean up debugger attributes tests. (#89011)
Mike Voorhees [Wed, 19 Jul 2023 19:40:46 +0000 (15:40 -0400)]
Clean up debugger attributes tests. (#89011)

* Remove `SetupLinkerKeepDebugMembersAttribute`.  This isn't supported anymore by the linker.

* Remove NETCOREAPP behavior difference in debugger attribute removal tests

* Move `DebuggerDisplayAttributeOnTypeWithNonExistentMethod` to the `KeepDebugMembers` folder since that is the scenario this test is testing

16 months agoJIT: Clamp basic block IL ranges when splitting blocks (#89179)
Jakob Botsch Nielsen [Wed, 19 Jul 2023 19:20:20 +0000 (21:20 +0200)]
JIT: Clamp basic block IL ranges when splitting blocks (#89179)

In release, code motion/compaction may lead to statements ending up in
blocks that don't contain their IL offset. This can cause splitting of
blocks to create meaningless IL ranges such as [057..020). Since we
maintain these IL ranges on a best-effort basis, just clamp them when we
do the splitting.

Fix #88348

16 months ago[main] Update dependencies from dotnet/icu dotnet/emsdk (#89147)
dotnet-maestro[bot] [Wed, 19 Jul 2023 19:05:11 +0000 (14:05 -0500)]
[main] Update dependencies from dotnet/icu dotnet/emsdk (#89147)

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

Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport
 From Version 8.0.0-preview.7.23367.1 -> To Version 8.0.0-rc.1.23368.3

* Compute the package name from the version

* Use a generated regex

* Use VersionBandForManifestPackages for CI/dev versions

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

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 8.0.0-preview.7.23367.1 -> To Version 8.0.0-rc.1.23368.2

* Fix band calculation

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
16 months agoFix OSX like cases (#89187)
Ahmet Ibrahim Aksoy [Wed, 19 Jul 2023 18:59:29 +0000 (21:59 +0300)]
Fix OSX like cases (#89187)

16 months ago[PERF] Use script instead of powershell to set DOTNET_ROOT (#89123)
Parker Bibus [Wed, 19 Jul 2023 17:02:22 +0000 (10:02 -0700)]
[PERF] Use script instead of powershell to set DOTNET_ROOT (#89123)

Use script for non-windows and powershell for windows.
Use the proper path separators for non-windows and windows.

16 months agoFix failures around blittable collections with [Out] and chars (#89149)
Jeremy Koritzinsky [Wed, 19 Jul 2023 16:49:18 +0000 (09:49 -0700)]
Fix failures around blittable collections with [Out] and chars (#89149)

16 months agoJIT: Ensure last-use copy omission candidates are marked with GTF_GLOB_REF (#89088)
Jakob Botsch Nielsen [Wed, 19 Jul 2023 16:24:18 +0000 (18:24 +0200)]
JIT: Ensure last-use copy omission candidates are marked with GTF_GLOB_REF (#89088)

Last-use copy omission allows the JIT to avoid creating copies of struct
values that are passed implicitly by-ref when the value is a last-use of
a local. When we do this we effectively address expose the
local for the lifetime of the call, so we mark the local as address
exposed as part of doing so.

However, there is a problem where morph may reorder two uses of a such a
local and break the last use information. For example, consider the
following case:

```
[000015] --CXG------      ▌  CALL      void   Program:Foo(int,int)
[000010] ----------- arg0 ├──▌  LCL_FLD   int    V00 loc0         [+0]
[000012] --CXG------ arg1 └──▌  CALL      int    Program:Bar(S):int
[000011] ----------- arg0    └──▌  LCL_VAR   struct<S, 32> V00 loc0          (last use)
```

V00 is used both at [000010] and at [000011], the latter as a last use.
Since we only address expose V00 when we get to [000011] we do not mark
[000010] with GTF_GLOB_REF; the net effect is the following call args
morphing, where we have reordered the two occurrences illegally:

```
[000015] --CXG+-----             ▌  CALL      void   Program:Foo(int,int)
[000037] DACXG------ arg1 setup  ├──▌  STORE_LCL_VAR int    V04 tmp3
[000012] --CXG+-----             │  └──▌  CALL      int    Program:Bar(S):int
[000011] -----+----- arg0 in rcx │     └──▌  LCL_ADDR  long   V00 loc0         [+0]
[000038] ----------- arg1 in rdx ├──▌  LCL_VAR   int    V04 tmp3
[000010] -----+----- arg0 in rcx └──▌  LCL_FLD   int   (AX) V00 loc0         [+0]
```

This change fixes the problem by running a separate pass over the IR
before morph to identify and address expose the candidates for last-use
copy omission. The net result is then the following correct IR:

```
[000015] --CXG+-----             ▌  CALL      void   Runtime_85611:Foo(int,int)
[000039] DA--G------ arg0 setup  ├──▌  STORE_LCL_VAR int    V05 tmp4
[000010] ----G+-----             │  └──▌  LCL_FLD   int   (AX) V00 loc0         [+0]
[000037] DACXG------ arg1 setup  ├──▌  STORE_LCL_VAR int    V04 tmp3
[000012] --CXG+-----             │  └──▌  CALL      int    Runtime_85611:Bar(Runtime_85611+S):int
[000011] ----G+----- arg0 in rcx │     └──▌  LCL_ADDR  long   V00 loc0         [+0]
[000038] ----------- arg1 in rdx ├──▌  LCL_VAR   int    V04 tmp3
[000040] ----------- arg0 in rcx └──▌  LCL_VAR   int    V05 tmp4
```

The pass has some TP impact but it is mitigated since we only need to
visit statements with GTF_CALL and since we can use the locals tree list
to prune which statements we visit.

Fix #85611

16 months agoAvoid generating internal static classes with constant names in Options Source gen...
Tarek Mahmoud Sayed [Wed, 19 Jul 2023 15:33:39 +0000 (08:33 -0700)]
Avoid generating internal static classes with constant names in Options Source gen (#89148)

16 months ago[wasm] Use source generator for results data json serialization (#89177)
Radek Doulik [Wed, 19 Jul 2023 13:26:54 +0000 (15:26 +0200)]
[wasm] Use source generator for results data json serialization (#89177)

This fixes problem with posting results, where we crashed with:

    MONO_WASM:    at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerOptionsNoTypeInfoResolverSpecified()
       at System.Text.Json.JsonSerializerOptions.MakeReadOnly()
       at System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer()
       at System.Text.Json.JsonSerializer.GetTypeInfo(JsonSerializerOptions , Type )
       at System.Text.Json.JsonSerializer.GetTypeInfo[JsonResultsData](JsonSerializerOptions )
       at System.Text.Json.JsonSerializer.Serialize[JsonResultsData](JsonResultsData , JsonSerializerOptions )
       at Sample.Test.GetJsonResults()
       at Sample.Test.GetFullJsonResults()
       at Sample.Test.__Wrapper_GetFullJsonResults_234275758(JSMarshalerArgument* __arguments_buffer)
    ManagedError@http://localhost:8781/_framework/dotnet.runtime.js:3:29628
    vr@http://localhost:8781/_framework/dotnet.runtime.js:3:34757
    Ao@http://localhost:8781/_framework/dotnet.runtime.js:3:52015
    To/U</<@http://localhost:8781/_framework/dotnet.runtime.js:3:50790
    init@http://localhost:8781/main.js:118:19
    setTimeout handler*yieldBench/<@http://localhost:8781/main.js:129:49
    yieldBench@http://localhost:8781/main.js:129:16
    init@http://localhost:8781/main.js:108:45
    setTimeout handler*yieldBench/<@http://localhost:8781/main.js:129:49
    yieldBench@http://localhost:8781/main.js:129:16
    init@http://localhost:8781/main.js:108:45

16 months agoFix broken runtime tests build (second attempt) (#89176)
Viktor Hofer [Wed, 19 Jul 2023 12:39:12 +0000 (14:39 +0200)]
Fix broken runtime tests build (second attempt) (#89176)

* Fix broken runtime tests build (second attempt)

Continuation of https://github.com/dotnet/runtime/pull/89115

* Update build-test-job.yml

16 months agoFix outerloop tests in System.Formats.Tar (#89172)
Alexander Köplinger [Wed, 19 Jul 2023 12:01:05 +0000 (14:01 +0200)]
Fix outerloop tests in System.Formats.Tar (#89172)

The change from https://github.com/dotnet/runtime/pull/88280 caused an issue when discovering the test:

```
System.InvalidOperationException : An appropriate member 'ManualTestsEnabled' could not be found. The conditional method needs to be a static method, property, or field on the type System.Formats.Tar.Tests.ManualTestsAsync or any ancestor, of any visibility, accepting zero arguments, and having a return type of Boolean.
```

16 months agoRemove unnecessary closures from Logging{Scope}HttpMessageHandler.SendCoreAsync ...
Stephen Toub [Wed, 19 Jul 2023 11:18:41 +0000 (07:18 -0400)]
Remove unnecessary closures from Logging{Scope}HttpMessageHandler.SendCoreAsync (#89160)

* Avoid unnecessary closure in LoggingHttpMessageHandler.SendCoreAsync

* Remove unnecessary closure in LoggingScopeHttpMessageHandler.SendCoreAsync

16 months agoExpose `MarkStep.ScopeStack` (#89120)
Mike Voorhees [Wed, 19 Jul 2023 10:45:52 +0000 (06:45 -0400)]
Expose `MarkStep.ScopeStack` (#89120)

We need access to this during our mark step.

16 months agoFix ILVerifier holding files open (#89127)
Mike Voorhees [Wed, 19 Jul 2023 10:41:22 +0000 (06:41 -0400)]
Fix ILVerifier holding files open (#89127)

There were a couple things to fix

1) `PEReader` implements `IDisposable` and needs to be disposed.  Not least because it is managing the lifetime of the streams opened by `File.OpenRead` calls inside `ILVerifier`

2) In order to dispose of of the pereaders, add `IDisposable` to `ILVerifier` and add a `using` to the caller that creates a new instance.

(1) and (2) fix the issues with files being held open.

While looking at the code, I didn't see a reason why `TryLoadAssemblyFromFolder` couldn't check the `_assemblyCache` before creating a opening a new stream and creating a new pereader.  I don't think this was causing any issues.  It just seemed like a harmless just-in-case change.

16 months ago[libs][iOS] Unify `System.Linq.Expression.dll` build for all platforms (#88723)
Ivan Povazan [Wed, 19 Jul 2023 08:05:26 +0000 (10:05 +0200)]
[libs][iOS] Unify `System.Linq.Expression.dll` build for all platforms (#88723)

- Ship a single assembly for all platforms, and have better compatibility between our AOT engines
- Size of the shipped assembly for iOS-like platforms is increased by ~113Kb
- The fullAOT + UseInterpreter=true configurations with Mono are now interpreting Ref.Emit generated code instead of using Reflection
- To prevent size regressions with Mono https://github.com/xamarin/xamarin-macios/pull/18555 needs to be merged

16 months agoFix building the reproNative.vcxproj project (#89159)
Michal Strehovský [Wed, 19 Jul 2023 07:33:50 +0000 (16:33 +0900)]
Fix building the reproNative.vcxproj project (#89159)

This got broken in #74623.

16 months ago[mono][interp] Fix memory leaks for interpreted dynamic methods. (#88892)
Zoltan Varga [Wed, 19 Jul 2023 05:41:38 +0000 (01:41 -0400)]
[mono][interp] Fix memory leaks for interpreted dynamic methods. (#88892)

* [mono] Set the 'dynamic' flag on method builders on creation so a MonoDynamicMethod is allocated instead of a MonoMethodWrapper.

* [mono][interp] Fix memory leaks for interpreted dynamic methods.

* Add a mempool to MonoDynamicMethod.
* Modify the intepreter code to allocate from this mempool when
  interpreting dynamic methods.

16 months ago[mono] Register static rgctx trampolines in the JIT info tables. (#89142)
Zoltan Varga [Wed, 19 Jul 2023 05:41:17 +0000 (01:41 -0400)]
[mono] Register static rgctx trampolines in the JIT info tables. (#89142)

mini_init_delegate () needs to do a reverse lookup from address
to method, and its possible for the address to be a static rgctx
trampoline if the address is the result of mono_ldftn ().

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

16 months agoImprove JsonSourceGenerationOptionsAttribute xml documentation. (#89082)
Eirik Tsarpalis [Wed, 19 Jul 2023 04:11:21 +0000 (05:11 +0100)]
Improve JsonSourceGenerationOptionsAttribute xml documentation. (#89082)

16 months agoFix EqualsIgnoreCaseUtf8_Scalar (#89152)
Egor Bogatov [Wed, 19 Jul 2023 03:59:33 +0000 (05:59 +0200)]
Fix EqualsIgnoreCaseUtf8_Scalar (#89152)

* Fix EqualsIgnoreCaseUtf8_Scalar

* revert change

* Remove activeissue

16 months agoDisable the "casts between generated and built-in COM interop" analyzer when the...
Jeremy Koritzinsky [Wed, 19 Jul 2023 00:08:13 +0000 (17:08 -0700)]
Disable the "casts between generated and built-in COM interop" analyzer when the "enable interop between generated COM interop and built-in COM interop" feature is enabled. (#89125)

16 months agoFix binding logic for dictionaries with complex elements (#89117)
Layomi Akinrinade [Wed, 19 Jul 2023 00:05:20 +0000 (17:05 -0700)]
Fix binding logic for dictionaries with complex elements (#89117)

* Fix binding logic for dictionaries with complex elements

* Remove interace impls not relevant to test and causing issues

16 months agoAdd docs on using Bionic with NativeAOT (#88817)
Michal Strehovský [Wed, 19 Jul 2023 00:05:06 +0000 (09:05 +0900)]
Add docs on using Bionic with NativeAOT (#88817)

Resolves #87340.

16 months agoReact to HttpRequestError API changes (#89124)
Miha Zupan [Tue, 18 Jul 2023 23:45:39 +0000 (01:45 +0200)]
React to HttpRequestError API changes (#89124)

* React to HttpRequestError API changes

* Use InvalidResponse for net_http_invalid_response_multiple_status_codes

* Use HttpRequestError.Unknown for the rest

* Add simple tests for the HttpRequestError property

* Fix the inner exception being removed by mistake

16 months ago[main] Update dependencies from dotnet/icu dotnet/emsdk dotnet/hotreload-utils (...
dotnet-maestro[bot] [Tue, 18 Jul 2023 23:18:01 +0000 (18:18 -0500)]
[main] Update dependencies from dotnet/icu dotnet/emsdk dotnet/hotreload-utils (#89075)

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

Microsoft.NETCore.Runtime.ICU.Transport
 From Version 8.0.0-preview.7.23360.1 -> To Version 8.0.0-preview.7.23367.1

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

Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport
 From Version 8.0.0-preview.7.23362.1 -> To Version 8.0.0-preview.7.23367.1

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

Microsoft.DotNet.HotReload.Utils.Generator.BuildTool
 From Version 8.0.0-alpha.0.23360.1 -> To Version 8.0.0-alpha.0.23367.4

---------

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
16 months agoImprove GC pause counter naming (#89052)
Andrew Au [Tue, 18 Jul 2023 23:04:16 +0000 (16:04 -0700)]
Improve GC pause counter naming (#89052)

16 months agoExpose the left-handed matrix creation APIs (#88930)
Tanner Gooding [Tue, 18 Jul 2023 22:44:06 +0000 (15:44 -0700)]
Expose the left-handed matrix creation APIs (#88930)

16 months ago[hot_reload] Check for added fields earlier in compute_class_bitmap (#89121)
Aleksey Kliger (λgeek) [Tue, 18 Jul 2023 22:33:52 +0000 (18:33 -0400)]
[hot_reload] Check for added fields earlier in compute_class_bitmap (#89121)

Added fields don't contribute to the class bitmap, and they also might not have their type resolved yet - move the "is from update" check before we need to access the field's type

Fixes #86172

* Add regression test

* [hot_reload] Check for added fields earlier in compute_class_bitmap and in mono_class_create_runtime_vtable

16 months agoImprove choice of IndexOfXx routine for some TryFindNextStartingPosition implementati...
Stephen Toub [Tue, 18 Jul 2023 21:38:16 +0000 (17:38 -0400)]
Improve choice of IndexOfXx routine for some TryFindNextStartingPosition implementations (#89099)

Earlier in .NET 8, we updated the Regex compiler and source generator to be able to vectorize a search for any set, not just simple ones.  When one of the main routines couldn't be used, we emit a specialized IndexOfAny helper that uses SearchValues to search for any matching ASCII character or a Unicode character, and if it encounters a Unicode character, it falls back to a linear scan.  This meant that a bunch of sets that wouldn't previously have taken these paths now do, but some of those sets have more efficient means of searching; for example, for the set `[^aA]` that searches case-insensitive for anything other than an 'A', with these scheme we'll emit a whole routine that uses SearchValues with a fallback, but we could just use IndexOfAnyExcept('A', 'a').  This fixes the compiler / source generator to prefer such helpers instead when available.

16 months agoLight up Ascii.Equality.Equals and Ascii.Equality.EqualsIgnoreCase with Vector512...
Khushal Modi [Tue, 18 Jul 2023 21:18:10 +0000 (14:18 -0700)]
Light up Ascii.Equality.Equals and Ascii.Equality.EqualsIgnoreCase with Vector512 code path (#88650)

* merging with main
Enabling AVX512 for ASCII.Equals

* Correcting defects in the new Equals for AVX512 case

* Correcting defects

* Upgrading ASCII.Equality.EqualsIgnoreCase

* Using intrinsics in AllCharsInVectorAreAscii

* Using intrinsics in AllCharsInVectorAreAscii

* Removing check for AVX512F and adding a check for Vector512 because the library is not using any functions from AVX512F

* Removing check for CompExactlyDependsOn(AVX512F) from AllCharsInVectorAreAscii for Vector 512. Also checking for Vector512 support and not AVX512F in ASCIIEquality.Equals

* Correcting the Tloader.Count512 for ushort

* resolving merge errors

* Adding TLoader method for Vector512 for EqualAndAscii

* Updating Load512 for WideningLoader for performance increase

* addressing review comments

* Addressing review changes. Changing Widen to WidenLower for Load512

16 months agoOpenSSL ENGINE support (#88656)
Krzysztof Wicher [Tue, 18 Jul 2023 20:29:49 +0000 (22:29 +0200)]
OpenSSL ENGINE support (#88656)

* OpenSSL ENGINE support

* Remove trailing spaces on README file

* Address PR feedback

* Test for PNSE and run tests on all platforms supporting OSSL

* Update IsOpenSslSupported

* s/IsOpenSslSupported/OpenSslPresentOnSystem

* Fix OpenSslNotPresentOnSystem on Windows

* Add preventive OpenSslIsAvailable check for better error handling

16 months agoAdd opt-in support for GeneratedComInterface/ComImport RCW interop (#87583)
Jeremy Koritzinsky [Tue, 18 Jul 2023 20:27:37 +0000 (13:27 -0700)]
Add opt-in support for GeneratedComInterface/ComImport RCW interop (#87583)

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
16 months ago[mono] Align HOST_TVOS/TARGET_TVOS defines with the rest of the repo (#89085)
Alexander Köplinger [Tue, 18 Jul 2023 20:04:55 +0000 (22:04 +0200)]
[mono] Align HOST_TVOS/TARGET_TVOS defines with the rest of the repo (#89085)

In the mono build we've been setting HOST_IOS/TARGET_IOS when targeting tvOS which differs from the other runtime repo build systems and caused confusion. This aligns the defines so we only set the iOS ones on iOS and not on tvOS.

Also removes mono_dl_get_system_dir() since it was not actually used.

16 months agoReenable a test on iOS/tvOS/Browser that was disabled (#89083)
Alexander Köplinger [Tue, 18 Jul 2023 20:04:37 +0000 (22:04 +0200)]
Reenable a test on iOS/tvOS/Browser that was disabled (#89083)

16 months agoAdd more details in PlatformNotSupportedException (#89112)
Marie Píchová [Tue, 18 Jul 2023 19:32:36 +0000 (21:32 +0200)]
Add more details in PlatformNotSupportedException (#89112)

16 months agoJSON: Add support for Int128, UInt128 and Half (#88962)
David Cantú [Tue, 18 Jul 2023 19:29:40 +0000 (14:29 -0500)]
JSON: Add support for Int128, UInt128 and Half (#88962)

* JSON: Add support for Int128, UInt128 and Half and add Number support for Utf8JsonReader.CopyString(...)

* Remove parsing limits on Read and move Number support of CopyString to an internal helper

* Fix AllowNamedFloatingPointLiterals on Write for Half

* Specify InvariantCulture on TryParse and TryFormat
Fix handling of floating-point literals on HalfConverter
Remove CopyString tests related to Number support

* Add test for invalid number input format

* Fix net6.0 build error about missing Half.TryParse overload

* Move rentedCharBuffer logic to TryParse helper

* Address feedback

* Disable test for OSX

16 months agoUse Span.CopyTo(Span) in BigInteger's add and subtract (#83951), fixes #83457
Alexander Speshilov [Tue, 18 Jul 2023 19:20:19 +0000 (22:20 +0300)]
Use Span.CopyTo(Span) in BigInteger's add and subtract (#83951), fixes #83457

* Use Span.CopyTo(Span) in BigInteger's add and subtract

In BigIntegerCalculator methods Add and Subtract, if sizes of arguments
differ, after processing the part of size of the right (small) argument,
there was loop of add/sub carry value. When the carry value once become
zero, in fact the rest of the larger argument can be copied to the result.

With this commit the second loop is interrupted when carry become zero
and applies fast Span.CopyTo(Span) to the rest part.

This optimization applied only when size of the greatest argument is more
or equal to const CopyToThreshold introduced in this commit. This const
is 8 now.
See #83457 for details.

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
16 months agoFix broken runtime tests build (#89115)
Viktor Hofer [Tue, 18 Jul 2023 18:51:43 +0000 (20:51 +0200)]
Fix broken runtime tests build (#89115)

* Fix broken runtime tests build

Follow-up on https://github.com/dotnet/runtime/pull/89005

* Update build-test-job.yml

* Update sfx-ref.proj

16 months agoEnable SxS workload manifests (#88781)
Jacques Eloff [Tue, 18 Jul 2023 18:47:28 +0000 (11:47 -0700)]
Enable SxS workload manifests (#88781)

16 months agoDisable reflection in source gen tests and fix AOT testing. (#89105)
Eirik Tsarpalis [Tue, 18 Jul 2023 18:36:18 +0000 (19:36 +0100)]
Disable reflection in source gen tests and fix AOT testing. (#89105)

16 months ago[Android] Use NDK toolchain instead of CMake for library mode (#88886)
Steve Pfister [Tue, 18 Jul 2023 18:23:15 +0000 (11:23 -0700)]
[Android] Use NDK toolchain instead of CMake for library mode (#88886)

This change switches from relying on CMake to clang directly for Android library mode. The intent is to keep the number of build dependencies to a minimum.

16 months agoFixing concurrency issue in ManagedWebSocket where calling Dispose could corrupt...
Ivan Zlatanov [Tue, 18 Jul 2023 17:46:59 +0000 (20:46 +0300)]
Fixing concurrency issue in ManagedWebSocket where calling Dispose could corrupt state if there is pending send or receive operation and compression is enabled. (#87966)

16 months agoMark final types as exact (#88163)
Michał Petryka [Tue, 18 Jul 2023 17:46:32 +0000 (19:46 +0200)]
Mark final types as exact (#88163)

Co-authored-by: Andy Ayers <andya@microsoft.com>
16 months agoFold BOX+ISINST to null if possible (#88989)
Egor Bogatov [Tue, 18 Jul 2023 17:30:48 +0000 (19:30 +0200)]
Fold BOX+ISINST to null if possible (#88989)

16 months agoEnable Nullable compilation on the Options source gen (#88973)
Tarek Mahmoud Sayed [Tue, 18 Jul 2023 17:26:56 +0000 (10:26 -0700)]
Enable Nullable compilation on the Options source gen (#88973)

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>