platform/upstream/dotnet/runtime.git
2 years agoMerge pull request #78077 from dotnet/LinkerIntoRuntime2
Andy Gocke [Wed, 16 Nov 2022 22:12:48 +0000 (14:12 -0800)]
Merge pull request #78077 from dotnet/LinkerIntoRuntime2

Merge ILLink from the dotnet/linker repo into the runtime repo

Tests are working, but packages are not publishing. Follow-up issues at https://github.com/dotnet/runtime/issues/78334

2 years agoDon't inline >8 bytes of IL calls in BBJ_THROW (#78386)
Egor Bogatov [Wed, 16 Nov 2022 21:40:08 +0000 (22:40 +0100)]
Don't inline >8 bytes of IL calls in BBJ_THROW (#78386)

2 years ago[wasm] Add intrinsics for BitOperations zero count (#78391)
Radek Doulik [Wed, 16 Nov 2022 21:09:23 +0000 (22:09 +0100)]
[wasm] Add intrinsics for BitOperations zero count (#78391)

2 years agoFixes around virtual method hierarchy validation (#78157)
Vitek Karas [Wed, 16 Nov 2022 21:06:37 +0000 (13:06 -0800)]
Fixes around virtual method hierarchy validation (#78157)

Adds the test from linker and fixes to make it work.
Mostly finding all the places where we can detect method overrides.

2 years agoPrefer OutputRid over PackageRID for output artifacts. (#76871)
Tom Deseyn [Wed, 16 Nov 2022 20:57:07 +0000 (21:57 +0100)]
Prefer OutputRid over PackageRID for output artifacts. (#76871)

* Prefer OutputRid over PackageRID for output artifacts.

This is a non-functional change that makes it more visible
these are output artifacts.

* installer/tests: keep using PackageRID.

* System.Net.*/tests: use OutputRid everywhere.

2 years agoOnly R2R public methods, methods that override public methods, and internal methods...
Jeremy Koritzinsky [Wed, 16 Nov 2022 20:56:51 +0000 (12:56 -0800)]
Only R2R public methods, methods that override public methods, and internal methods that aren't always inlined (#75793)

2 years agoDisable distributed transactions test (#78468)
Shay Rojansky [Wed, 16 Nov 2022 20:21:36 +0000 (21:21 +0100)]
Disable distributed transactions test (#78468)

See #77241

2 years agoFix single quote processing from debug output. (#78479)
Jiri Cincura ↹ [Wed, 16 Nov 2022 20:04:39 +0000 (21:04 +0100)]
Fix single quote processing from debug output. (#78479)

2 years agoAdd more readme for M.E libraries (#78477)
Maryam Ariyan [Wed, 16 Nov 2022 20:03:23 +0000 (15:03 -0500)]
Add more readme for M.E libraries (#78477)

2 years ago[main] Update dependencies from dotnet/runtime dotnet/llvm-project dotnet/icu dotnet...
dotnet-maestro[bot] [Wed, 16 Nov 2022 19:58:31 +0000 (19:58 +0000)]
[main] Update dependencies from dotnet/runtime dotnet/llvm-project dotnet/icu dotnet/xharness dotnet/emsdk dotnet/roslyn-analyzers dotnet/roslyn (#78314)

[main] Update dependencies from dotnet/runtime dotnet/llvm-project dotnet/icu dotnet/xharness dotnet/emsdk dotnet/roslyn-analyzers dotnet/roslyn

2 years agoAdding check on R2RDump (#78343)
Brian Bohe [Wed, 16 Nov 2022 19:42:09 +0000 (11:42 -0800)]
Adding check on R2RDump (#78343)

* Adding check on variable debug info ranges

* Adding r2rdump command argument --val

Set it to ensure variable debug info is not empty.

* Adding new r2rdump argument to test script

* Adding new r2rdump argument to CoreLib dump test

* Adding new r2rdump argument to tests

Co-authored-by: Brian Bohe <brianbohe@microsoft.com>
2 years ago[wasm] Add link to debugger docs from WasmAppHost docs (#78471)
Marek Fišera [Wed, 16 Nov 2022 19:02:40 +0000 (20:02 +0100)]
[wasm] Add link to debugger docs from WasmAppHost docs (#78471)

* [wasm] Add link to debugger docs from WasmAppHost docs.

* Forward and backward slashes

* Fix

2 years agonew RID: wasi-wasm (#78376)
Pavel Savara [Wed, 16 Nov 2022 18:51:59 +0000 (19:51 +0100)]
new RID: wasi-wasm (#78376)

- new RID: wasi-wasm
- msbuild: TargetsWasi, mono.wasiruntime subset
- differentiate wasm on Browser from wasm on Wasi, renamed IsBrowserProject
- build shell files
- initial CMake files
- CI pipeline platform wasi_wasm
- OperatingSystem.OSPlatformName ="Wasi"
- OperatingSystem.IsWasi()

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
2 years ago[NativeAOT] Address some COOP native helpers that could cause suspension pauses....
Vladimir Sadov [Wed, 16 Nov 2022 18:48:20 +0000 (10:48 -0800)]
[NativeAOT] Address some COOP native helpers that could cause suspension pauses. (#78450)

* Memmove<T> to shared source.

* Delete RhpCopyObjectContents

* RhCompareObjectContentsAndPadding is ok, but added an assert.

* remove unused BulkMoveWithWriteBarrier in Augments

2 years ago[marshal] Cleanup dead ifdefs (#78435)
Aleksey Kliger (λgeek) [Wed, 16 Nov 2022 18:44:43 +0000 (13:44 -0500)]
[marshal] Cleanup dead ifdefs (#78435)

1. The `DISABLE_NONBLITTABLE` define was a previous attempt at partitioning the marshaling into a simple version that just supports blittable types and the full legacy marshaller.  It was never used in production.

2. The `ENABLE_ILGEN` was used previously in configurations where runtime codegen was not available to save some space by excluding support for emitting IL at runtime (needed for marshaling, fast managed allocators in sgen, etc).  It also used to emit the ilgen support code into a separate static library that could optionallly be linked into the runtime, and enabled with an appropriate API call (`mono_marshal_ilgen_init`).  This define is now on by default and the API function is a no-op.

3. Mark a collection of `mono_win32_compat_` functions with `MONO_RT_EXTERNAL_ONLY` and move them to `external-only.c` (these were used in mono/mono dllmap support to provide some common kernel32 functions on non-Windows)

4. Remove `MonoMarshalILgenCallbacks` in `marshal-ilgen.c` - just do direct calls to the `_ilgen` helper functions

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

2 years agoAdds readme for more extension items (#77865)
Maryam Ariyan [Wed, 16 Nov 2022 18:25:31 +0000 (13:25 -0500)]
Adds readme for more extension items (#77865)

2 years agoRemove most *PrintToStd* functions (#78437)
Aaron Robinson [Wed, 16 Nov 2022 16:59:09 +0000 (08:59 -0800)]
Remove most *PrintToStd* functions (#78437)

These functions either weren't used or simply called
each other directly. This reduces them to the only
ones we actually need.

Remove the ExposeExceptionsInCOM knob that isn't
used by the .NET Interop team at all.

2 years agoFix parameters order when creating XmlConfigurationElementTextContent object (#78433)
Tarek Mahmoud Sayed [Wed, 16 Nov 2022 16:58:14 +0000 (08:58 -0800)]
Fix parameters order when creating XmlConfigurationElementTextContent object (#78433)

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

2 years ago[wasm] Use Helix's retry mechanism to re-run debugger tests on CI if .. (#78357)
Ankit Jain [Wed, 16 Nov 2022 16:37:16 +0000 (11:37 -0500)]
[wasm] Use Helix's retry mechanism to re-run debugger tests on CI if .. (#78357)

.. they failed while waiting for the browser to launch.

Related: https://github.com/dotnet/arcade/tree/main/src/Microsoft.DotNet.Helix/Sdk#test-retry

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

2 years agoJIT: Use compile time handle for instruction comments on xarch too (#78382)
Jakob Botsch Nielsen [Wed, 16 Nov 2022 13:55:58 +0000 (14:55 +0100)]
JIT: Use compile time handle for instruction comments on xarch too (#78382)

When displaying addr modes we were using the base constant as the handle
type, which does not work in R2R code. We would end up displaying
"hackishClassName" for class handles (the SPGO handler ends up handling
the exception thrown).

We're already storing the proper compile time handle in the debug
information (in particular due to arm64), so we can just use that
instead.

2 years agoDedup Enumerable.Any with Enumerable.TryGetNonEnumeratedCount (#78438)
Stephen Toub [Wed, 16 Nov 2022 11:42:33 +0000 (06:42 -0500)]
Dedup Enumerable.Any with Enumerable.TryGetNonEnumeratedCount (#78438)

2 years agoAdd sdcardfs to filesystems list (#78424)
Adeel Mujahid [Wed, 16 Nov 2022 11:19:26 +0000 (13:19 +0200)]
Add sdcardfs to filesystems list (#78424)

2 years agoAdd HashTo/GetCurrentHashAs{UInt32/64} methods (#78075)
Stephen Toub [Wed, 16 Nov 2022 11:12:53 +0000 (06:12 -0500)]
Add HashTo/GetCurrentHashAs{UInt32/64} methods (#78075)

* Add HashTo/GetCurrentHashAs{UInt32/64} methods

* Address PR feedback

2 years agoUse IndexOfAny in IndexOfHtmlAttributeEncodingChars (#78240)
Stephen Toub [Wed, 16 Nov 2022 11:11:21 +0000 (06:11 -0500)]
Use IndexOfAny in IndexOfHtmlAttributeEncodingChars (#78240)

* Use IndexOfAny in IndexOfHtmlAttributeEncodingChars

* Tweak usage of IndexOf

2 years agoUse zero register in csel when possible (#78330)
SwapnilGaikwad [Wed, 16 Nov 2022 09:45:14 +0000 (09:45 +0000)]
Use zero register in csel when possible (#78330)

2 years agoFixing typo in area-owners (#78429)
Jose Perez Rodriguez [Wed, 16 Nov 2022 08:45:56 +0000 (00:45 -0800)]
Fixing typo in area-owners (#78429)

2 years agoIntroduce WASM JITs for interpreter opcodes, do_jit_call, and interp_entry wrappers...
Katelyn Gadd [Tue, 15 Nov 2022 22:02:59 +0000 (14:02 -0800)]
Introduce WASM JITs for interpreter opcodes, do_jit_call, and interp_entry wrappers (#76477)

This PR introduces a "jiterpreter" just-in-time WASM compiler for interpreter opcodes along with a set of specialized WASM JIT compilers to improve the performance of interp_entry and do_jit_call. The result is significantly improved performance for pure-interpreter workloads along with measurable speedups for interp->aot and aot->interp transitions in mixed mode AOT applications. In this commit it is disabled by default, with the exception of an optimization to use wasm exception handling if available for do_jit_call (as a replacement for mono_llvm_catch_cpp_exception).

It will be enabled by default in a future PR.

2 years agoUpdating fabricbot area pods (#78415)
Jose Perez Rodriguez [Tue, 15 Nov 2022 21:08:50 +0000 (13:08 -0800)]
Updating fabricbot area pods (#78415)

* Updating fabricbot area pods

* Also update area-owners.json

2 years ago[MONO] Move Marshal-ilgen into a component (#75542)
Nathan Ricci [Tue, 15 Nov 2022 20:48:03 +0000 (15:48 -0500)]
[MONO] Move Marshal-ilgen into a component (#75542)

* Move marshal_ilgen into a component.

2 years agoLinker into runtime diff2 (#78049)
Tlakaelel Axayakatl Ceja [Wed, 9 Nov 2022 00:16:11 +0000 (16:16 -0800)]
Linker into runtime diff2 (#78049)

* Merge and remove common files
Remove arcade eng\common directory in src\tools\illink since now we will use the runtime arcade infra
Remove build.cmd/build.sh and lint.cmd/lint.sh in src\tools\illink directory since now they will execute via a subset
Remove/Merge common files from src\tools\illink root:
 - .gitattributes
 - .gitignore
 - .github
 - .gitmodules
 - after.illink.sln.targets
 - code_of_conduct.md
 - global.json
 - LICENSE.txt
 - NuGet.config
 - THIRD-PARTY-NOTICES.TXT
Remove/Merge common files from src\tools\illink\eng:
 - Build.props
 - Publishing.props
 - Signing.props
 - SourceBuild.props
 - SourceBuildPrebuiltBaseline.xml
 - Tools.props
 - Version.Details.xml
 - Versions.props

* Create subsets to be able to build illink
Create a variable for the tools folder in runtime
Add subsets tools.illink and tools.illinktests for building illink and unitest it
Add Microsoft.DotNet.Cecil dependencies to runtime and to illink projects
Some workarounds to be able to build illink
Delete some cecil information from the external folder since now its a package

* Refactorings to make test work
Test projects use to have relative paths based on the current working directory to know where to find stuff, now that the project is in a different place things are not found, this commit changes to instead use MSBuild variables to calculate where things are
Add the cecil package to tests
Change a cecil test that verify the official package name to only care about the important pieces

* Enable pipeline
Add a variable to recognize when illink contains a change, and set an exclusion of the src/tools/* for other repos
Reuse the dotnet-linker-tests pipeline file to also run illink unitests every time there are illink changes

* Fix Markdown lint

* Remove checked-in binaries

* Use nunit for linker tests and fix cecil version test

2 years agoFix ALC lookup from the DAC (#78400)
Aaron Robinson [Tue, 15 Nov 2022 20:29:50 +0000 (12:29 -0800)]
Fix ALC lookup from the DAC (#78400)

* Fix ALC lookup from the DAC

It seems the SOS commands for ALC lookup have
been broken for a bit. Some parts of the impl
weren't DAC-ized and caused failures.

2 years agoFix Parameter order passed to ConfigurationDebugViewContext (#78352)
Tarek Mahmoud Sayed [Tue, 15 Nov 2022 18:47:45 +0000 (10:47 -0800)]
Fix Parameter order passed to ConfigurationDebugViewContext (#78352)

Fix https://github.com/dotnet/runtime/issues/78306

2 years agoVarious support changes and cleanups for the jiterpreter PR (#78225)
Katelyn Gadd [Tue, 15 Nov 2022 18:32:34 +0000 (10:32 -0800)]
Various support changes and cleanups for the jiterpreter PR (#78225)

Introduce mono_interp_is_method_multicastdelegate_invoke
Add interpreter opcodes for Math.Min, Math.Max, and Math.Abs
Make it easy to configure AOT+trimming for browser-bench to do comparison tests between AOT and interp
Add missing td->cbb update in interpreter transform
Add mono_wasm_array_length_ref missing safe wasm API
Optimize out linker placeholder wrappers that were slowing down most C->TS calls
Generate warning messages for missing cwraps imports from C
Simplify/optimize _zero_region

2 years agoTrigger AVX-512 pipeline on PRs, not merges (#78351)
Bruce Forstall [Tue, 15 Nov 2022 17:29:43 +0000 (09:29 -0800)]
Trigger AVX-512 pipeline on PRs, not merges (#78351)

2 years ago[wasm] Test `SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http11.ResponseHead...
Marek Fišera [Tue, 15 Nov 2022 16:57:11 +0000 (17:57 +0100)]
[wasm] Test `SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http11.ResponseHeaders_ExtraWhitespace_Trimmed` not supported on NodeJS. (#78375)

Test `SocketsHttpHandlerTest_HttpClientHandlerTest_Headers_Http11.ResponseHeaders_ExtraWhitespace_Trimmed` is not supported on NodeJS.
Test introduced in the https://github.com/dotnet/runtime/pull/74393.
Closes https://github.com/dotnet/runtime/issues/77631.

2 years ago[mono] Force AOT+interpreter for iOSSimulator arm64 library test local build (#76551)
Mitchell Hwang [Tue, 15 Nov 2022 14:18:08 +0000 (09:18 -0500)]
[mono] Force AOT+interpreter for iOSSimulator arm64 library test local build (#76551)

* [mono] Force AOT and interpreter for iOSSimulator arm64 library test build

* [mono] Extend Force AOT+interpreter to iOS device

* [mono] Enable Force Interp+AOT for tvOS device and arm64 sim

* [iOS][tvOS] Update build with auto populated RunAOTCompilation and MonoForceInterpreter properties

* Remove RunAOTCompilation and MonoForceInterpreter from iOS/tvOS pipelines

* Revert "Remove RunAOTCompilation and MonoForceInterpreter from iOS/tvOS pipelines"

This reverts commit f27b1ae15a6434e95415f30e7e01c74258e3046c.

2 years ago[PERF] Fix mono dotnet creation (#78257)
Parker Bibus [Tue, 15 Nov 2022 09:22:46 +0000 (01:22 -0800)]
[PERF] Fix mono dotnet creation (#78257)

2 years agofix MulticastLoopback option for IPv6 (#78285)
Tomas Weinfurt [Mon, 14 Nov 2022 19:25:10 +0000 (11:25 -0800)]
fix MulticastLoopback option for IPv6 (#78285)

2 years agoRemoving obsolete references to 'emitMaxTmpSize' (#78199)
DeepakRajendrakumaran [Mon, 14 Nov 2022 19:11:47 +0000 (11:11 -0800)]
Removing obsolete references to 'emitMaxTmpSize' (#78199)

2 years agoRemove unused method in CngKey
Kevin Jones [Mon, 14 Nov 2022 18:23:13 +0000 (13:23 -0500)]
Remove unused method in CngKey

2 years agoLonger timeout for Interpreter run (#78311)
Jiri Cincura ↹ [Mon, 14 Nov 2022 17:26:26 +0000 (18:26 +0100)]
Longer timeout for Interpreter run (#78311)

2 years agoAdd a VN-based dead store removal phase (#77990)
SingleAccretion [Mon, 14 Nov 2022 16:49:03 +0000 (19:49 +0300)]
Add a VN-based dead store removal phase (#77990)

* Add a flag for explicit inits

* Move optConservativeNormalVN

* Fix call rationalization

* Add VN-based dead store removal

* Limit to partial stores only

Fewer regressions; a bit faster TP-wise.

Diffs (libraries.pmi) for the full implementation:
---------------------------------------------------------------------------------
 2,236 contexts with diffs (1,871 improvements, 111 regressions)
   -25,583/+1,467 bytes

Diffs (libraries.pmi) for partial definitions only:
---------------------------------------------------------------------------------
 1,687 contexts with diffs (1,683 improvements, 3 regressions)
   -23,661/+25 bytes

TP impact about the same, ~0.05% against ~0.045%.

* Revert "Add a flag for explicit inits"

This reverts commit 127dccf0a3ee0462a0d5c435548c4a200661e354.

* Fix VN logic for zero-init

(The "lvaIsOSRLocal" check in codegen was redundant)

* Add JitEnableVNBasedDeadStoreRemovalRange

* Update phase description

2 years agoJIT: Check layout equality of GT_OBJ/GT_BLK nodes in GenTree::Compare (#78312)
Jakob Botsch Nielsen [Mon, 14 Nov 2022 15:58:14 +0000 (16:58 +0100)]
JIT: Check layout equality of GT_OBJ/GT_BLK nodes in GenTree::Compare  (#78312)

Fix #78310

2 years agoFix argument exception names in File/DirectoryInfo (#78239)
Stephen Toub [Mon, 14 Nov 2022 15:48:34 +0000 (10:48 -0500)]
Fix argument exception names in File/DirectoryInfo (#78239)

2 years agoArm64: Support additional condition checks in select nodes (#78223)
Alan Hayward [Mon, 14 Nov 2022 13:59:26 +0000 (13:59 +0000)]
Arm64: Support additional condition checks in select nodes (#78223)

Generating a FEQ or FNEU will generate an incorrect compare.

With the optimizer code fixed, it's not possible to generate a
test to trigger the code in codegen. However, the code as it is was
wrong. Given it's untested, it might be better to replace it with
some asserts?

I've added some general compare consume tests to ensure everything
is generated ok.

2 years ago[mono] Fix some asserts caused by #78182. (#78291)
Zoltan Varga [Mon, 14 Nov 2022 09:30:20 +0000 (04:30 -0500)]
[mono] Fix some asserts caused by #78182. (#78291)

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

2 years ago[mono][llvm] Fix a crash when emitting P_OBJC_GET_SELECTOR opcodes. (#78215)
Zoltan Varga [Mon, 14 Nov 2022 08:46:21 +0000 (03:46 -0500)]
[mono][llvm] Fix a crash when emitting P_OBJC_GET_SELECTOR opcodes. (#78215)

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

2 years agoNumber block assignments normally (#77690)
SingleAccretion [Mon, 14 Nov 2022 08:42:02 +0000 (11:42 +0300)]
Number block assignments normally (#77690)

Aka delete "fgValueNumberBlockAssignment".

2 years agoFix handling generic custom attributes (#78297)
Michal Strehovský [Mon, 14 Nov 2022 03:36:58 +0000 (12:36 +0900)]
Fix handling generic custom attributes (#78297)

Fixes #78200.

2 years agoRevert "Allocate boxed static structs on Frozen Object Heap and remove getFieldAddres...
Egor Bogatov [Mon, 14 Nov 2022 03:36:31 +0000 (04:36 +0100)]
Revert "Allocate boxed static structs on Frozen Object Heap and remove getFieldAddress (#77737)" (#78296)

This reverts commit cabb8b089fd3d84fc46446c2079ddc1981b55fd9.

2 years agoFix `--singlemethodname` (#78207)
Michal Strehovský [Sun, 13 Nov 2022 23:44:30 +0000 (08:44 +0900)]
Fix `--singlemethodname` (#78207)

Single method compilation mode broke with the change to use System.CommandLine. "Not specified" no longer means `null`.

2 years agoComputeManagedAssembliesToCompileToNative: Make microsoft.netcore.app check case...
Alex Rønne Petersen [Sun, 13 Nov 2022 23:43:17 +0000 (00:43 +0100)]
ComputeManagedAssembliesToCompileToNative: Make microsoft.netcore.app check case-insensitive. (#78022)

The inputs can come from SDK pack paths where the Microsoft.NETCore.App part of
the path is *not* lower case, resulting in files such as coreclr.dll,
createdump.exe, etc being copied to the publish directory.

2 years agoAllocate boxed static structs on Frozen Object Heap and remove getFieldAddress (...
Egor Bogatov [Sun, 13 Nov 2022 20:48:33 +0000 (21:48 +0100)]
Allocate boxed static structs on Frozen Object Heap and remove getFieldAddress (#77737)

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoFix nullable annotations in ITypeDescriptorContext (#78287)
gpetrou [Sun, 13 Nov 2022 13:28:42 +0000 (15:28 +0200)]
Fix nullable annotations in ITypeDescriptorContext (#78287)

2 years agoDon't emit manifest for NativeRuntimeEventSource (#78213)
David Mason [Sun, 13 Nov 2022 08:13:15 +0000 (00:13 -0800)]
Don't emit manifest for NativeRuntimeEventSource (#78213)

2 years agoUpdate deep-dive-blog-posts.md (#78281)
Stephen Toub [Sun, 13 Nov 2022 00:50:31 +0000 (19:50 -0500)]
Update deep-dive-blog-posts.md (#78281)

2 years agofix: [Wasm] Adjust windows build (#70689)
Jérôme Laban [Sat, 12 Nov 2022 14:17:58 +0000 (09:17 -0500)]
fix: [Wasm] Adjust windows build (#70689)

Co-authored-by: Ankit Jain <radical@gmail.com>
2 years agoFix Equals in hot reload scenario (#78249)
Buyaa Namnan [Sat, 12 Nov 2022 03:22:24 +0000 (19:22 -0800)]
Fix Equals in hot reload scenario (#78249)

* Fix Equals in hot reload scenario

Co-authored-by: Steve Harter <steveharter@users.noreply.github.com>
2 years agoDelete `fgMorphBlockOperand` (#77688)
SingleAccretion [Sat, 12 Nov 2022 00:45:34 +0000 (03:45 +0300)]
Delete `fgMorphBlockOperand` (#77688)

* Stop calling fgMorphBlockOperand

* Fix missing NO_CSEs

* Simplify

* Delete fgMorphBlockOperand

2 years agoReact to CheckForOverflowUnderflow in regex source generator (#78228)
Stephen Toub [Fri, 11 Nov 2022 22:59:41 +0000 (17:59 -0500)]
React to CheckForOverflowUnderflow in regex source generator (#78228)

* React to CheckForOverflowUnderflow in regex source generator

The regex source generator uses code patterns that might have arithmetic overflows, e.g. a bounds check with `(uint)index < span.Length`.  These are intentional, and they're benign... unless the project/compilation has opted-in to overflow/underflow checking (CheckForOverflowUnderflow).  In that case, the code for many patterns can start throwing false positive overflow exceptions, making the source generator unusable.

This commit causes the generator to look at the CheckOverflow setting in the compilation options, and if it's set, to emit `unchecked { ... }` around all the relevant code.

* Address PR feedback

2 years agoSystem.Diagnostics.TraceSource readme small typo (#78253)
Carlos Sanchez [Fri, 11 Nov 2022 22:49:59 +0000 (14:49 -0800)]
System.Diagnostics.TraceSource readme small typo (#78253)

The framework where we publish it is NETCore.App, not WindowsDesktop.

2 years agoSystem.Diagnostics.EventLog: Add README (#78243)
Carlos Sanchez [Fri, 11 Nov 2022 22:32:36 +0000 (14:32 -0800)]
System.Diagnostics.EventLog: Add README (#78243)

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
2 years agoFix relative symlink support in TarFile (#77338)
Adeel Mujahid [Fri, 11 Nov 2022 21:46:06 +0000 (23:46 +0200)]
Fix relative symlink support in TarFile (#77338)

* Fix relative symlink support in TarFile

* Update src/libraries/System.Formats.Tar/tests/TarFile/TarFile.CreateFromDirectory.File.Roundtrip.cs

Co-authored-by: David Cantú <dacantu@microsoft.com>
Co-authored-by: David Cantú <dacantu@microsoft.com>
2 years ago[mono][aot] Prefer concrete instances instead of gshared ones for met… (#78182)
Zoltan Varga [Fri, 11 Nov 2022 21:15:35 +0000 (16:15 -0500)]
[mono][aot] Prefer concrete instances instead of gshared ones for met… (#78182)

* [mono][aot] Prefer concrete instances instead of gshared ones for methods containing type equality checks.

For example, calls to Vector<T>.IsSupported cannot be optimized away in a method where T
is T_BYTE because its written as:

```
            get => (typeof(T) == typeof(byte)) ||
                   (typeof(T) == typeof(double)) ||
```

and T_BYTE could be instantiated with an enum whose basetype is byte.

Fixes some of the issues in https://github.com/dotnet/runtime/issues/78163.

* Avoid an assert when compiling Vector<object> instances.

2 years agoFix recursive assembly spec parsing with textual PGO (#78035)
Jakob Botsch Nielsen [Fri, 11 Nov 2022 21:12:33 +0000 (22:12 +0100)]
Fix recursive assembly spec parsing with textual PGO (#78035)

* Add thread local to skip textual PGO data if invoked recursively
* Change AssemblyNameParser.ParseVersion to pass
  NumberFormatInfo.InvariantInfo in its ushort.TryParse invocation.
  This avoids initializing globalization from within this parsing, which
  was causing problems in the textual PGO scenario.

Fix #77971

2 years agoMemoryExtensions.Replace(Span<T>, T, T) implemented (#76337)
Günther Foidl [Fri, 11 Nov 2022 20:50:56 +0000 (21:50 +0100)]
MemoryExtensions.Replace(Span<T>, T, T) implemented (#76337)

* Defined API

* Tests

* Scalar implementation

* Use EqualityComparer<T>.Default instead

* Delegation to SpanHelpers.Replace

* ReplaceValueType implemented

* Use ushort instead of short, as it doesn't sign-extend for broadcast and in the scalar loop

* Forward string.Replace(char, char) to SpanHelpers.ReplaceValueType

* Process remainder vectorized only when not done already and with max width available

* Split into inlineable scalar path and non-inlineable vectorized path

* Replaced open coded loops with Replace

* Don't use EqualityComparer<T>.Default

Cf. https://github.com/dotnet/runtime/pull/76337#discussion_r982886319

* Remove guards for remainder

Cf. https://github.com/dotnet/runtime/pull/76337#discussion_r983448480

* Don't split method into scalar and vectorized and don't force inlining of scalar-part

* Fixed assert

ReplaceValueType is called from string.Replace(char, char) so the Debug.Assert was on wrong position, as at entry to method non accelerated platforms are allowed to call it.

* Better handling of remainder from the vectorized loop(s)

Intentionally leave one iteration off, as the remaining elements are done vectorized anyway. This eliminates the less probable case (cf. https://github.com/dotnet/runtime/pull/76337#discussion_r983448480) that the last vector is done twice.

* PR feedback

2 years agoSystem.Diagnostics.PerformanceCounter: Add README (#78244)
Carlos Sanchez [Fri, 11 Nov 2022 20:10:51 +0000 (12:10 -0800)]
System.Diagnostics.PerformanceCounter: Add README (#78244)

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
2 years agoSystem.Diagnostics.TraceSource: Add README (#78245)
Carlos Sanchez [Fri, 11 Nov 2022 20:10:22 +0000 (12:10 -0800)]
System.Diagnostics.TraceSource: Add README (#78245)

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
2 years agoHardware intrinsics tests in new style (#74886)
David Wrighton [Fri, 11 Nov 2022 19:56:17 +0000 (11:56 -0800)]
Hardware intrinsics tests in new style (#74886)

Port all of the vector tests to the new xunit style specification
- Test disables need to use the attribute based form
- All tests are run on all architectures (This wasn't happening in the old system, but hopefully with test striping the need for this has gone away.)

2 years agoEnsure ReadBufferState resets any BOM offsets every time the buffer is advanced....
Eirik Tsarpalis [Fri, 11 Nov 2022 17:53:56 +0000 (17:53 +0000)]
Ensure ReadBufferState resets any BOM offsets every time the buffer is advanced. (#78221)

* Ensure the async reader state resets the BOM offset in every AdvanceBuffer() call.

* Add BOM insertion to async serialization stress testing

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

2 years agoFix bug in String.Equals unrolling for certain single-char strings (#78190)
Egor Bogatov [Fri, 11 Nov 2022 16:25:34 +0000 (17:25 +0100)]
Fix bug in String.Equals unrolling for certain single-char strings (#78190)

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years ago[mono] MiniJIT OP_XEQUAL for floats (#77770)
Matous Kozak [Fri, 11 Nov 2022 16:14:10 +0000 (17:14 +0100)]
[mono] MiniJIT OP_XEQUAL for floats (#77770)

* xequal special instruction for floats

* reduce code

* Moving type pass to emit_xequal

* OP_EXTRACT_MASK

* remove space

* Update src/mono/mono/mini/mini-amd64.c

* Update src/mono/mono/mini/mini-amd64.c

Co-authored-by: Fan Yang <52458914+fanyang-mono@users.noreply.github.com>
2 years agoremove unnecessary code (#78171)
Thays Grazia [Fri, 11 Nov 2022 15:15:52 +0000 (12:15 -0300)]
remove unnecessary code (#78171)

2 years agoMake System.IO.Compression work in the repro project (#78208)
Michal Strehovský [Fri, 11 Nov 2022 13:18:55 +0000 (22:18 +0900)]
Make System.IO.Compression work in the repro project (#78208)

Need to pass additional lib.

2 years agoExclude dynamic libraries in AppleAppBuilder for iOS device (#78173)
Milos Kotlar [Fri, 11 Nov 2022 12:30:18 +0000 (13:30 +0100)]
Exclude dynamic libraries in AppleAppBuilder for iOS device (#78173)

* exclude dynamic libraries when forceAOT=true

* use preferDylibs insted of foreceAOT

2 years agoAllow DecompressionHandler to be trimmed when the application isn't using AutomaticDe...
Eric Erhardt [Fri, 11 Nov 2022 11:24:34 +0000 (05:24 -0600)]
Allow DecompressionHandler to be trimmed when the application isn't using AutomaticDecompression in HttpClient. (#78198)

This allow for the Brotli compression code to be trimmed in a NativeAOT app that uses HttpClient, which is about 1 MB of size savings on Linux.

2 years agoVectorize String.Equals for OrdinalIgnoreCase (#77947)
Egor Bogatov [Fri, 11 Nov 2022 11:02:06 +0000 (12:02 +0100)]
Vectorize String.Equals for OrdinalIgnoreCase (#77947)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoFix Vector<T> != operator (#78177)
Radek Doulik [Fri, 11 Nov 2022 08:39:50 +0000 (09:39 +0100)]
Fix Vector<T> != operator (#78177)

2 years ago[NativeAOT] Objective-C: SetMessageSendPendingException and SetMessageSendCallback...
Austin Wise [Fri, 11 Nov 2022 08:37:39 +0000 (00:37 -0800)]
[NativeAOT] Objective-C:  SetMessageSendPendingException and SetMessageSendCallback (#77956)

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoMake Type.IsEnum and Type.GetEnumUnderlyingType intrinsics (#71685)
Michał Petryka [Fri, 11 Nov 2022 04:50:14 +0000 (05:50 +0100)]
Make Type.IsEnum and Type.GetEnumUnderlyingType intrinsics (#71685)

* Make Type.GetTypeCode an intrinsic

Makes Type.GetTypeCode a JIT intrinsic for primitive types,
enums and strings.

Makes Type.IsEnum use intrinsics instead of IsSubclassOf

Makes Enum.GetUnderlyingType use Type.GetTypeCode

Moves the legacy FCall to InternalGetUnderlyingTypeImpl,
so that the non-intrinsic GetTypeCode can use it.

Introduces JIT tests checking the generated codegen.

* Change IsEnum to an intrinsic

* Fallback to the FCall for nint/nuint enums

* Fix compilation

* Add missing Intrinsic

* Add typeof support to IsKnownConstant

* Use gtIsTypeHandleToRuntimeTypeHelper

* Add __reftype tests

* Make more places use gtIsTypeof

* Update EnumTests.cs

* Add impTypeGetTypeCode to the header

* Update EnumGetUnderlyingTypeEnums.il

* Make the IsActualEnum helper an intrinsic

* Remove GetTypeCode intrinsics

* Create a new JIT-EE api, add GetEnumUnderlyingType back

* Optimize GetTypeCode with IsKnownConstant

* Change the code to make the inliner happy

* Handle all types in GetTypeCode

* Check for custom types

* Fix build, do suggested changes

Co-authored-by: Andy Ayers <andya@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoUpdating CreateScalar to be intrinsic for Vector64/128/256 (#77798)
Tanner Gooding [Fri, 11 Nov 2022 03:49:10 +0000 (19:49 -0800)]
Updating CreateScalar to be intrinsic for Vector64/128/256 (#77798)

* Updating CreateScalar to be intrinsic for Vector64/128/256

* Applying formatting patch

* Fixing CreateScalar VecCon nodes created on import and find use before insert

* Applying formatting patch

* Ensure we zero extend TYP_BYTE and TYP_SHORT

* Ensure TYP_UBYTE and TYP_USHORT are also explicitly zero extended

* Fix the cast and add a comment explaining "why"

* Applying formatting patch

2 years agoFix elliptic curve name case sensitivity on Windows
Kevin Jones [Fri, 11 Nov 2022 02:45:00 +0000 (21:45 -0500)]
Fix elliptic curve name case sensitivity on Windows

2 years agoFix regex fixer to maintain string literal syntax (#78172)
Stephen Toub [Fri, 11 Nov 2022 02:14:47 +0000 (21:14 -0500)]
Fix regex fixer to maintain string literal syntax (#78172)

* Fix regex fixer to maintain string literal syntax

* Simplify

* Still transform interpolated strings

2 years agoFix morph issue with fgOptimizeEqualityComparisonWithConst (#78187)
David Wrighton [Fri, 11 Nov 2022 00:50:03 +0000 (16:50 -0800)]
Fix morph issue with fgOptimizeEqualityComparisonWithConst (#78187)

* Fix morph issue with fgOptimizeEqualityComparisonWithConst
- On arm32 a shift of a long requires a helper call, but the optimization in fgOptimizeEqualityComparisonWithConst for converting a right shift into a left shift was not keeping the GTF_CALL flag on the GenTree node.

* Update src/coreclr/jit/morph.cpp

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years agoIntroduce `FIELD_ADDR` and use it for TLS statics and instance class fields (#77353)
SingleAccretion [Thu, 10 Nov 2022 23:11:41 +0000 (02:11 +0300)]
Introduce `FIELD_ADDR` and use it for TLS statics and instance class fields (#77353)

* Introduce GT_FIELD_ADDR

* Add FIELD_ADDR to fgAddrCouldBeNull

* Add gtNewFieldAddrNode; move gtNewFieldRef

* Implement Windows x86 TLS via FIELD_ADDR

Tested manually to work as well as it did before.

* Silence the IR checker

* Minor code cleanup

* Prepare morph for instance FIELD_ADDRs

* Fix ObjectAllocator

* Use FIELD_ADDR in ld[s]flda import

* Work around morphing issues

With NativeAOT, we can have FIELD_ADDR nodes that are
effectively NOPs (those for the method table pointer field).

This means not all operators that the expansion produces
will be simple (in fact, they can be more or less arbitrary).

This means we cannot simply call "fgMorphSmpOp" as we used to.
Unfortunately, we cannot just call "fgMorphTree" either, because
it propagates assertions on newly created (or, I suppose, bashed)
IND nodes. This creates lots of new cases where GTF_ORDER_SIDEEFF
is applied to these nodes, affecting CQ.

Work around this by calling "fgMorphTree" for non-simple operators
only.

2 years agoDon't consider `lvSpillAtSingleDef` in `WritesAnyLocation` (#78181)
Tanner Gooding [Thu, 10 Nov 2022 22:02:03 +0000 (14:02 -0800)]
Don't consider `lvSpillAtSingleDef` in `WritesAnyLocation` (#78181)

2 years ago[wasm] Add Vector128.AndNot intrinsics (#78133)
Radek Doulik [Thu, 10 Nov 2022 18:24:39 +0000 (19:24 +0100)]
[wasm] Add Vector128.AndNot intrinsics (#78133)

* [wasm] Add Vector128.AndNot intrinsics

C#

    var v = Vector128.Create(System.Random.Shared.Next(), System.Random.Shared.Next(), System.Random.Shared.Next(), System.Random.Shared.Next());
    var v2 = Vector128.Create(System.Random.Shared.Next(), System.Random.Shared.Next(), System.Random.Shared.Next(), System.Random.Shared.Next());
    v = Vector128.AndNot(v, v2);

is emitted as

    ...
    i32x4.splat    [SIMD]
    local.get $5
    i32x4.replace.lane 1    [SIMD]
    local.get $6
    i32x4.replace.lane 2    [SIMD]
    local.get $7
    i32x4.replace.lane 3    [SIMD]
    local.get $8
    i32x4.splat    [SIMD]
    local.get $9
    i32x4.replace.lane 1    [SIMD]
    local.get $10
    i32x4.replace.lane 2    [SIMD]
    local.get $2
    i32x4.replace.lane 3    [SIMD]
    v128.andnot    [SIMD]
    v128.store offset:8 align:3    [SIMD]
    ...

* Review feedback

2 years ago[NativeAOT] Enable software writewatch and card bundles on Windows. (#77934)
Vladimir Sadov [Thu, 10 Nov 2022 17:41:51 +0000 (09:41 -0800)]
[NativeAOT] Enable software writewatch and card bundles on Windows. (#77934)

* amd64

* arm64

* fix ARM64 build

* import conditionally

2 years agoSwitch `LightupAppActivation` tests to component tests targeting additional deps...
Elinor Fung [Thu, 10 Nov 2022 17:17:05 +0000 (09:17 -0800)]
Switch `LightupAppActivation` tests to component tests targeting additional deps (#78139)

The `LightupAppActivation` tests are testing handling of additional deps. The actual app and lib are not really interesting, so we can switch them to the dependency resolution tests that use a mock coreclr and don't actually run an app. On my Windows machine, this goes from ~20s to run the deleted tests to ~700ms to run the new tests.

2 years agoAdd REAMDE.md for ServiceProcess.ServiceController (#78124)
Viktor Hofer [Thu, 10 Nov 2022 17:12:32 +0000 (18:12 +0100)]
Add REAMDE.md for ServiceProcess.ServiceController (#78124)

* Add REAMDE.md for ServiceProcess.ServiceController

2 years agoReduce host memory usage: don't keep resolved deps around for app lifetime (#77987)
Elinor Fung [Thu, 10 Nov 2022 17:04:06 +0000 (09:04 -0800)]
Reduce host memory usage: don't keep resolved deps around for app lifetime (#77987)

`hostpolicy` keeps a global `hostpolicy_init_t` around which has a list of `fx_definition_t` which each contain an associated `deps_json_t`. The deps are resolved/parsed on initialization of hostpolicy, updating the globally-stored information with all the resolved assets and computing properties that will be passed to the runtime.

The only part of the deps resolution results we currently use after initialization / computing the properties is the rid fallback graph of the root framework (for component dependency resolution). Everything else we are just holding on to for the lifetime of the application.

This separates `deps_json_t` from `fx_definition_t` such that we:
- don't keep all the resolved deps around for the lifetime of the application
- store only the one rid fallback graph we need for future resolutions
- stop including/building deps parsing functionality in `hostfxr` (via `hostcommon`)

For a blank console app (so no other dependencies, just NETCoreApp) running on Windows, this reduces the amount we keep on the native heap by ~200kB. The more dependencies, the more we were keeping around.

2 years agoRemove ENABLE_VISIBILITY_HIDDEN from mono.proj (#78155)
Alexander Köplinger [Thu, 10 Nov 2022 17:02:22 +0000 (18:02 +0100)]
Remove ENABLE_VISIBILITY_HIDDEN from mono.proj (#78155)

It was never wired up in the CMake based build system and we set visibility hidden by default now.

2 years agoMust read `SequenceNumber` before reading the `Item` (#78142)
Vladimir Sadov [Thu, 10 Nov 2022 17:02:07 +0000 (09:02 -0800)]
Must read `SequenceNumber` before reading the `Item` (#78142)

2 years agoFix bug with BigInteger.TrailingZeroCount (#77727)
Drew Kersnar [Thu, 10 Nov 2022 16:52:53 +0000 (10:52 -0600)]
Fix bug with BigInteger.TrailingZeroCount (#77727)

* Fix bug with BigInteger.TrailingZeroCount

* Update src/libraries/System.Runtime.Numerics/tests/BigIntegerTests.GenericMath.cs

Co-authored-by: Tommi Kekäläinen <76913562+tkekalainen@users.noreply.github.com>
* Update negative code path

* Simplify logic for handling negative values

* Update src/libraries/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs

Co-authored-by: Tommi Kekäläinen <76913562+tkekalainen@users.noreply.github.com>
* Update comment

Co-authored-by: Tommi Kekäläinen <76913562+tkekalainen@users.noreply.github.com>
2 years agoFix a few recent perf regressions in Regex (#78003)
Stephen Toub [Thu, 10 Nov 2022 12:18:51 +0000 (07:18 -0500)]
Fix a few recent perf regressions in Regex (#78003)

* Split TryFindNextStartingPosition into LeftToRight and RightToLeft versions

A previous change increased the size of the method. Splitting it to reduce the size (and how many locals needed to be zerod) as well as to reduce some branching.

* Avoid generating match-all code for starting "any" sets

* Avoid using IndexOfAnyExcept('\n') for TryFindNextPossibleStartingPosition

It's common at the beginning of a pattern and it's rare to have long sequences of newlines that benefit from IndexOf.

Also tweak how we prioritize sets; if two sets have ranges, prefer the one whose range is less inclusive / has a lower chance of matching (based purely on count).

* Address PR feedback

2 years agoOptimize some SIMD comparisons with Max/Min trick (#78027)
Egor Bogatov [Thu, 10 Nov 2022 12:01:52 +0000 (13:01 +0100)]
Optimize some SIMD comparisons with Max/Min trick (#78027)

2 years agoFix non-determinism in Regex source generator (#78103)
Stephen Toub [Thu, 10 Nov 2022 10:42:19 +0000 (05:42 -0500)]
Fix non-determinism in Regex source generator (#78103)

* Fix non-determinism in Regex source generator

The source generator enumerates a Hashtable to write out its contents.  When the keys of the Hashtable are strings, string hash code randomization may result in the order of that enumeration being different in different processes, leading to non-deterministic ordering of values written out and thus non-deterministic source generator output.

* Address PR feedback

2 years agoFix expensive typo in JsonNode (#78130)
Stephen Toub [Thu, 10 Nov 2022 09:13:35 +0000 (04:13 -0500)]
Fix expensive typo in JsonNode (#78130)

2 years agoReturn NULL for mmap fail case on Unix (#78069)
ws77.cho [Thu, 10 Nov 2022 09:12:30 +0000 (18:12 +0900)]
Return NULL for mmap fail case on Unix (#78069)

* Return NULL for mmap fail case on Unix

If mmap failed, "MAP_FAILED" is returned not "NULL".
The windows implememtation of GetRWMapping returns "NULL" for fail case,
and the caller function is also checking "NULL".

So, change Unix implementation to return "NULL" for fail case.

* call memset when mmap succeeds

* check MAP_FAILED instead of NULL

* return false for failing mmap

* Call g_fatalErrorHandler if releasing failed

* Update src/coreclr/utilcode/executableallocator.cpp

Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
* Fix wrong condition check

Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
2 years agoDelete `AppDomainIterator` (#78078)
Elinor Fung [Thu, 10 Nov 2022 05:57:59 +0000 (21:57 -0800)]
Delete `AppDomainIterator` (#78078)