platform/upstream/dotnet/runtime.git
2 years ago[wasm] Build improvements, and fixes (#61581)
Ankit Jain [Sat, 4 Dec 2021 06:48:02 +0000 (06:48 +0000)]
[wasm] Build improvements, and fixes (#61581)

Includes:
- Better error logging, and handling
- Add @(NativeFileReference) to up-to-date check items for VS
- Add `WasmBuild.sln`
- Better fix up of symbol names for pinvokes, and callbacks, based on @lambdageek's suggestion in https://github.com/dotnet/runtime/pull/60814#discussion_r736903990

Fixes dotnet#60862

2 years agoJIT: three fixes for OSR (#62367)
Andy Ayers [Sat, 4 Dec 2021 03:41:55 +0000 (19:41 -0800)]
JIT: three fixes for OSR (#62367)

Found when trying to enable OSR by default and prospecting for arm64 support.

* Explicitly initalize the OSR step variable.
* Prevent `fgOptimizeUncondBranchToSimpleCond` from changing the scratch entry
  BB to have conditional flow.
* Retain runtime supplied patchpoint info when cleaning up after an altjit failure.

2 years agoUse Spans on Go() methods for Code Gen engines (#62324)
Jose Perez Rodriguez [Sat, 4 Dec 2021 02:45:02 +0000 (18:45 -0800)]
Use Spans on Go() methods for Code Gen engines (#62324)

* Use Spans on Emitter Go() methods

* Use Spans on Compiler Go() methods

* Rename localSpan to slice in order to avoid confusion with runtextSpan

2 years agoFix superpmi.exe handling of exclusion lists (#62349)
Bruce Forstall [Fri, 3 Dec 2021 23:44:37 +0000 (15:44 -0800)]
Fix superpmi.exe handling of exclusion lists (#62349)

superpmi.exe has the concept of an exclusion list file which is automatically read
and processed when reading a .mch file. (I'm not sure if anyone actually uses it.)
So, when opening a `t.mch` file, it looks for an adjacent `t.mch.exc` and then `t.exc`
file.

There was a bug where it would also look for a `t` file (the comments say it takes t.exc.mch
and looks for t.exc, but it didn't check for that). In my case when I was testing, I actually
had a `t` directory (not file), which it found, but then emitted an error trying to load.

So, two fixes:
1. For `t.mch`, don't look for `t`.
2. Check all cases for being a directory, and fail if any name is a directory.

2 years agoAlways create the zip folder to upload (#62368)
Kunal Pathak [Fri, 3 Dec 2021 23:32:18 +0000 (15:32 -0800)]
Always create the zip folder to upload (#62368)

2 years agoAdd RateLimiting APIs (#61788)
Brennan [Fri, 3 Dec 2021 23:06:44 +0000 (15:06 -0800)]
Add RateLimiting APIs (#61788)

2 years agoFix superpmi.py collect script (#62347)
Bruce Forstall [Fri, 3 Dec 2021 22:45:29 +0000 (14:45 -0800)]
Fix superpmi.py collect script (#62347)

Collect also does a replay, so needs all the replay arguments set to something.
Fixes this error: `'CoreclrArguments' object has no attribute 'compile'`

2 years agoDelete old code generation approach from RegexCompiler / source generator (#62318)
Stephen Toub [Fri, 3 Dec 2021 22:09:51 +0000 (17:09 -0500)]
Delete old code generation approach from RegexCompiler / source generator (#62318)

* Delete old code generation approach from RegexCompiler / source generator

In .NET Framework and up through .NET Core 3.1, the code generated for RegexOptions.Compiler was effectively an unrolled version of what RegexInterpreter would process.  The RegexNode tree would be turned into a series of opcodes via RegexWriter; the interpreter would then sit in a loop processing those opcodes, and the RegexCompiler iterates through the opcodes generating code for each equivalent to what the interpreter would do but with some decisions made at compile-time rather than at run-time.  This approach, however, leads to complicated code that's not pay-for-play (e.g. a big backtracking jump table that all compilations go through even if there's no backtracking), that doesn't factor in the shape of the tree (e.g. it's difficult to add optimizations based on interactions between nodes in the graph), and that doesn't read well when emitted as C# instead of IL as part of the source generator.  In .NET 5, we started adding an alternative implementation that processed the RegexNode tree directly, addressing all of those cited issues; however, it only worked for a subset of expressions, namely those with little-to-no backtracking (e.g. non-atomic loops and alternations weren't supported).  Since then, we've improved it to the point where everything other than RegexOptions.RightToLeft (which implicitly means lookbehinds as well) is supported, and we've agreed it's ok to drop compilation for those constructs; if they ever become an issue, we can add support for them via the new compilation scheme.

As such, this PR:
- Deletes all of the code associated with the older code generation scheme
- Updates the Regex ctor to fall back to selecting the interpreter if the expression can't be compiled
- Updates the source generator to fall back to just emitting a cached use of Regex if the expression can't be compiled (and issuing a diagnostic in that case)
- Adds several tests that now pass with the new scheme that didn't with the old (and that still don't with the interpreter)

* Make the addition of more declarations a bit more robust

* Reduce backtracking code gen when nodes are atomic

Also added some comments and renamed a few methods for consistency between RegexCompiler and RegexGenerator.Emitter

* Fix tests on mono interpreter

2 years agoConsistently use CreateProxyUri in WebProxy ctors (#62338)
Miha Zupan [Fri, 3 Dec 2021 21:54:28 +0000 (13:54 -0800)]
Consistently use CreateProxyUri in WebProxy ctors (#62338)

2 years agoAdd parser tests from nim-regex (#62093)
Dan Moseley [Fri, 3 Dec 2021 19:52:18 +0000 (12:52 -0700)]
Add parser tests from nim-regex (#62093)

* new parser tests

* baseline

* Nim tests

* typos

* positive cases

* new parser tests

* change to \u

2 years agoUpdate overlapped field test to conflict on 32-bit arches (#62308)
Aleksey Kliger (λgeek) [Fri, 3 Dec 2021 19:43:21 +0000 (14:43 -0500)]
Update overlapped field test to conflict on 32-bit arches (#62308)

* Update overlapped field test to conflict on 32-bit arches

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

* [class-init] Setup fields of nested structs in layout check

   On AOT the field's class may not have been fully inited yet.

   Related to https://github.com/dotnet/runtime/issues/62311

2 years ago[mono][wasm] Fix the passing/returning of small vtypes. (#62299)
Zoltan Varga [Fri, 3 Dec 2021 19:38:03 +0000 (14:38 -0500)]
[mono][wasm] Fix the passing/returning of small vtypes. (#62299)

According to the ABI, they need to be returned by value.

2 years ago[mono][wasm] Fix a windows cross compiler issue. (#62339)
Zoltan Varga [Fri, 3 Dec 2021 19:37:47 +0000 (14:37 -0500)]
[mono][wasm] Fix a windows cross compiler issue. (#62339)

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

2 years ago[mono] Disable new test running on AOT. (#62335)
Thays Grazia [Fri, 3 Dec 2021 19:14:29 +0000 (16:14 -0300)]
[mono] Disable new test running on AOT. (#62335)

* Disable test running on AOT.

2 years agoFixes #62167. WriteAsync was bugged when writing multiple segments if called after...
Kuinox [Fri, 3 Dec 2021 19:08:28 +0000 (20:08 +0100)]
Fixes #62167. WriteAsync was bugged when writing multiple segments if called after an .Advance(int) (#62306)

2 years agoSupport unloadability in `DispatchProxy`. (#62095)
Theodore Tsirpanis [Fri, 3 Dec 2021 17:52:35 +0000 (19:52 +0200)]
Support unloadability in `DispatchProxy`. (#62095)

* Use separate ProxyAssemblies per ALC in DispatchProxyGenerator.

2 years ago[main] Update dependencies from dotnet/arcade dotnet/xharness dotnet/runtime-assets...
dotnet-maestro[bot] [Fri, 3 Dec 2021 16:56:45 +0000 (11:56 -0500)]
[main] Update dependencies from dotnet/arcade dotnet/xharness dotnet/runtime-assets (#62331)

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

Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.Build.Tasks.Workloads , Microsoft.DotNet.Build.Tasks.Templating , Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.Installers , Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Archives , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.ApiCompat , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.GenFacades , Microsoft.DotNet.GenAPI , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.PackageTesting , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.SharedFramework.Sdk
 From Version 7.0.0-beta.21576.4 -> To Version 7.0.0-beta.21602.3

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

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 1.0.0-prerelease.21602.1 -> To Version 1.0.0-prerelease.21602.2

* Update dependencies from https://github.com/dotnet/runtime-assets build 20211202.1

Microsoft.DotNet.CilStrip.Sources , System.ComponentModel.TypeConverter.TestData , System.Drawing.Common.TestData , System.IO.Compression.TestData , System.IO.Packaging.TestData , System.Net.TestData , System.Private.Runtime.UnicodeData , System.Runtime.Numerics.TestData , System.Runtime.TimeZoneData , System.Security.Cryptography.X509Certificates.TestData , System.Windows.Extensions.TestData
 From Version 7.0.0-beta.21579.1 -> To Version 7.0.0-beta.21602.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoFix soundplayer (#62323)
Dan Moseley [Fri, 3 Dec 2021 14:42:09 +0000 (07:42 -0700)]
Fix soundplayer (#62323)

2 years agoDisable TestIgnoreCaseRelationBorderCasesInNonBacktracking test (#62319)
Stephen Toub [Fri, 3 Dec 2021 11:28:35 +0000 (06:28 -0500)]
Disable TestIgnoreCaseRelationBorderCasesInNonBacktracking test (#62319)

2 years agoSimplify code emitted for single char repeater (#62322)
Stephen Toub [Fri, 3 Dec 2021 11:26:51 +0000 (06:26 -0500)]
Simplify code emitted for single char repeater (#62322)

Rather than outputting an if block per unrolled iteration, just output a clause for each iteration as part of a single if block.  We already do this for concatenations, but we don't yet for standalone repeaters.

2 years agoAvoid closure for GetOrAdd (#62317)
Gérald Barré [Fri, 3 Dec 2021 07:27:38 +0000 (02:27 -0500)]
Avoid closure for GetOrAdd (#62317)

2 years agoMove the remainder of X509Certificates and TestUtilities use GeneratedDllImport ...
Jeremy Koritzinsky [Fri, 3 Dec 2021 05:08:27 +0000 (21:08 -0800)]
Move the remainder of X509Certificates and TestUtilities use GeneratedDllImport (#62309)

2 years ago[wasm] Work around `System.Diagnostics.Tests.StopwatchTests.GetTimestamp` failure...
Ankit Jain [Fri, 3 Dec 2021 04:31:38 +0000 (04:31 +0000)]
[wasm] Work around `System.Diagnostics.Tests.StopwatchTests.GetTimestamp` failure (#62290)

2 years agoEnsure that we don't try to get the simdBaseJitType for scalar intrinsics (#61982)
Tanner Gooding [Fri, 3 Dec 2021 03:02:06 +0000 (19:02 -0800)]
Ensure that we don't try to get the simdBaseJitType for scalar intrinsics (#61982)

* Ensure that we don't try to get the simdBaseJitType for scalar intrinsics

* Update a condition to also check for isScalarIsa

2 years agoReduce repeated variable add operations to a single multiply. (#61663)
anthonycanino [Fri, 3 Dec 2021 00:49:43 +0000 (19:49 -0500)]
Reduce repeated variable add operations to a single multiply. (#61663)

* Reduce repeated variable add operations to a single multiply.

`gtReduceStrength` will reduce `i + i + i + i` to `i * 4`, which
will be optimized to `i << 2`. The reduction is not limited to
power of twos, as `i + i + i + i + i` will reduce to `i * 5`, which
will be optimized to `lea reg1, [reg2+4*reg2]` etc on xarch.

* Produce a `GT_MUL` compatible with non-64 bit arch.

A `GT_MUL` with `TYP_LONG` must go through the GT_MUL preorder
processing on non-64 bit arch. Change forces that to happen by
creating a new GenTree node if GT_ADD can be reduced to GT_MUL
and then running fgMorphTree on then new node.

* Run jit-format.

* Suggested style changes.

* Abort optimization if result will create 64-bit MUL on 32-bit arch.

Also cleaned up the code per suggestions regarding structure (move
to morph.cpp) and fgGlobalOpt check.

* Run jit-format.

* Fix small typo bug.

* Small code cleanups per review.

* Moving definition of transformed tree nodes for clarity.

2 years agoUse GeneratedDllImport throughout System.Private.CoreLib. (#62295)
Jeremy Koritzinsky [Fri, 3 Dec 2021 00:15:47 +0000 (16:15 -0800)]
Use GeneratedDllImport throughout System.Private.CoreLib. (#62295)

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
2 years agoFinish new code gen approach for RegexCompiler / source generator (#62268)
Stephen Toub [Fri, 3 Dec 2021 00:13:34 +0000 (19:13 -0500)]
Finish new code gen approach for RegexCompiler / source generator (#62268)

* Add an ifdef to compile one source generated test at a time

* Change the ATT test theory to factor out the engine

* Add a few tests and delete some unnecessary ones

* Finish the new code gen strategy (all but RightToLeft)

* Fix mono failures (hopefully)

2 years agoJIT: handle interaction of OSR, PGO, and tail calls (#62263)
Andy Ayers [Thu, 2 Dec 2021 23:00:40 +0000 (15:00 -0800)]
JIT: handle interaction of OSR, PGO, and tail calls (#62263)

When both OSR and PGO are enabled, the jit will add PGO probes to OSR methods.
And if the OSR method also has a tail call, the jit must take care to not add
block probes to any return block reachable from possible tail call blocks.

Instead, instrumentation should create copies of the return block probe in each
return block predecessor (possibly splitting critical edges to make this viable).

Because all this happens early on, there are no pred lists. The analysis leverages
cheap preds instead, which means it needs to handle cases where a given pred has
multiple pred list entries. And it must also be aware that the OSR method's actual
flowgraph is a subgraph of the full initial graph.

This came up while scouting what it would take to enable OSR by default.
See #61934.

2 years agoUpdate dependencies from https://github.com/dotnet/linker build 20211201.5 (#62277)
dotnet-maestro[bot] [Thu, 2 Dec 2021 22:47:25 +0000 (16:47 -0600)]
Update dependencies from https://github.com/dotnet/linker build 20211201.5 (#62277)

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21601.1 -> To Version 7.0.100-1.21601.5

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agomake S.S.C.X509Certificates compliant with interop guidelines - part 4 of 4
Badre BSAILA [Thu, 2 Dec 2021 22:24:14 +0000 (23:24 +0100)]
make S.S.C.X509Certificates compliant with interop guidelines - part 4 of 4

2 years agoLock MemeoryMappedFile CreateViewAccesssor call (#62288)
Buyaa Namnan [Thu, 2 Dec 2021 22:18:41 +0000 (14:18 -0800)]
Lock MemeoryMappedFile CreateViewAccesssor call (#62288)

2 years ago[arm64] JIT: Add with sign/zero extend (#61549)
Egor Bogatov [Thu, 2 Dec 2021 20:37:26 +0000 (23:37 +0300)]
[arm64] JIT: Add with sign/zero extend (#61549)

2 years agoreturn 100 (#62284)
Kunal Pathak [Thu, 2 Dec 2021 19:08:06 +0000 (11:08 -0800)]
return 100 (#62284)

2 years ago[main] Update dependencies from dotnet/emsdk dotnet/xharness (#62279)
dotnet-maestro[bot] [Thu, 2 Dec 2021 16:53:12 +0000 (17:53 +0100)]
[main] Update dependencies from dotnet/emsdk dotnet/xharness (#62279)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years ago[mono] Fix StackTrace from a dim and Vtable offsets for static interface method ...
Thays Grazia [Thu, 2 Dec 2021 16:22:41 +0000 (13:22 -0300)]
[mono] Fix StackTrace from a dim and Vtable offsets for static interface method (#60770)

* Fix mono_get_generic_context_from_stack_frame when it's from a dim.

* Using @vargaz fix

* Fixing test case source name

* Fix behavior when the interface had static interface methods.

* Fixing test cases.

2 years agoUse ReadOnlySpan<char> on RegexCompiled engine. (#62245)
Jose Perez Rodriguez [Thu, 2 Dec 2021 14:55:18 +0000 (06:55 -0800)]
Use ReadOnlySpan<char> on RegexCompiled engine. (#62245)

* Use ReadOnlySpan<char> on RegexCompiled engine.

* Fixing unit tests by correcting some bad IL.

2 years ago[Mono] Fix support for nested structs with explicit layout (#61467)
Simon Rozsival [Thu, 2 Dec 2021 13:08:32 +0000 (14:08 +0100)]
[Mono] Fix support for nested structs with explicit layout (#61467)

* Add test case for nested struct with explicit layout

* Add license

* Modify test

* Temporarily enable the test in the CI pipeline

* Allow running Mac Catalyst builds in App Sandbox

* Allow enabling app sandbox for the other Mac Catalyst sample

* Revert "Allow enabling app sandbox for the other Mac Catalyst sample"

This reverts commit 8c3c9f92daa47d1de844dbe897155d119415fb74.

* Revert "Allow running Mac Catalyst builds in App Sandbox"

This reverts commit 1e404165d1859bc9e25dbcdb0b4dc74a839dc708.

* Add more test cases

* WIP: First implementation of the recursive check

* Improve code

* Fix test case

* Add more test cases

* Unify test cases

* Bugfixes

* Remove test which behaves differently depending on the target platform

* Remove sequential layout test which behaves differently on Linux and on Windows

* Reorganize test cases

* Remove call to mono_class_setup_fields

* Fix embedding detection

* Fix layout validation for generic structs

* Remove unintentional change

* Revert temporary change to the runtime.yml pipeline

* Code clean-up

* Revert unrelated change

* Use getters instead of directly accessing MonoClass fields

2 years agoAdd test that ensures that it's possible to zip a named pipe on Unix (#62240)
Adam Sitnik [Thu, 2 Dec 2021 13:06:11 +0000 (14:06 +0100)]
Add test that ensures that it's possible to zip a named pipe on Unix (#62240)

2 years ago[mono] Fix warnings with recent clang/gcc (#62244)
Alexander Köplinger [Thu, 2 Dec 2021 12:32:00 +0000 (13:32 +0100)]
[mono] Fix warnings with recent clang/gcc (#62244)

- Unused/unset variables in hot_reload.c
- Misleading indentation in aot-compiler.c
- Cast to smaller integer type in method-to-ir.c

Co-authored-by: Aleksey Kliger (λgeek) <alklig@microsoft.com>
2 years ago[Wasm] JS modularization (#61313)
Pavel Savara [Thu, 2 Dec 2021 09:38:00 +0000 (10:38 +0100)]
[Wasm] JS modularization (#61313)

Modularized dotnet.js
* By using emcc options MODULARIZE and EXPORT_ES6, depending on WasmEnableES6 to produce ES6 or CommonJS modules respectively.
* WasmEnableES6 enables WasmBuildNative because dotnet.js need to be re-linked
* CommonJS version is able to be loaded into global namespace and behaves as before this change.
* Added new es6/*.js and es6/*.js files which are included in dotnet.js creation.
* Key aspects are documented in src/mono/wasm/runtime/modularize-dotnet.md of this PR.
* Improved dotnet.d.ts it is now generated into version control too, so that we could observe how it evolves.
* Removed legacy --testing argument and simplified is_testing logic in the the samples.
* Added browser-es6 sample app, which uses WasmEnableES6=true to compile dotnet.js as ES6 module.
* Added browser-legacy sample, which uses dotnet.js CommonJS module and loads it into global namespace.
* Added package.json into the nupkg

Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Katelyn Gadd <kg@luminance.org>
Co-authored-by: Marek Fišera <mara@neptuo.com>
2 years agoUse GeneratedDllImport in System.DirectoryServices (#61975)
Elinor Fung [Thu, 2 Dec 2021 05:52:02 +0000 (21:52 -0800)]
Use GeneratedDllImport in System.DirectoryServices (#61975)

2 years agoFix some typo in test (#62257)
Tarek Mahmoud Sayed [Thu, 2 Dec 2021 04:07:36 +0000 (20:07 -0800)]
Fix some typo in test (#62257)

2 years agoRevert "CI matrix change: add Windows.Server.Core.20H2 - Second attempt (#60054)...
Andy Gocke [Thu, 2 Dec 2021 03:35:40 +0000 (19:35 -0800)]
Revert "CI matrix change: add Windows.Server.Core.20H2 - Second attempt (#60054)" (#62253)

This reverts commit efc8adbb650de1164ec886355f1ba3599e711e65.

2 years agoJIT: don't forward sub a volatile read tree via copy (#62224)
Andy Ayers [Thu, 2 Dec 2021 02:34:46 +0000 (18:34 -0800)]
JIT: don't forward sub a volatile read tree via copy (#62224)

The copy may not get the same value as the original.
Detect this by looking for `GTF_ORDER_SIDEEFF`.

Closes #62048.

2 years agoFix mono debugger thread block when wait for attach (#62175)
D.S. Qiu [Thu, 2 Dec 2021 00:54:58 +0000 (08:54 +0800)]
Fix mono debugger thread block when wait for attach (#62175)

* wait_for_attach change to gc safe mode

* change MONO_REQ_GC_SAFE_MODE to MONO_REQ_GC_UNSAFE_MODE

2 years agoUse ReadOnlySpan<char> instead of strings on SourceGenerator engine (#62222)
Jose Perez Rodriguez [Thu, 2 Dec 2021 00:38:28 +0000 (16:38 -0800)]
Use ReadOnlySpan<char> instead of strings on SourceGenerator engine (#62222)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoCache LastAccessed during MemoryCache compaction (#61187)
Eric Erhardt [Thu, 2 Dec 2021 00:22:22 +0000 (18:22 -0600)]
Cache LastAccessed during MemoryCache compaction (#61187)

* Cache LastAccessed during MemoryCache compaction

During cache compaction, we are sorting entries based on their LastAccessed time. However, since the cache entries can still be used concurrently on other threads, the LastAccessed time may be updated in the middle of sorting the entries. This leads to exceptions in a background thread, crashing the process.

The fix is to cache the LastAccessed time outside of the entry when we are adding it to the list. This will ensure the time is stable during the compaction process.

Fix #61032

2 years agoAdd NetCoreAppCurrent configurations to Microsoft.Extensions libraries (#61867)
Eric Erhardt [Wed, 1 Dec 2021 23:33:21 +0000 (17:33 -0600)]
Add NetCoreAppCurrent configurations to Microsoft.Extensions libraries (#61867)

* Add NetCoreAppCurrent configurations to Microsoft.Extensions libraries

This makes all Extensions projects consistent in which TFMs they target. This way we don't need to add new TFMs during development of a new feature.

Fix #54012

2 years agothrow exception when creating an entry name that already exists in ZipArchive (#60973)
Badre BSAILA [Wed, 1 Dec 2021 20:16:59 +0000 (21:16 +0100)]
throw exception when creating an entry name that already exists in ZipArchive (#60973)

* throw exception when creating an entry name that already exists in ZipArchive

* secure code at the top of CreateEntry call

* specify entry name in exception message

* fix exception message, make AddEntry retrocompatible, and fix test issue with globalization

* restore the EmptyEntryTest code as before

2 years ago[SuperPMI] Added a new optional -compile argument (#62217)
SeanWoo [Wed, 1 Dec 2021 20:03:46 +0000 (00:03 +0400)]
[SuperPMI] Added a new optional -compile argument (#62217)

* Added a new optional -compile argument that specifies which method contexts need to be compiled

* Update src/coreclr/scripts/superpmi.py

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
* Added another form of -compile argument like -c

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
2 years ago[mono][llvm] Mark the gc poll function as used so llvm doesn't optimize it away causi...
Zoltan Varga [Wed, 1 Dec 2021 19:49:41 +0000 (14:49 -0500)]
[mono][llvm] Mark the gc poll function as used so llvm doesn't optimize it away causing an assert inside 'opt'. (#62198)

2 years ago[main] Update dependencies from dotnet/linker (#61669)
dotnet-maestro[bot] [Wed, 1 Dec 2021 19:15:39 +0000 (20:15 +0100)]
[main] Update dependencies from dotnet/linker (#61669)

* Update dependencies from https://github.com/dotnet/linker build 20211115.4

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21565.4

* Update dependencies from https://github.com/dotnet/linker build 20211116.4

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21566.4

* Update dependencies from https://github.com/dotnet/linker build 20211117.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21567.1

* Update dependencies from https://github.com/dotnet/linker build 20211118.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21568.1

* Update dependencies from https://github.com/dotnet/linker build 20211119.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21569.1

* Update dependencies from https://github.com/dotnet/linker build 20211122.2

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21572.2

* Update dependencies from https://github.com/dotnet/linker build 20211130.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21580.1

* Update dependencies from https://github.com/dotnet/linker build 20211201.1

Microsoft.NET.ILLink.Tasks
 From Version 7.0.100-1.21562.1 -> To Version 7.0.100-1.21601.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2 years agoFeature/get debug view value processing (#60391)
Ondřej Škrabánek [Wed, 1 Dec 2021 19:08:56 +0000 (19:08 +0000)]
Feature/get debug view value processing (#60391)

* Added parameter for processing the value of the configuration e.g. for obfuscation

* Rename

* Extension methods separated

* After review suggestion changes

* Documentation update

* Build fixes

* Documentation for ConfigurationDebugViewContext added

* Nullable string error fix

* Changed to nullable string

* PR fixes

* Definition fix

* Missing definition

* Added getters to the definition

* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs

Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
* Tests added

* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs

Docs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs

Docs updateDocs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs

Docs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs

Docs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationRootExtensions.cs

Docs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Update src/libraries/Microsoft.Extensions.Configuration.Abstractions/src/ConfigurationDebugViewContext.cs

Docs update

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Santiago Fernandez Madero <safern@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
2 years agoCouple of debug info test fixes (#62199)
Jakob Botsch Nielsen [Wed, 1 Dec 2021 18:24:36 +0000 (19:24 +0100)]
Couple of debug info test fixes (#62199)

It looks like in CI we are seeing a null method ID in some cases when
this test is run under R2R and GC stress. Add a check for this, and also
mark the test as stress incompatible like other ETW tests, since it runs
very slowly under stress modes.

Fix #62118

2 years agoneedLabel assert (#62025)
Kunal Pathak [Wed, 1 Dec 2021 16:00:36 +0000 (08:00 -0800)]
needLabel assert (#62025)

2 years agoFix use of StringBuilder.AppendFormat in ILCompiler (#62147)
Stephen Toub [Wed, 1 Dec 2021 15:34:49 +0000 (10:34 -0500)]
Fix use of StringBuilder.AppendFormat in ILCompiler (#62147)

2 years ago[main] Update dependencies from 5 repositories (#62187)
dotnet-maestro[bot] [Wed, 1 Dec 2021 14:55:37 +0000 (15:55 +0100)]
[main] Update dependencies from 5 repositories (#62187)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoOptimize FMA codegen base on the overwritten (#58196)
weilinwa [Wed, 1 Dec 2021 14:47:13 +0000 (06:47 -0800)]
Optimize FMA codegen base on the overwritten (#58196)

* Optimize FMA codegen base on the overwritten

* Improve function/var names

* Add assertions

* Get use of FMA with TryGetUse

* Decide FMA form with two conditions, OverwrittenOpNum and isContained

* Fix op reg error in codegen

* Decide form using lastUse and isContained in no overwritten case

* Clean up code

* Separate default case overwrittenOpNum==0

* Apply format patch

* Change variable and function names

* Update regOptional for op1 and resolve some other comments

* Optimize FMA codegen base on the overwritten

* Improve function/var names

* Add assertions

* Get use of FMA with TryGetUse

* Decide FMA form with two conditions, OverwrittenOpNum and isContained

* Fix op reg error in codegen

* Decide form using lastUse and isContained in no overwritten case

* Clean up code

* Separate default case overwrittenOpNum==0

* Apply format patch

* Change variable and function names

* Update regOptional for op1 and resolve some other comments

* Change var names

* Fix jit format

* Fix build node error for op1 is regOptional

* Use targetReg instead of GetResultOpNumForFMA in codegen

* Update variable names

* Refactor lsra to solve lastUse status changed caused assertion failure

* Add check to prioritize contained op in lsra

* Update for jit format

* Simplify code

* Resolve comments

* Comment out assert because of lastUse change

* Fix some copiesUpperBits related errors

* Update src/coreclr/jit/lsraxarch.cpp

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
* Add link to the new issue

Co-authored-by: Kunal Pathak <Kunal.Pathak@microsoft.com>
2 years agofix issue where HTTP2 connection could be scavenged but not disposed (#62225)
Geoff Kizer [Wed, 1 Dec 2021 14:33:24 +0000 (06:33 -0800)]
fix issue where HTTP2 connection could be scavenged but not disposed (#62225)

Co-authored-by: Geoffrey Kizer <geoffrek@windows.microsoft.com>
2 years agoJIT/EE interface cleanups (#62214)
Jan Kotas [Wed, 1 Dec 2021 13:42:32 +0000 (05:42 -0800)]
JIT/EE interface cleanups (#62214)

- Convert RuntimeHelpers.InitializeArray to new style intrinsic
- Delete unused isStructRequiringStackAllocRetBuf JIT/EE method and related optimization
- Delete unused CORINFO_HELP_GETSTATICFIELDADDR_CONTEXT jit helper

2 years agoType memory maps with placeholders (#61933)
SingleAccretion [Wed, 1 Dec 2021 12:04:19 +0000 (15:04 +0300)]
Type memory maps with placeholders (#61933)

Use TYP_UNDEF (as TYP_MEM) for "first field"-like maps and
TYP_UNKNOWN (as TYP_HEAP) for the heaps themselves.

This will enable the type validation logic to be more precise.
For now, just assert that the heap is always updated with the
properly typed VNs.

2 years agoFix GT_ADD trees with mismatched operands (#62177)
Michal Strehovský [Wed, 1 Dec 2021 11:04:11 +0000 (20:04 +0900)]
Fix GT_ADD trees with mismatched operands (#62177)

Fixes issue observed in https://github.com/dotnet/runtimelab/issues/1128#issuecomment-979370161 - the trees generate additions of `TYP_I_IMPL` with `TYP_INT` and that confuses things down the line.

2 years agoFix some missing debug info (#62018)
Jakob Botsch Nielsen [Wed, 1 Dec 2021 10:25:47 +0000 (11:25 +0100)]
Fix some missing debug info (#62018)

* Propagate debug info in loop cloning

* Do not consume debug info on the standalone call statement created for
  inline candidates. This would lead to the loss of debugging
  information for failed inline candidates, since those statements are
  dropped and expanded in the upcoming GT_RET_EXPR node instead. In some
  cases it would also lead to the loss of debugging information for
  successful inlines.
  In the new logic we allow the same debugging information to be
  attached to the upcoming statement using the GT_RET_EXPR.

This change adds around 40 KB (~0.5%) to SPC.

2 years agoConsole.Unix: fix OpenStandardInput Stream sometimes throwing for Reads. (#62153)
Tom Deseyn [Wed, 1 Dec 2021 08:35:36 +0000 (09:35 +0100)]
Console.Unix: fix OpenStandardInput Stream sometimes throwing for Reads. (#62153)

* Console.Unix: fix OpenStandardInput Stream sometimes throwing for Reads.

When connected to a terminal reads happen line-by-line.

StdInReader caches the line in a StringBuilder.

Instead of returning when the destination buffer is full, an attempt
was made to decode the next chunk from the StringBuilder (if there is
one). This causes the encoder to throw for encoding into an empty buffer.

2 years agodon't run the System.IO.FileSystem.DriveInfo tests in parallel (#62134)
Adam Sitnik [Wed, 1 Dec 2021 08:28:20 +0000 (09:28 +0100)]
don't run the System.IO.FileSystem.DriveInfo tests in parallel (#62134)

* don't run the System.IO.FileSystem.DriveInfo in parallel, fixes #62119

* unify disabling test parallelization per assembly

2 years agore-enable and fix the SetOutReadToEnd test (#62200)
Adam Sitnik [Wed, 1 Dec 2021 08:27:17 +0000 (09:27 +0100)]
re-enable and fix the SetOutReadToEnd test (#62200)

2 years agoStart building a universal System.Linq.Expressions library (#61952)
Michal Strehovský [Wed, 1 Dec 2021 05:00:56 +0000 (14:00 +0900)]
Start building a universal System.Linq.Expressions library (#61952)

System.Linq.Expressions currently offers multiple build time definitions to build different flavors of the library:

* `FEATURE_COMPILE` (defined everywhere except iOS/tvOS/Catalyst, and NativeAOT) - enables Reflection.Emit-based expression tree compiler.
* `FEATURE_INTERPRET` (always defined and not actually possible to build without) - enables the expression interpreter
* `FEATURE_DLG_INVOKE` (defined everywhere except NativeAOT, but we likely need to be able to run without it on iOS too because there's uninvestigated bugs around it ActiveIssue'd in #54970) - in the interpreter, use a delegate to invoke `CallInstructions` instead of `MethodInfo.Invoke`. The delegate might have to be Reflection.Emitted if it's not supportable with `Func`/`Action` (that's the uninvestigated iOS/tvOS/Catalyst bug).

For #61231, we need to be able to build a single System.Linq.Expression library that can switch between these build-time configurations _at publish time_ since we don't want to build a separate S.L.Expressions library for NativeAOT. There are advantages in having this setup for non-NativeAOT scenarios too. This pull request accomplishes that by mechanically changing the `#define`s into feature switches.

The feature switch is placed in the last proposed location for https://github.com/dotnet/runtime/issues/17973. I expect we'll want such API to be public at some point; now that Xamarin and NativeAOT use this formerly .NET Native-only thing the API request became relevant again.

This pull request is focused on the mechanical replacement of `#defines` with feature switches and it's already a lot bigger than I'm comfortable with.

There's some obvious "`!FEATURE_COMPILE` means this is .NET Native with everything what that meant" that I did not touch because this is meant to be a mechanical change. Some cleanup will be needed at some point. Right now this just mostly means we're running fewer tests than we could.

Validation:
* Verified that we're still running the same number of tests with CoreCLR as we previously were and they're all passing.
* Verified we're getting mostly the same size of the S.L.Expressions library on iOS (433 kB grew to 436 kB, the diffs are expected).
* Verified things work on the NativeAOT side as well.

2 years agoHave RegexInterpreter work over ReadOnlySpan<char> instead of strings. (#62165)
Jose Perez Rodriguez [Wed, 1 Dec 2021 04:55:59 +0000 (20:55 -0800)]
Have RegexInterpreter work over ReadOnlySpan<char> instead of strings. (#62165)

2 years agoTrack a missing place to reset alignment flag from BasicBlock (#62163)
Kunal Pathak [Wed, 1 Dec 2021 01:25:45 +0000 (17:25 -0800)]
Track a missing place to reset alignment flag from BasicBlock (#62163)

* Add unmark loopAlign in a missing place

* Add test case

* add trailing \n

2 years agoImprove SuperPMI temp filename creation (#62169)
Bruce Forstall [Wed, 1 Dec 2021 00:18:24 +0000 (16:18 -0800)]
Improve SuperPMI temp filename creation (#62169)

* Improve SuperPMI temp filename creation

1. Disallow all non-ASCII characters from the MC filename.
2. Disallow `(` and `)` in filenames.
3. To improve uniqueness, always append an 8-character random number
to the filename.

* Fix Linux build

2 years agoFix a few syntax issues in shell scripts (#62102)
Adeel Mujahid [Tue, 30 Nov 2021 23:32:39 +0000 (01:32 +0200)]
Fix a few syntax issues in shell scripts (#62102)

* Fix a few syntax issues in shell scripts

* Cleanup trailing whitespace in changed files
```sh
# git remote add dotnet https://github.com/dotnet/runtime && git pull --rebase dotnet main

if uname 2>/devnull | grep -q Darwin; then
    space=" "
fi

git show --name-only --pretty="" HEAD...dotnet/main |\
    xargs -I{} sh -c "test -f {} && sed -i$space'' 's/[[:space:]]*$//' {}"
```

* Address CR feedback

2 years agoUse the right format of bkpt/brk for align that falls after jump (#62106)
Kunal Pathak [Tue, 30 Nov 2021 22:28:19 +0000 (14:28 -0800)]
Use the right format of bkpt/brk for align that falls after jump (#62106)

* Always use int3/bkpt

* Use right formatting for brk instruction

* Rename to brk_unix and brk_windows

* jit format

2 years agoRemove workarounds for referencing the DllImport source generator now that we use...
Jeremy Koritzinsky [Tue, 30 Nov 2021 21:48:15 +0000 (13:48 -0800)]
Remove workarounds for referencing the DllImport source generator now that we use the RTM sdk. (#62156)

Co-authored-by: Andy Gocke <andy@commentout.net>
2 years agoUpdate creating codespace instructions (#62213)
Eric Erhardt [Tue, 30 Nov 2021 21:13:21 +0000 (15:13 -0600)]
Update creating codespace instructions (#62213)

2 years agoUpdate DI external tests for Stashbox (#61928)
Peter Csajtai [Tue, 30 Nov 2021 20:58:40 +0000 (21:58 +0100)]
Update DI external tests for Stashbox (#61928)

2 years ago[JIT] [Issue: 61620] Optimizing ARM64 for *x = dblCns; (#61847)
SeanWoo [Tue, 30 Nov 2021 20:23:39 +0000 (00:23 +0400)]
[JIT] [Issue: 61620] Optimizing ARM64 for *x = dblCns; (#61847)

* [Issue: 61620] Optimizing ARM64 for *x = 0;

* Update src/coreclr/jit/lower.cpp

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
* Fixed bug with * x = dConst if dConst is not 0

* remove extra printf

* Replacing IsFPZero with IsCnsNonZeroFltOrDbl for STOREIND Minor edits with conditional compilation in lower.cpp

* fixed ARM codegen for STOREIND

* Update src/coreclr/jit/lower.cpp

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
* Update src/coreclr/jit/lower.cpp

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
* fix formatting

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years agoValidate end when reading QPACK headers (#62164)
github-actions[bot] [Tue, 30 Nov 2021 20:04:02 +0000 (09:04 +1300)]
Validate end when reading QPACK headers (#62164)

Co-authored-by: JamesNK <JamesNK@users.noreply.github.com>
2 years agoProtecting send message to debugger if it's disables (#61927)
Thays Grazia [Tue, 30 Nov 2021 20:02:27 +0000 (17:02 -0300)]
Protecting send message to debugger if it's disables (#61927)

2 years agoRuntimeHelpers.CreateSpan<T> (#61079)
David Wrighton [Tue, 30 Nov 2021 18:44:38 +0000 (10:44 -0800)]
RuntimeHelpers.CreateSpan<T> (#61079)

Implement `RuntimeHelpers.CreateSpan<T>` #60948

Implementation provides for
- Both non-intrinsic and intrinsic implementations in CoreCLR
- Non-intrinsic implementation in Mono
  - Mono implementation also implements untested big endian support

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoBuild HttpStress and SslStress with live-built runtime using current TFM (#61689)
Anton Firszov [Tue, 30 Nov 2021 17:16:30 +0000 (18:16 +0100)]
Build HttpStress and SslStress with live-built runtime using current TFM (#61689)

This PR changes both local (non-containerized) and containerized stress builds to build against the live-built runtime with the help of targetingpacks.targets.

2 years agoFix parsing of ping error replies on raw sockets (#61592)
Filip Navara [Tue, 30 Nov 2021 17:12:58 +0000 (18:12 +0100)]
Fix parsing of ping error replies on raw sockets (#61592)

* Fix parsing of ping error replies on raw sockets

* Re-enable ping tests

* Update the SendPingToExternalHostWithLowTtlTest test validation

2 years ago[TODO-List-Cleanup] Delete `NumChildren`, `GetChild` and `gtGetChildPointer` (#61875)
SingleAccretion [Tue, 30 Nov 2021 17:02:34 +0000 (20:02 +0300)]
[TODO-List-Cleanup] Delete `NumChildren`, `GetChild` and `gtGetChildPointer` (#61875)

* Delete "gtGetChildPointer"

TryGetUse does the same thing and is used more often.

Also some editorial renames to standardize on the "user/use" terminology.

* Delete NumChildren and GetChild

In most situations these methods are the wrong thing
to call - they are not very efficient by design.

Not surprisingly, thus, they were mostly only used in debug
code. The few product dependencies were removed and replaced
with equivalent alternatives, deduplicating the code.

In the process, BasicBlock::firstNode() was removed as it was
not used anywhere.

* Rename 'def' -> 'operand'

* A few forgotten pieces

* One more

2 years agoarea-PAL-Libraries merged into area-System.Runtime.InteropServices (#62180)
Jeff Handley [Tue, 30 Nov 2021 15:06:20 +0000 (07:06 -0800)]
area-PAL-Libraries merged into area-System.Runtime.InteropServices (#62180)

Past issues/PRs were re-tagged as area-System.Runtime.InteropServices and the issue labeler bot was retrained.

2 years agoFix method HttpHeadersNonValidated uses to get HeaderDescriptor (#62150)
Stephen Toub [Tue, 30 Nov 2021 15:04:56 +0000 (10:04 -0500)]
Fix method HttpHeadersNonValidated uses to get HeaderDescriptor (#62150)

We have two non-public methods for getting a HeaderDescriptor from a string name, one static on HeaderDescriptor and one instance on HttpHeaders.  HttpHeadersNonValidated was using the former, but this then doesn't take into account custom logic used by HttpHeaders in other methods, like TryAddWithoutValidation, which means some methods on HttpHeadersNonValidated can't find the corresponding headers.

2 years agoNo-op ConcurrentStack.PushRange(T[]) if empty (#62126)
Martin Costello [Tue, 30 Nov 2021 14:56:51 +0000 (14:56 +0000)]
No-op ConcurrentStack.PushRange(T[]) if empty (#62126)

* No-op ConcurrentStack.PushRange(T[]) if empty

Resolves #62121.

* Add more bounds checks

Assert that ArgumentOutOfRangeException is thrown if specifying indexes for an empty array with PushRange(T[], int, int).

* Review feedback

Allow out-of-bounds index on empty array if count is zero.

* Add extra test case

Add a further test case for a non-empty array but with a count parameter value of zero.

2 years agoavoid code duplication for disabling parallelization with xUnit (#62132)
Adam Sitnik [Tue, 30 Nov 2021 14:52:48 +0000 (15:52 +0100)]
avoid code duplication for disabling parallelization with xUnit (#62132)

The collection definitions must be in the same assembly as the test that uses them

2 years agoFix System.Object serialization with custom number handling (#62020)
Eirik Tsarpalis [Tue, 30 Nov 2021 14:47:58 +0000 (14:47 +0000)]
Fix System.Object serialization with custom number handling (#62020)

* Fix System.Object serialization with custom number handling

* fix typos

2 years agoFix mono alc from gchandle (#62120)
D.S. Qiu [Tue, 30 Nov 2021 14:07:03 +0000 (22:07 +0800)]
Fix mono alc from gchandle (#62120)

* remove MonoManagedAssemblyLoadContext

* fix mono_alc_from_gchandle use field

* change by vargaz review

* formatting

* fixed compiler error

2 years agoFix TimeSpan support in sourcegen (#62130)
Eirik Tsarpalis [Tue, 30 Nov 2021 13:55:44 +0000 (13:55 +0000)]
Fix TimeSpan support in sourcegen (#62130)

* fix TimeSpan support in sourcegen

* address feedback

2 years agoFix set value. Implement Runtime.evaluate. (#62142)
Thays Grazia [Tue, 30 Nov 2021 13:41:46 +0000 (10:41 -0300)]
Fix set value. Implement Runtime.evaluate. (#62142)

2 years agoAvoid printing debug info on 0 byte instructions (#62077)
Jakob Botsch Nielsen [Tue, 30 Nov 2021 10:27:42 +0000 (11:27 +0100)]
Avoid printing debug info on 0 byte instructions (#62077)

In particular do not attach it to INS_align that do not end up producing
any code.

2 years agoFix clang 13 induced runtime issues (#62170)
Jan Vorlicek [Tue, 30 Nov 2021 09:55:21 +0000 (10:55 +0100)]
Fix clang 13 induced runtime issues (#62170)

The clang 13 optimizer started to assume that "this" pointer is always
properly aligned. That lead to elimination of some code that was actually
needed.
It also takes pointer aliasing rules more strictly in one place in jit.
That caused the optimizer to falsely assume that a callee with an argument
passed by reference is not modifying that argument and used a stale
copy of the original value at the caller site.

This change fixes both of the issues. With this fix, runtime compiled
using clang 13 seems to be fully functional.

2 years ago[wasm][debugger] A draft of doc for describing debugger behavior. (#62015)
Ilona Tomkowicz [Tue, 30 Nov 2021 09:32:33 +0000 (10:32 +0100)]
[wasm][debugger] A draft of doc for describing debugger behavior. (#62015)

* A draft of doc for describing debugger behaviour.

* Removing spaces.

2 years agoRun Codespaces prebuild only in upstream repo (#62162)
Eric Erhardt [Tue, 30 Nov 2021 02:47:25 +0000 (20:47 -0600)]
Run Codespaces prebuild only in upstream repo (#62162)

The codespaces prebuild action can only run in the dotnet/runtime repo and not forks. The feature needs to be enabled for each repo and will fail if it isn't enabled. In order to minimize failure notifications, add a check to the action so it only runs against dotnet/runtime.

2 years agoRemove extraneous support in the test runner generator for referencing corelib direct...
Jeremy Koritzinsky [Tue, 30 Nov 2021 01:15:51 +0000 (17:15 -0800)]
Remove extraneous support in the test runner generator for referencing corelib directly. (#62154)

2 years agoMono hot reload reorg and beginning (disabled) add method support (#61853)
Aleksey Kliger (λgeek) [Tue, 30 Nov 2021 00:31:28 +0000 (19:31 -0500)]
Mono hot reload reorg and beginning (disabled) add method support (#61853)

This PR does two things:
1. Reorganizes how we keep track of deltas, and how we do metadata lookups after updates
2. Adds an ifdefed-out initial draft of support for adding methods.  (It worked for a simple test but it's not ready for general use yet).

Details of the delta changes.

* Previously Mono used a fully immutable model of metadata changes.  Logically each delta brings in modifications to existing table rows and addition of new rows.  Previously mono never formed the fully mutated tables - instead, each lookup was essentially responsible for playing all the changes forward every time it needed to lookup a row.  This was fine when we primarily supported only row additions (because we could just skip past all the updates that hadn't added the row we wanted yet, and just look in a single delta).  But as we started to support more and more modifications (of custom attributes, of property getters & setters, of parameters, etc) we now had to look through the whole list of deltas to make sure we found the latest modification of every row.
* The new approach is for each `DeltaInfo` (representing a summary of a particular update to a single assembly) to contain a collection of `mutants` - the fully modified tables with all the newly added rows and all the new modifications.  So lookups are fast now - we just go to the latest generation that is visible to a particular thread and look at its mutants tables.  The downside is increased memory use.  So we allocate the mutants from memory pools owned by each `DeltaInfo`.  Right now we never dealloc the pools, but in the future we could.  We already iterate over all the threads during our stop-the-world phase - we can record the earliest generation still needed by every thread and delete the pools for all earlier copies.  In practice this means we only keep 3 sets of tables: the mmaped baseline tables, the newest mutants, and the mutants from the prior generation for any still-executing methods.
* Additionally instead of storing a list of delta images in the `BaselineInfo`, we now store a list of `DeltaInfo` structs which each `DeltaInfo` pointing to a delta image.  This means that we can avoid repeated hash table lookups to map from a delta image to its `DeltaInfo` every time the runtime queries us for a table row or for a heap element.

---

* checkpoint: allow adding methods to existing classes.

Doesn't do anything yet.

And needs more sanity checking (roslyn won't give us virtual or abstract
methods, but we should check).

* fixme in loader

* [metadata] Add mono_metadata_table_num_rows

Returns the number of rows in a metadata table, taking into account metadata
update deltas

* add table to ptr table helper

* Param attr lookups for deltas can have param_index == 0

The params are added with a subsequent enclog "add param" function.

* WIP: start adding support for parameter additions.

It "works" in that calling methods appears to work (ie direct token references
seem to do the right thing).

Primarily this is because the param table additions are not that interesting.
All the good stuff is in the method signature (which is just in the blob heap).

Presumably anything that actually needs parameter attributes, or anything that
uses reflection to look at the parameters, will break.

* WIP: add MethodDef -> TypeDef lookup

Allows calling non-public methods, which are now assigned the correct parent

* Add hot reload test for lambda capturing this

Lambdas that only capture `this` (and not local variables or arguments) compile
to a private instance method in the enclosing class.  So it is enough to
support EnC deltas that add methods.

* clarify comments about MONO_METHOD_PARAMLIST

* [hot_reload] Store debug info of updated methods

* [hot_reload] Allocate modifiable tables in DeltaInfo

This is the foundation for a new approach for metadata lookups.
Instead of using an immutable model (each lookup traverses every delta to find
the most up to date version of each table row), we are going to create a
complete updated table for each generation and only do the lookup in the latest
exposed generation directly.  (This is essentially the CoreCLR model).

This commit is just the first foundations: we allocate the tables and copy over
the previous generations' rows and zero out any rows that will be inserted.
Delta applications and lookups have not been updated yet.

As a slight optimization, tables that don't have modified or added rows are not
copied from the base image.  If a generation modifies or adds rows, from that
point forward, each subsequent generation will copy the table.

We could be a bit more thrifty with copying, but it will complicate lookups.
Also eventually we will try to deallocate the pools for generations that are
older than no thread needs anymore.

Metadata heaps are still looked up in each delta directly - heap combining does
not seem necessary yet.

* [mini] Allow MONO_VERBOSE_METHOD='*:*'

Implement method name wildcard matching for method descriptions

Globbing doesn't work because we don't have g_pattern_match_simple in eglib.
But a plain '*' wildcard does work.

* populate mutated table rows

leave suppressed columns unchanged

* [hot_reload] Switch lookups to the mutant tables

* cleanup: remove of effective_table calculation

The row index doesn't change in the new scheme, pass it by value

* cleanup: Remove relative_delta_index from component API

It's only used internally by the update logic

* cleanup: Pass DeltaInfo to relative_delta_index

don't compute it from the dmeta image

* cleanup: Store a list of DeltaInfo in the BaselineInfo

Instead of storing a list of delta images and then relying on delta_info_lookup
to find the DeltaInfo, just store them directly on the baseline info.

This changes the cleanup responsibilities a bit.  Now we destroy the DeltaInfo
when we are iterate through the delta infos when we close the baseline image,
instead of when we remove the delta_image_to_info hashtable entry.

* Turn off method addition support, for now

Just want to get the cleanups enabled for now

* Fix null ptr when checking for updated ppdb info

2 years agoRevert "Adding support for the X86Base.Pause intrinsic on Mono (#61707)" (#62157)
Andy Gocke [Tue, 30 Nov 2021 00:14:45 +0000 (16:14 -0800)]
Revert "Adding support for the X86Base.Pause intrinsic on Mono (#61707)" (#62157)

This reverts commit 1997beecd941ec0b825a5319cda0e97f2effbf3b.

2 years agoSupport zero-byte reads on HTTP response streams (#61913)
Miha Zupan [Mon, 29 Nov 2021 23:11:38 +0000 (15:11 -0800)]
Support zero-byte reads on HTTP response streams (#61913)

* Allow zero byte reads on raw HTTP/1.1 response streams

* Allow zero byte reads on the rest of HTTP/1.1 response streams

* Allow zero byte reads on HTTP/2 response streams

* Allow zero byte reads on HTTP/3 response streams

* Enable sync zero-byte reads

* Add zero-byte read tests

* Fully enable zero-byte reads on HTTP/2 and 3

* Add zero-byte read tests for HTTP/2 and HTTP/3

* Remove unsafe-ish code from PeekChunkFromConnectionBuffer

* Add comments when we do extra zero-byte reads

* Update MockQuicStreamConformanceTests to allow zero-byte reads

* Update ConnectedStream tests to allow zero-byte reads

* Skip zero-byte read tests on Browser

* Update comment on explicit zero-byte reads in ChunkedEncodingReadStream

2 years agoCleanup some code using ECAlgorithm
Kevin Jones [Mon, 29 Nov 2021 22:29:43 +0000 (17:29 -0500)]
Cleanup some code using ECAlgorithm

2 years agoImplement PEM exports for RSA PKCS#1 and ECPrivateKey
Kevin Jones [Mon, 29 Nov 2021 22:23:30 +0000 (17:23 -0500)]
Implement PEM exports for RSA PKCS#1 and ECPrivateKey