platform/upstream/dotnet/runtime.git
2 years ago[main] Update dependencies from dotnet/linker (#62771)
dotnet-maestro[bot] [Mon, 20 Dec 2021 12:32:52 +0000 (13:32 +0100)]
[main] Update dependencies from dotnet/linker (#62771)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoImprove XML documentation (#62994)
bjornen77 [Mon, 20 Dec 2021 12:08:12 +0000 (13:08 +0100)]
Improve XML documentation (#62994)

Corrected return value type in XML documentation.

Fix #62993

Co-authored-by: Björn Sjögren <bjs@hms.se>
2 years ago[main] Update dependencies from dotnet/arcade (#62985)
dotnet-maestro[bot] [Mon, 20 Dec 2021 08:48:50 +0000 (09:48 +0100)]
[main] Update dependencies from dotnet/arcade (#62985)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoFix managed CoreCLR build on Android (#63002)
Michal Strehovský [Mon, 20 Dec 2021 04:02:03 +0000 (13:02 +0900)]
Fix managed CoreCLR build on Android (#63002)

2 years agoImplement isMoffset for emitOutputAM (#62896)
SingleAccretion [Sun, 19 Dec 2021 22:35:37 +0000 (01:35 +0300)]
Implement isMoffset for emitOutputAM (#62896)

2 years agoRemove small casts on the RHS of ASG(CLS_VAR) (#62693)
SingleAccretion [Sun, 19 Dec 2021 22:20:57 +0000 (01:20 +0300)]
Remove small casts on the RHS of ASG(CLS_VAR) (#62693)

2 years agoHave NativeAOT test execution project include SDK (#62927)
Michal Strehovský [Sat, 18 Dec 2021 23:57:31 +0000 (08:57 +0900)]
Have NativeAOT test execution project include SDK (#62927)

* Have NativeAOT test execution project include SDK

The SDK contains logic to configure trimming - we were skipping all of that. We couldn't previously include the SDK because it would reflection-root the entrypoint assembly. No longer the case after #62890.

2 years agoAdd 'w' and 's' bit to xarch instruction flags. (#61198)
anthonycanino [Sat, 18 Dec 2021 18:21:17 +0000 (10:21 -0800)]
Add 'w' and 's' bit to xarch instruction flags. (#61198)

Change encodes 'w' and 's' in the insFlags struct and INS_FLAG
entry for xarch instruction table. In addition, add methods to check
check if this flag is set for an instruction, which allows to start
simplifying some of the various ad-hoc checks for these bits that were
previously done per-instruction throughout emitxarch.cpp.

2 years ago[wasm] Testing with NodeJs on CI (#62779)
Pavel Savara [Sat, 18 Dec 2021 09:14:01 +0000 (10:14 +0100)]
[wasm] Testing with NodeJs on CI (#62779)

* enable testing with NodeJS on CI
* Fix task marshal tests.
Co-authored-by: Marek Fišera <mara@neptuo.com>
2 years agoSuppress OSR for crossgen2 execution (#62968)
Andy Ayers [Sat, 18 Dec 2021 07:09:36 +0000 (23:09 -0800)]
Suppress OSR for crossgen2 execution (#62968)

* Suppress OSR for crossgen2 execution

In CI testing, crossgen2 currently is run via a .NET 6 runtime, and
that runtime has some bugs in OSR.

Work around by suppressing OSR for the duration of the run. We should
be able to revert this once we update the crossgen2 runtime
to a .NET 7 version.

* add COMPlus exclusions for readytorun/multifolder

2 years agoAllow building libs against NativeAOT CoreLib (#62945)
Michal Strehovský [Sat, 18 Dec 2021 05:13:08 +0000 (14:13 +0900)]
Allow building libs against NativeAOT CoreLib (#62945)

To make sure ApiCompat tooling for NativeAOT's CoreLib runs at least in some legs, compile libs against NativeAOT CoreLib if we're building CLR, but not building the JIT flavor of the runtime.

The baselining is necessary because the reflection stack of NativeAOT doesn't live in CoreLib.

The CannotRemoveBaseTypeOrInteface baselining will go away once https://github.com/dotnet/runtime/issues/62944 gets fixed. It's one of the "overall goodness" things we can take out of NativeAOT and put it into all runtimes.

2 years agoHandle RunClassConstructor with nonreflectable cctor (#62947)
Michal Strehovský [Sat, 18 Dec 2021 04:59:42 +0000 (13:59 +0900)]
Handle RunClassConstructor with nonreflectable cctor (#62947)

This is now getting hit in #62927, so it's somewhat more urgent. (The feature switches from the SDK put us into the situation that triggers this bug around `RunClassConstructor` on an otherwise unused type.)

Fixes dotnet/runtimelab#987.

Remember what class constructor contexts we saw during scanning phase and if the owning type is also generated, assume `RunClassConstructor` could be used and ensure the cctor context is also generated in the compilation phase.

This is somewhat less precise, but introducing a new node type for "a type used with `RunClassConstructor`" that dataflow analysis could report doesn't seem worth it.

2 years agoUpdate shared trimming attributes with recently added/used types (#62911)
Marek Safar [Fri, 17 Dec 2021 22:26:34 +0000 (23:26 +0100)]
Update shared trimming attributes with recently added/used types (#62911)

2 years agoUnify implementation of string constructors accross runtimes (#62936)
Jan Kotas [Fri, 17 Dec 2021 22:25:23 +0000 (14:25 -0800)]
Unify implementation of string constructors accross runtimes (#62936)

String constructors implementation methods had a dummy this argument on CoreCLR, but not on other runtimes.  It required ifdefs in the implementation. This change removes the ifdefs and makes the string constructors implementation methods uniform accross all runtimes. It is possible to do this cleanup now since we have just bumped R2R version band.

2 years agoDeduplicate JIT/Methodical/explicit/coverage tests (#62867)
Tomáš Rylek [Fri, 17 Dec 2021 19:05:08 +0000 (20:05 +0100)]
Deduplicate JIT/Methodical/explicit/coverage tests (#62867)

This test set contains several project groups exercising various
primitive types using explicit and sequential layout. Each group
comprises a variant source file implementing a sequential or
explicit struct / class 'AA' with a field of the given type
(e.g. expl_byte_1.cs / seq_byte_1.cs) and a common source file
(body_byte.cs in this case) implementing a number of tests
manipulating the type 'AA' that is shared by the explicit and
the sequential variant of the project (e.q. expl_byte_1[_d/_r].csproj,
seq_byte_1[_d/_r].csproj).

The problem was that the Main method resided in the common source
file so that it was always present twice - once for the sequential
and once for the explicit variant of the test (ignoring the _d / _r
flavors). After experimenting with several ways to refactor the tests
I have come to the conclusion that the most straightforward way
of deduplicating them is just moving the Main method out of the shared
source code into the variant (explicit / sequential) sources that
aren't shared.

Thanks

Tomas

2 years agoJIT: handle more cases for MOD/DIV -> UMOD/UDIV transformation (#62394)
Egor Bogatov [Fri, 17 Dec 2021 18:36:24 +0000 (21:36 +0300)]
JIT: handle more cases for MOD/DIV -> UMOD/UDIV transformation (#62394)

* Introduce IsNeverNegative

* Address feedback

* Apply suggestions from code review

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

* fix build on x86

Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years agoRemove forward-sub for hw intrinsics during inlining (#62883)
Egor Bogatov [Fri, 17 Dec 2021 18:36:00 +0000 (21:36 +0300)]
Remove forward-sub for hw intrinsics during inlining (#62883)

2 years ago[main] Update dependencies from dotnet/arcade llvm-project (#62842)
dotnet-maestro[bot] [Fri, 17 Dec 2021 17:33:07 +0000 (18:33 +0100)]
[main] Update dependencies from dotnet/arcade llvm-project (#62842)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoOSR support for Arm64 (#62831)
Andy Ayers [Fri, 17 Dec 2021 16:32:17 +0000 (08:32 -0800)]
OSR support for Arm64 (#62831)

* OSR support for Arm64

Enable OSR for Arm64:
* rename `FpToSpDelta` in `PatchpointInfo` to `TotalFrameSize` so it makes
sense for both x64 and Arm64.
* make it clear that the local offsets in `PatchpointInfo` are virtual
(relative to the top of the frame). Adjust recorded Arm64 offsets to match.
* add new jit config setting `JitEnableOSRRange` to allow selectively enabling
OSR for only a subset of jitted methods.
* Arm64 OSR method is passed Tier0 SP but not Tier0 FP, as Tier0 FP can point
either at top or bottom of Tier0 frame depending on frame type. For Arm64 the
OSR method establishes its own FP that chains to caller FP. (I will likely
revise x64 to work this way too, as it makes simple FP chain stackwalks work
out better).
* The Arm64 OSR epilog gets an extra SP adjustment to remove the Tier0 frame.
* The Arm64 OSR prolog gets a phantom SP adjustment in unwind to account for
being passed the Tier0 SP.
* pad OSR funclet frames with tier0 frame size so `PSPSym` ends up at the same
caller-SP relative offset as the OSR frame
* handle the large `fiSpDelta1` offsets from the funclet frame padding
* local/arg init for the OSR frame from the Tier0 frame was moved into a new
method `genEnregisterOSRArgsAndLocals`; implemented the ARM64 version.
* sequencing of this initialization in the prolog reordered slightly to prevent
inadvertent clobbering.
* comments/code that referred to `original` or `old` method were revised to
instead try and consistently use `tier0`.
* support the mixed-altjit case for OSR by allocating a local copy of the
patchpoint info with similar and plausible information.
* add symbol table note for locals in OSR methods that live on the Tier0 frame.
* fix `fgIsThrowHlpBlk` when called on an empty block
* broaden the jit-experimental testing matrix to include Arm64.

2 years agosetInternalRegsDelayFree only for candidate lclVars (#62884)
Kunal Pathak [Fri, 17 Dec 2021 15:00:53 +0000 (07:00 -0800)]
setInternalRegsDelayFree only for candidate lclVars (#62884)

2 years agoDisable some suspicious tests which might lead to OOM crashes on Android emulators...
Maxim Lipnin [Fri, 17 Dec 2021 12:35:23 +0000 (15:35 +0300)]
Disable some suspicious tests which might lead to OOM crashes on Android emulators and arm64 devices (#62767)

Just blindly disabling several crypto tests near which crashes have been observed for a while (based on a couple of the mobile targets rolling build runs).

Disabled tests:

- System.Security.Cryptography.Rsa.Tests.RSAKeyFileTests.ReadWriteDiminishedDPPrivatePkcs1
- System.Security.Cryptography.Rsa.Tests.RSAKeyFileTests.ReadEncryptedDiminishedDP_EmptyPassword
- System.Security.Cryptography.Rsa.Tests.RSAKeyFileTests.DecryptPkcs12PbeTooManyIterations
- System.Security.Cryptography.Rsa.Tests.RSAKeyFileTests.ReadWriteRsa2048EncryptedPkcs8_Pbes2HighIterations
- System.Security.Cryptography.Dsa.Tests.DSAKeyFileTests.cs.DecryptPkcs12PbeTooManyIterations
- System.Security.Cryptography.Dsa.TestsDSAKeyFileTests.cs.ReadWriteDsa1024EncryptedPkcs8_Pbes2HighIterations
- System.Security.Cryptography.Tests.ECKeyFileTests.DecryptPkcs12PbeTooManyIterations
- System.Security.Cryptography.Tests.ECKeyFileTests.ReadWriteEc256EncryptedPkcs8_Pbes2HighIterations
- System.Security.Cryptography.EcDsa.Tests.ECDsaTests_Span

See also https://github.com/dotnet/runtime/issues/62547.

2 years agoignore directories when building TPA (#62932)
Andy Ayers [Fri, 17 Dec 2021 06:03:58 +0000 (22:03 -0800)]
ignore directories when building TPA (#62932)

2 years agoRemove an unused .editorconfig entry. (#62905)
Theodore Tsirpanis [Fri, 17 Dec 2021 04:12:14 +0000 (06:12 +0200)]
Remove an unused .editorconfig entry. (#62905)

2 years agoCorrected the grammar/spelling mistake in autogenerated cs file. (#62934)
pyracanda [Fri, 17 Dec 2021 04:08:11 +0000 (07:08 +0300)]
Corrected the grammar/spelling mistake in autogenerated cs file. (#62934)

2 years agoIncrease iteration count in the FinalizeTest (#62924)
Michal Strehovský [Fri, 17 Dec 2021 02:20:58 +0000 (11:20 +0900)]
Increase iteration count in the FinalizeTest (#62924)

Iteration count was dropped to a smaller number in https://github.com/dotnet/corert/pull/2867. Looks like it's not enough because we see this test fail in the CI.

2 years agoAdd Pri-0 test suppressions for NativeAOT (#62926)
Michal Strehovský [Fri, 17 Dec 2021 02:18:48 +0000 (11:18 +0900)]
Add Pri-0 test suppressions for NativeAOT (#62926)

2 years agoHandle zero-sized unwind fragment candidates (#62931)
Bruce Forstall [Fri, 17 Dec 2021 01:54:39 +0000 (17:54 -0800)]
Handle zero-sized unwind fragment candidates (#62931)

Every unwind fragment should be non-zero sized. If we consider
splitting on a boundary that would create a zero-sized fragment,
don't report that one. This only occurs when setting the
stress mode JitSplitFunctionSize to something small.

2 years agoRemove the varargs-based mdarray helper. (#62855)
Jeremy Koritzinsky [Thu, 16 Dec 2021 23:11:50 +0000 (15:11 -0800)]
Remove the varargs-based mdarray helper. (#62855)

2 years agoFix duplicated FldSeq in block morphing (#62687)
SingleAccretion [Thu, 16 Dec 2021 22:16:46 +0000 (01:16 +0300)]
Fix duplicated FldSeq in block morphing (#62687)

* Fix duplicated FldSeq in block morphing

Reusing the address for the first field is problematic as
the first field is likely to be at a zero offset, thus a
zero-offset field sequence will be attached to it, and
subsequent copies of the same tree will pick it up, which
is incorrect.

Fix by reusing the address for the last field instead.

* Add a test

* Add a description of the issue to the test

2 years agoUpdate CODEOWNERS (#62928)
Michal Strehovský [Thu, 16 Dec 2021 21:54:54 +0000 (06:54 +0900)]
Update CODEOWNERS (#62928)

2 years agoFix InvokeMember corner case (#62891)
Michal Strehovský [Thu, 16 Dec 2021 21:06:41 +0000 (06:06 +0900)]
Fix InvokeMember corner case (#62891)

2 years agoImprove compatibility with IL Linker (#62890)
Michal Strehovský [Thu, 16 Dec 2021 21:06:14 +0000 (06:06 +0900)]
Improve compatibility with IL Linker (#62890)

`<TrimmerRootAssembly Include="myEntrypointAssembly" />` won't actually root anything with IL Linker. NativeAOT would do what it's instructed to do. This is showing up as a difference because the SDK auto-injects this root into all trimmed projects.

2 years ago[wasm] callback to make waiting on module load easier (#62904)
Pavel Savara [Thu, 16 Dec 2021 20:45:41 +0000 (21:45 +0100)]
[wasm] callback to make waiting on module load easier (#62904)

* callback to make waiting on module load easier

2 years agoDelete several duplicate test projects under JIT/Methodical (#62861)
Tomáš Rylek [Thu, 16 Dec 2021 18:28:51 +0000 (19:28 +0100)]
Delete several duplicate test projects under JIT/Methodical (#62861)

arithm32_cs_d: duplicate of arithm32_d
arithm32_cs_do: duplicate of arithm32_do

arithm64_cs_d: duplicate of arithm64_d with the only difference
that arithm64_d was Pri1. I have kept arithm64_d (due to the
shorter name) but I deleted the Pri1 specifier.

arithm64_cs_do: duplicate of arithm64_do with the only difference
that aritm64_do was Pri1. I have kept arithm64_d (due to the
shorter name) but I deleted the Pri1 specifier.

gc_nested: duplicate of gc_nested_d
nested: duplicate of nested_d
gcreport: duplicate of gcreport_d
native: duplicate of native_d
virtcall: duplicate of virtcall_d
refanyval: duplicate of refanyval_d

In all five cases I kept the version with _d for symmetry with
the other build options (_do / _r / _ro).

_XAssemblytest1-xassem: duplicate of _XModuletest1_xmod
_XAssemblytest2-xassem: duplicate of _XModuletest2_xmod
_XAssemblytest4-xassem: duplicate of _XModuletest4_xmod

In these three cases I kept the _XModuletest variants that have
compilation files and project references organized as two item groups
that is the most prevalent style in our projects. The _Xmoduletest
variants are apparently missing a boilerplate comment that is of
little use.

Thanks

Tomas

2 years ago[wasm] Add support for running debugger tests CI (#62431)
Ankit Jain [Thu, 16 Dec 2021 18:17:37 +0000 (18:17 +0000)]
[wasm] Add support for running debugger tests CI (#62431)

* [wasm] Don't emit warning if runtimeconfig.json cannot be found

Library projects don't have runtimeconfig.json files by default. So,
don't make it a warning. Instead, emit a low importance which might be
useful when debugging.

But library projects can have runtimeconfig.json, like the runtime test
projects. So, don't limit processing that by OutputType.

IOW, if it's found then use it.

* [wasm] Add timestamp to logs

* Download dotnet-install script for installing workloads

Instead of trying to use the script from `.dotnet`, download the script.
`.dotnet` might not exist, for example, when the `global.json` version
matches the system installed one.

* [wasm] WasmAppBuilder: catch UnauthorizedAccessException also

* [wasm] Fix bug in tests

Some helper methods have a `Action<JToken>` parameter. Many tests
pass an async lambda to this, expecting it to get awaited upon.

```csharp
    EvaluateAndCheck (Action<T> locals_fn)
    {
        ...
        locals_fn(); // no await
        ...
    }

    async Task Test()
    {
        EvaluateAndCheck( async (locals) => {
            ...
            CheckNumber(locals, ...);

            await CheckDateTime(locals, ..);
            ...

        } );
    }
```

In the above example, roslyn generates an async-void lambda, so the
compiler never complains about the async lambda being passed.
`EvaluateAndCheck` cannot, and does not await this, but if the lambda happens to
block, then it will return at that point, and the test(calling method) will end,
without ever completing the lambda. And for most tests, the actual
checks are done in that lambda.

This gets hit when `CheckDateTimeValue` tries to fetch properties of a
`DateTime` object. And it started to show up when adding
`ConfigureAwait(false)` to some calls.

* [wasm] Add Wasm.Debugger.Tests wrapper project

This is a proxy/wrapper project for `src/mono/wasm/debugger/DebuggerTestSuite/DebuggerTestSuite.csproj`.

- Building the project as part of the regular browser-wasm build
  presents some issues, because of part the tests need use the aspnet
  sdk, and that doesn't work with `browser-wasm`.
- This wrapper project essentially builds the `DebuggerTestSuite`
  project, with some
  properties(`TargetFramework;TargetFrameworks;Configuration;TargetOS;TargetArchitecture`)
  removed so they don't propogate from the parent build.
  - And it packages it up for running the tests on helix

- I did try to convert `DebuggerTestSuite` into a `Wasm.Debugger.Tests`,
  and make it use the library tests infrastructure, but ran into an
  issue
  - it built the project with no `testhost.dll`, so can't use `dotnet
    test`
  - it did get `xunit.console.dll`, but that would fail to run the tests
    because of missing `System.Runtime` (and I'm guessing, other
    assemblies)
    - attempts to publish the project failed
    - So, for now, this is what we have!

* [wasm][tests] Make them friendly to running outside the tree

.. like on helix.

Add new `DEBUGGER_TEST_PATH`, and `CHROME_PATH_FOR_DEBUGGER_TESTS` which
will be set for helix.

And change the appbundle directory name from the misleading `publish/`
to `AppBundle/`.

* [wasm] Tests.cs -> MiscTests.cs

* [wasm] Add support for submitting debugger tests to helix

Also, added `eng/testing/scenarios/WasmDebuggerTestsJobsList.txt` which
is a manually generated list of test classes. This will be changed to be
generated at runtime, in an upcoming PR.

* [wasm] Add debugger tests job for linux, and windows

They follow the same pattern as other wasm jobs:

- build when isFullMatrix
- build in runtime-manual
- Additionally, build when there are changes in:

```
  - src/mono/wasm/debugger/*
  - src/mono/wasm/runtime/*
  - src/mono/mono/*
```

* [wasm] Add new make targets to submit tests to helix

`submit-debugger-tests-helix`
`submit-tests-helix` - submits any library test archives

* Build Wasm.Debugger.Tests from src/libraries/tests.proj

* DebuggerTestSuite: Copy files for the test archive

* [wasm] Fix HarnessTests.BrowserClose

* [wasm] Fix building `ApplyUpdateReferencedAssembly` project on CI

Essentially, disable use of SourceLink which gets enabled by default
when using `-p:ContinuousIntegrationBuild=true`.

Issue: https://github.com/dotnet/runtime/issues/62618

* cleanup

* Wasm.Build.Tests: add missing file

* [wasm] sendtohelixhelp.proj: Error out if there is more than one zip

.. file when running for Wasm.Build.Tests, or Wasm.Debugger.Tests .

* [wasm] Disable DebuggerTests.ArrayTests on helix

Issue: https://github.com/dotnet/runtime/issues/62661

Using `[Trait..` instead of `ActiveIssue` because: https://github.com/dotnet/runtime/issues/62660

* disable non-wasma builds

* sendtohelixhelp.proj: guard against no payload found

* Disable more tests

* add back builds

* [wasm][debugger] Disable failing debugger test

`DebuggerTests.BreakpointTests.BreakpointInAssemblyUsingTypeFromAnotherAssembly_BothDynamicallyLoaded`

Issue: https://github.com/dotnet/runtime/issues/62823

* Try to fix windows command line

* Move debugger-tests for linux to runtime-staging

* Revert "[wasm][debugger] Fix source-link test (#62786)"

.. as it is breaking debugger tests build on windows.

Issue: https://github.com/dotnet/runtime/issues/62892
This reverts commit 815174072529c5183fc7418bec20dce61f2f6f15.

2 years agoDelete `GT_SIMD_CHK` and `GT_HW_INTRINSIC_CHK` (#62088)
SingleAccretion [Thu, 16 Dec 2021 17:59:26 +0000 (20:59 +0300)]
Delete `GT_SIMD_CHK` and `GT_HW_INTRINSIC_CHK` (#62088)

* Delete GT_SIMD_CHK and GT_HW_INTRINSIC_CHK

The former was unused, the latter - barely used.
Overall, there is no need for these to be separate
opers, it just leads to unnecessary `#ifdef`s.

* Remove IsArrayBoundsCheck

In loop cloning: redundant with the check for constant lengths below.

In assertion propagation: needless pessimization.

In range check: not needed. While it is not useful to search for the
array lengths from "new int[] { ... }" expressions, it is still useful
to look for assertions related to them.

* GTF_ARR_BOUND_INBND -> GTF_CHK_INDEX_INBND

* Fix formating

2 years agoMove 1604 docker based helix queues to 1804 (#62871)
Santiago Fernandez Madero [Thu, 16 Dec 2021 17:01:54 +0000 (11:01 -0600)]
Move 1604 docker based helix queues to 1804 (#62871)

2 years ago[wasm] Add a new supported signature for pinvokes (#61667)
Vlad Brezae [Thu, 16 Dec 2021 09:44:49 +0000 (11:44 +0200)]
[wasm] Add a new supported signature for pinvokes (#61667)

2 years agoDirectory.Delete: prefer DirectoryNotFoundException over UnauthorizedAccess IOExcepti...
Tom Deseyn [Thu, 16 Dec 2021 09:21:53 +0000 (10:21 +0100)]
Directory.Delete: prefer DirectoryNotFoundException over UnauthorizedAccess IOException. (#62396)

* Directory.Delete: prefer DirectoryNotFoundException over UnauthorizedAccess IOException.

* Refactor error handling.

2 years agodisable fragile http test on wasm (#62852)
Pavel Savara [Thu, 16 Dec 2021 07:47:53 +0000 (08:47 +0100)]
disable fragile http test on wasm (#62852)

2 years agoFix Microsoft.VisualBasic.Core file version (#62848)
Santiago Fernandez Madero [Thu, 16 Dec 2021 05:03:12 +0000 (23:03 -0600)]
Fix Microsoft.VisualBasic.Core file version (#62848)

2 years agoEnable NativeAOT in the CI (#62833)
Michal Strehovský [Thu, 16 Dec 2021 04:38:12 +0000 (13:38 +0900)]
Enable NativeAOT in the CI (#62833)

2 years ago[TODO-List-Cleanup] Delete the quirks (#61876)
SingleAccretion [Thu, 16 Dec 2021 02:15:16 +0000 (05:15 +0300)]
[TODO-List-Cleanup] Delete the quirks (#61876)

* Remove the VN quirk

* Delete the costing quirk

2 years agoUndo breaking change in 6.0 in environment variable configuration prefix support...
Maryam Ariyan [Thu, 16 Dec 2021 02:12:00 +0000 (18:12 -0800)]
Undo breaking change in 6.0 in environment variable configuration prefix support (#62819)

2 years agoAdd docs around NativeAOT workflows (#62837)
Michal Strehovský [Thu, 16 Dec 2021 01:35:54 +0000 (10:35 +0900)]
Add docs around NativeAOT workflows (#62837)

2 years agoMaking user secrets optional by default (#62821)
Maryam Ariyan [Wed, 15 Dec 2021 23:33:36 +0000 (15:33 -0800)]
Making user secrets optional by default (#62821)

2 years agoUnify the FlushProcessWriteBuffers mechanism for macOS arm64 / x64 (#62822)
Jan Vorlicek [Wed, 15 Dec 2021 23:14:14 +0000 (00:14 +0100)]
Unify the FlushProcessWriteBuffers mechanism for macOS arm64 / x64 (#62822)

The macOS arm64 was using a new mechanism to implement FlushProcessWriteBuffers
because the original one based on a wired memory page doesn't work on arm64.
We have seen people hitting problems with the wired memory page allocation on
x64 in the past due to the fact that wired memory is a scarce resource and
in some cases, e.g. in presence of apps that greedily grab all of the available
wired memory pages, we were unable to initialize coreclr and execute any .NET
application.

This change switches x64 to the same mechanism as arm64 to prevent that issue
from happening and updates the minimum supported x64 macOS to 10.14. That's the
version required for the new APIs the change is using. Apple stopped supporting
10.13 a year ago anyways.

2 years agoAdd ConstantExpectedAttribute (#62436)
Wei Zheng [Wed, 15 Dec 2021 22:13:53 +0000 (06:13 +0800)]
Add ConstantExpectedAttribute (#62436)

2 years agoMake `ControlFlowBuilder.Clear` public. (#62811)
Theodore Tsirpanis [Wed, 15 Dec 2021 22:13:05 +0000 (00:13 +0200)]
Make `ControlFlowBuilder.Clear` public. (#62811)

2 years agoUpdated tracking issue (#62814)
Fan Yang [Wed, 15 Dec 2021 19:57:48 +0000 (14:57 -0500)]
Updated tracking issue (#62814)

2 years agoPass HFA/HVA in registers (#62623)
Egor Chesakov [Wed, 15 Dec 2021 19:07:27 +0000 (11:07 -0800)]
Pass HFA/HVA in registers (#62623)

* Have more concise check for "HFAs should not be morphed to FieldList when they are not passed on SIMD registers" in src/coreclr/jit/morph.cpp

* Pass HFA/HVA arguments in registers in src/coreclr/jit/morph.cpp

2 years agoMake emitAddrMode xarch only (#62830)
Bruce Forstall [Wed, 15 Dec 2021 18:50:19 +0000 (10:50 -0800)]
Make emitAddrMode xarch only (#62830)

It is not used on arm32/arm64.

2 years agoChange all "unmanaged" (no GC fields) sequential types to have sequential layout...
Jeremy Koritzinsky [Wed, 15 Dec 2021 18:20:37 +0000 (10:20 -0800)]
Change all "unmanaged" (no GC fields) sequential types to have sequential layout. (#61759)

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoAdd ubuntu 21.10 (#62783)
Jan Jahoda [Wed, 15 Dec 2021 17:28:05 +0000 (18:28 +0100)]
Add ubuntu 21.10 (#62783)

2 years ago[MonoAOTCompiler] more properties & custom WorkingDirectory (#62725)
Jonathan Peppers [Wed, 15 Dec 2021 17:15:05 +0000 (11:15 -0600)]
[MonoAOTCompiler] more properties & custom WorkingDirectory (#62725)

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

PR #58523 fixed something on Windows, but it didn't actually address
our issues on Android.

A directory name like `foo Ümläüts` fails:

* `mkdir 'foo Ümläüts' ; cd 'foo Ümläüts'`
* `dotnet new android`
* `dotnet build -c Release -p:RunAOTCompilation=true` (adding
  `-p:EnableLLVM=true` complicates further)

The error:

    Precompiling failed for C:\src\foo Ümläüts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll: Error: Loaded assembly 'C:\src\foo ├£ml├ñ├╝ts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll' doesn't match original file name 'C:\foo ▄mlΣⁿts\obj\Release\android-arm64\linked\System.Private.CoreLib.dll'. Set MONO_PATH to the assembly's location.

Reviewing the existing AOT implementation in Xamarin.Android, I found
out *why* Xamarin.Android works:

    [AOT] response file obj\Release\120\aot\arm64-v8a\App36.dll\response.txt: --llvm "--aot=temp-path=obj\Release\120\aot\arm64-v8a\App36.dll,llvm-path=C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Xamarin\Android,outfile=obj\Release\120\aot\arm64-v8a\libaot-App36.dll.so,msym-dir=obj\Release\120\aot\arm64-v8a,asmwriter,mtriple=aarch64-linux-android,tool-prefix=C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-,ld-name=ld.EXE,ld-flags=\"-LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\";\"-LC:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\toolchains\llvm\prebuilt\windows-x86_64\lib\gcc\aarch64-linux-android\4.9.x\libgcc.a\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\libc.so\";\"C:\Program Files (x86)\Android\android-sdk\ndk-bundle\platforms\android-21\arch-arm64\usr\lib\libm.so\"" C:\Users\jopepper\source\repos\App36\App36\obj\Release\120\android\assets\shrunk\App36.dll

1. Xamarin.Android passes *relative* paths. The `foo Ümläüts`
   directory name doesn't even come into play for some arguments.

2. With LLVM, `ld-flags` contains a `;`.

The existing code splits on `;` and joins on `,`:

https://github.com/dotnet/runtime/blob/25c207351c4f57cf2daa98caaf327a8b8d83edb8/src/tasks/AotCompilerTask/MonoAOTCompiler.cs#L505-L509

So we lose any `;` delimiters for the `ld-flags` value, they get
replaced by `,`.

I think the solution here is:

1. Add several missing properties to `<MonoAOTCompiler/>` so we don't
   have to rely on the `%(AotArguments)` item metadata. No splitting
   on `;` would be required, `ld-flags` can be passed in and used as-is.

2. Add a new `WorkingDirectory` property. When this is set, assume
   paths passed in might be relative -- and don't transform paths by
   calling `Path.GetFullPath()`.

Lastly, I fixed a place where the UTF8 encoding wasn't passed when
MSBuild logging the response file.

These changes I tried to make in a way where this shouldn't break
other .NET workloads like wasm. If existing MSBuild targets call this
task (not using the new properties), the behavior should remain
unchanged.

I tested these changes by commiting a modified `MonoAOTCompiler.dll`:

https://github.com/xamarin/xamarin-android/pull/6562

I'm able to enable several AOT tests related to dotnet/runtime#56163.

2 years agoManifest DllImportSourceGenerator as a generator (#62836)
Michal Strehovský [Wed, 15 Dec 2021 16:51:38 +0000 (01:51 +0900)]
Manifest DllImportSourceGenerator as a generator (#62836)

2 years agoUpdate libunwind to v1.6.2 (#62092)
Adeel Mujahid [Wed, 15 Dec 2021 16:02:20 +0000 (18:02 +0200)]
Update libunwind to v1.6.2 (#62092)

* Update libunwind to v1.6.2

* Apply libunwind changes from 1b5719c

Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
* Suppress Wincompatible-pointer-types on arm64

* Fix remote unwinding on win-arm64

* Mark base as both input and output

Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
Co-authored-by: Jan Vorlicek <janvorli@microsoft.com>
Co-authored-by: Jan Vorlicek <jan.vorlicek@volny.cz>
2 years ago[wasm][debugger] Fix source-link test (#62786)
Thays Grazia [Wed, 15 Dec 2021 12:53:06 +0000 (09:53 -0300)]
[wasm][debugger] Fix source-link test (#62786)

* Fix 62551

* Addressing @radical comments.

* Adding comments to not forget what we were trying to test.
Indenting.

2 years agoUse 1ES pool instead of deprecated windows image in "Publish to Build Asset Registry...
Alexander Köplinger [Wed, 15 Dec 2021 06:12:53 +0000 (07:12 +0100)]
Use 1ES pool instead of deprecated windows image in "Publish to Build Asset Registry" job (#62797)

2 years agoAdd custom marshaller tests for delegates (#62691)
Andrii Kurdiumov [Wed, 15 Dec 2021 05:44:19 +0000 (11:44 +0600)]
Add custom marshaller tests for delegates (#62691)

2 years agoImprove ARM64 JIT disassembly (#62557)
Will Smith [Wed, 15 Dec 2021 05:17:14 +0000 (21:17 -0800)]
Improve ARM64 JIT disassembly (#62557)

* Improved ARM64 disassembly by emitting the right register

* Assume INS_OPTS_NONE and INS_OPTS_LSL are 64bit when displaying an extended register

2 years agoUse wildcards for NativeAOT libs (#62820)
Michal Strehovský [Wed, 15 Dec 2021 03:44:07 +0000 (12:44 +0900)]
Use wildcards for NativeAOT libs (#62820)

2 years agoBring over NativeAOT smoke tests (#62763)
Michal Strehovský [Wed, 15 Dec 2021 03:42:35 +0000 (12:42 +0900)]
Bring over NativeAOT smoke tests (#62763)

We'll probably want to spread these out to the appropriate categories (CoreMangLib, etc.) and enable them for non-NativeAOT scenarios eventually. For now, moving these as they were in runtimelab because being able to build them as a subtree (`build.sh tree nativeaot`) in one go makes things easy.

2 years agoRevert removal of clr dependency from mono builds (#62788)
Nathan Ricci [Wed, 15 Dec 2021 01:51:09 +0000 (20:51 -0500)]
Revert removal of clr dependency from mono builds (#62788)

This partially reverts this change: https://github.com/dotnet/runtime/pull/62652

The problem is that although we no longer need to patch, we do need corerun from the clr.hosts subset. Corerun still ends up as part of the pubished clr product artifact, and not in the mono product artifact. And thus we still end up downloading clr, and still need this dependency for now.

2 years ago[mono] Fix types for arguments to printf calls (#62796)
Alexander Köplinger [Wed, 15 Dec 2021 01:49:39 +0000 (02:49 +0100)]
[mono] Fix types for arguments to printf calls (#62796)

* [mono] Fix types for arguments to printf calls

   These came up while I was using a code scanning tool.

* Fix build

2 years agoIL cleanup - remove .module and make .assembly match source name (#62812)
Tomáš Rylek [Wed, 15 Dec 2021 01:15:25 +0000 (02:15 +0100)]
IL cleanup - remove .module and make .assembly match source name (#62812)

2 years agoAdd SchemeHttp index to QPACK constants (#62800)
github-actions[bot] [Wed, 15 Dec 2021 00:01:51 +0000 (13:01 +1300)]
Add SchemeHttp index to QPACK constants (#62800)

Co-authored-by: JamesNK <JamesNK@users.noreply.github.com>
2 years agoFix __SkipRestorePackages setup for msbuild (#62583)
Gleb Balykov [Tue, 14 Dec 2021 23:54:00 +0000 (02:54 +0300)]
Fix __SkipRestorePackages setup for msbuild (#62583)

2 years agoBuild NativeAOT flavor of clrcompression static lib (#62570)
Michal Strehovský [Tue, 14 Dec 2021 23:43:21 +0000 (08:43 +0900)]
Build NativeAOT flavor of clrcompression static lib (#62570)

This is similar in spirit to the static library for the single file host.

The main different from the single file host one is that we don't want `/GL` because the static library is going to be linked on end user machine and `/GL` is super version fragile.

We build two flavors - with control flow guard and without control flow guard. CFG is a compile time option for end users in NativeAOT and we need static libs that support both.

2 years agoFix named mutex PAL test issue (#62655)
Jan Vorlicek [Tue, 14 Dec 2021 23:39:42 +0000 (00:39 +0100)]
Fix named mutex PAL test issue (#62655)

The issue seems to be caused by a bug in the test. The problematic call
to `TestCreateMutex` is passed `nullptr` as the `name` parameter. It
then calls `convert` helper on it to convert it to wide char. However,
the `convert` helper doesn't check whether it is `nullptr` or not and
ends up returning a pointer to a memory with possibly random data,
that is returned by `malloc(0)`. The returned pointer is then passed to
the CreateMutex PAL api that probably ends up attempting to get the
length of the name or something. And depending on the random data, it
sometimes fails.

The fix is to change the `convert` function to handle `nullptr` so that
it returns `nullptr` too.

2 years agoDisable HardwareIntrinsics Pause tests (#62793)
Bruce Forstall [Tue, 14 Dec 2021 23:27:59 +0000 (15:27 -0800)]
Disable HardwareIntrinsics Pause tests (#62793)

Tracking: #62423

2 years agoFixing regression for AuthType.Anonymous which leads to a NullReferenceException...
Jose Perez Rodriguez [Tue, 14 Dec 2021 23:25:55 +0000 (15:25 -0800)]
Fixing regression for AuthType.Anonymous  which leads to a NullReferenceException be thrown. (#62807)

2 years agoDeduplicate JIT/Methodical/Boxing/xlang tests (#62753)
Tomáš Rylek [Tue, 14 Dec 2021 21:40:58 +0000 (22:40 +0100)]
Deduplicate JIT/Methodical/Boxing/xlang tests (#62753)

This group comprises a C# & IL main module and a C# & IL library
and tries all four pairings between them. The C# version of the
main module used to be shared but that's problematic with test
merging as distinguishing the two tests with an identical
namespace, class name and entry point would be hard. As this is
the only occurrence of this pattern in the runtime test source
tree, I'm proposing to duplicate the C# main module source and
adjust it for the two scenarios (targeting C# vs. IL version
of the dependent library).

Thanks

Tomas

2 years agoJIT: Fix range checks for "i >= 0 && i < cns" patterns (#61569)
Egor Bogatov [Tue, 14 Dec 2021 21:17:56 +0000 (00:17 +0300)]
JIT: Fix range checks for "i >= 0 && i < cns" patterns (#61569)

2 years ago[main] Update dependencies from 7 repositories (#62718)
dotnet-maestro[bot] [Tue, 14 Dec 2021 20:11:14 +0000 (21:11 +0100)]
[main] Update dependencies from 7 repositories (#62718)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
2 years agoFix named mutexes on OSX to work between arm64 and emulated x64 processes (#62764)
Koundinya Veluri [Tue, 14 Dec 2021 19:32:53 +0000 (11:32 -0800)]
Fix named mutexes on OSX to work between arm64 and emulated x64 processes (#62764)

- The page size is different between arm64 processes and emulated x64 processes
- The shared memory file size is set to the page size and there was a strict check on the file size, leading to an exception from the second process of a different arch that tries to share the same mutex
- Made the file size check less strict, and allowed an arch to increase but not decrease the file size such that it can be mapped at page size granularity
- Fix for https://github.com/dotnet/runtime/issues/62140 in main

2 years agoRename IHttpHeadersHandler to IHttpStreamHeadersHandler (#62750)
github-actions[bot] [Tue, 14 Dec 2021 18:48:18 +0000 (07:48 +1300)]
Rename IHttpHeadersHandler to IHttpStreamHeadersHandler (#62750)

Co-authored-by: James Newton-King <james@newtonking.com>
2 years agoRemove dummy project property IlasmRoundTrip (#62678)
Tomáš Rylek [Tue, 14 Dec 2021 18:41:07 +0000 (19:41 +0100)]
Remove dummy project property IlasmRoundTrip (#62678)

I have identified 63 tests in the tree that set IlasmRoundTrip
to true in their MSBuild project scripts. I haven't found any place
in the scripts that would be looking at the value so I'm guessing
it may have been a predecessor to today property
IlasmRoundTripIncompatible and I'm proposing to delete the unused
property. Please let me know if you're aware of any test script logic
that queries it.

Thanks

Tomas

2 years agoUnify native file name props (#62724)
Adeel Mujahid [Tue, 14 Dec 2021 18:31:19 +0000 (20:31 +0200)]
Unify native file name props (#62724)

The top level `Directory.Build.props` imports eng/native/naming.props,
which defines platform specific naming conventions. Use that in places
where locally defined props are used and delete the redundant props.

2 years agoPE loader/image cleanups. No-copy mapping of R2R PEs on Windows. (#61938)
Vladimir Sadov [Tue, 14 Dec 2021 18:23:57 +0000 (10:23 -0800)]
PE loader/image cleanups. No-copy mapping of R2R PEs on Windows. (#61938)

* removed IMAGE_MAPPED

* removed RawImageLayout

* delete MappedImageLayout

* use mem-mapping on Windows

* tweaks and touchups

* a few cleanups

* comments

* move EnsureLoaded into Assemby::Init

* A fix for IsDynamic() case.

* fix for preferred base, if used.

* disable failing scenario

* PR feedback

* Typo (CENTINEL --> SENTINEL)

* added a bug link to a disabled test scenario + couple comment tweaks

2 years ago[wasm] Make typescript and rollup build incremental (#62772)
Pavel Savara [Tue, 14 Dec 2021 17:30:23 +0000 (18:30 +0100)]
[wasm] Make typescript and rollup build incremental (#62772)

- eliminate slow ArgsMarshalString
- make rollup build incremental
- exclude dotnet.d.ts from typescript inputs

2 years agoRemove AOT warnings for S.Drawing.Common (#61567)
Andrii Kurdiumov [Tue, 14 Dec 2021 17:21:50 +0000 (23:21 +0600)]
Remove AOT warnings for S.Drawing.Common (#61567)

* Remove AOT warnings for S.Drawing.Common
- `Marshal.SizeOf(Type)` replaced with `Marshal.SizeOt<T>()`
- `Marshal.PtrToStructure(IntrPtr, Type)` replaced with `Marshal.PtrToStructure<T>(IntPtr)`

* Use pointers where possible

* Ref return PRINTDLG

* Use GeneratedDllImport

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years ago[wasm][debugger] Avoiding assert on mono runtime (#62601)
Thays Grazia [Tue, 14 Dec 2021 16:40:08 +0000 (13:40 -0300)]
[wasm][debugger] Avoiding assert on mono runtime (#62601)

* Avoiding assert on mono runtime

* Update src/mono/wasm/debugger/BrowserDebugProxy/DebugStore.cs

Co-authored-by: Ankit Jain <radical@gmail.com>
* Addressing @radical comments.
Removing unused fields in another test case.

Co-authored-by: Ankit Jain <radical@gmail.com>
2 years agointroduce automation rules aiding PR workflows (#62534)
Eirik Tsarpalis [Tue, 14 Dec 2021 16:27:28 +0000 (18:27 +0200)]
introduce automation rules aiding PR workflows (#62534)

2 years ago[tests] Re-enable some explicit layout tests on Mono (#62746)
Aleksey Kliger (λgeek) [Tue, 14 Dec 2021 15:13:01 +0000 (10:13 -0500)]
[tests] Re-enable some explicit layout tests on Mono (#62746)

* [tests] Re-enable some explicit layout tests on Mono

   These were fixed by https://github.com/dotnet/runtime/pull/61467

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

* objref and non-objref overlap tests expected to fail AOT compilation

   As well as the NestedStructs tests.

   Resolves https://github.com/dotnet/runtime/issues/62567

2 years agoUse TempFile in SendPacketsAsync tests (#62726)
Anton Firszov [Tue, 14 Dec 2021 14:38:49 +0000 (15:38 +0100)]
Use TempFile in SendPacketsAsync tests (#62726)

2 years ago[wasm] Fix imports: require, exit, quit (#62712)
Pavel Savara [Tue, 14 Dec 2021 11:47:08 +0000 (12:47 +0100)]
[wasm] Fix imports: require, exit, quit (#62712)

- fix require, just capture require on top level, replace it later
- simplify exit, quit
- whitespace in *.lib.*

2 years agoRemoving trailing dot from a SNI host in TLS (#62540)
Katya Sokolova [Tue, 14 Dec 2021 09:58:41 +0000 (10:58 +0100)]
Removing trailing dot from a SNI host in TLS (#62540)

* Removing trailing dot from a SNI host in TLS

* Add SSL connection scenario for FQDN with trailing dot

* Removing http layer test for FQDN with trailing dot

* Removing null-forgiving for TargetHost

2 years agoAdd support for NativeAOT testing (#62704)
Michal Strehovský [Tue, 14 Dec 2021 08:01:03 +0000 (17:01 +0900)]
Add support for NativeAOT testing (#62704)

Adds support for running runtime tests in NativeAOT configuration. It's similar to crossgen2 testing, but there's small differences.

* A layout for the AOT compiler is generated into `CORE_ROOT`. This includes the AOT compiler, NativeAOT corelib, and framework/test dependencies we otherwise dump into `CORE_ROOT`.
* The test execution script is amended to first AOT compile the test using the AOT compiler in `CORE_ROOT` and then run the AOT compiled test.
* The test is compiled by running MSBuild on a generated project file. This is different from crossgen2 testing that directly invokes crossgen2. The extra project file is annoying, but also the NativeAOT compiler has more command line arguments and we also need to invoke the platform linker with another set of command line arguments. Having MSBuild do that for us (using the shipping .target/.props that ship with NativeAOT) saves a some trouble there.
* This also includes support for multimodule testing (where each managed .dll is compiled into a single .o/.obj that we link with the native linker). This needs an extra step during test build to precompile the entire framework into a .a/.lib file.

2 years agoGeneralize loop pre-header creation and loop hoisting (#62560)
Bruce Forstall [Tue, 14 Dec 2021 07:02:51 +0000 (23:02 -0800)]
Generalize loop pre-header creation and loop hoisting (#62560)

* Generalize loop pre-header creation and loop hoisting

A loop pre-header is a block that flows directly (and only) to the loop entry
block. The loop pre-header is the only non-loop predecessor of the entry block.
Loop invariant code can be hoisted to the loop pre-header where it is
guaranteed to be executed just once (per loop entry).

Currently, a loop pre-header has a number of restrictions:
- it is only created for a "do-while" (top entry) loop, not for a mid-loop entry.
- it isn't created if the current loop head and the loop entry block are in
different EH try regions

Additionally, partially due those restrictions, loop hoisting has restrictions:
- it requires a "do-while" (top entry) loop
- it requires the existing `head` block to dominate the loop entry block
- it requires the existing `head` block to be in the same EH region as the entry block
- it won't hoist if the `entry` block is the first block of a handler

This change removes all these restrictions.

Previously, even if we did create a pre-header, the definition of a pre-header
was a little weaker: an entry predecessor could be a non-loop block and also
not the pre-header, if the predecessor was dominated by the entry block. This
is more complicated to reason about, so I change the pre-header creation to
force entry block non-loop predecessors to branch to the pre-header instead.
This case only rarely occurs, when we have what looks like an outer loop back
edge but the natural loop recognition package doesn't recognize it as an outer loop.

I added a "stress mode" to always create a loop pre-header immediately after
loop recognition. This is disabled currently because loop cloning doesn't
respect the special status and invariants of a pre-header, and so inserts
all the cloning conditions and copied blocks after the pre-header, triggering
new loop structure asserts. This should be improved in the future.

A lot more checking of the loop table and loop annotations on blocks has been
added. This revealed a number of problems with loop unrolling leaving things
in a bad state for downstream phases. Loop unrolling has been updated to fix
this, in particular, the loop table is rebuilt if it is detected that we unroll
a loop that contains nested loops, since there will now be multiple copies of
those nested loops. This is the first case where we might rebuild the loop
table, so it lays the groundwork for potentially rebuilding the loop table in
other cases, such as after loop cloning where we don't add the "slow path"
loops to the table.

There is some code refactoring to simplify the "find loops" code as well.

Some change details:
- `optSetBlockWeights` is elevated to a "phase" that runs prior to loop recognition.
- LoopFlags is simplified:
- LPFLG_DO_WHILE is removed; call `lpIsTopEntry` instead
- LPFLG_ONE_EXIT is removed; check `lpExitCnt == 1` instead
- LPFLG_HOISTABLE is removed (there are no restrictions anymore)
- LPFLG_CONST is removed: check `lpFlags & (LPFLG_CONST_INIT | LPFLG_CONST_LIMIT) == (LPFLG_CONST_INIT | LPFLG_CONST_LIMIT)` instead (only used in one place
- bool lpContainsCall is removed and replaced by LPFLG_CONTAINS_CALL
- Added a `lpInitBlock` field to the loop table. For constant and variable
initialization loops, code assumed that these expressions existed in the
`head` block. This isn't true anymore if we insert a pre-header block.
So, capture the block where these actually exist when we determine that
they do exist, and explicitly use this block pointer where needed.
- Added `fgComputeReturnBlocks()` to extract this code out of `fgComputeReachability` into a function
- Added `optFindAndScaleGeneralLoopBlocks()` to extract this out of loop recognition to its own function.
- Added `optResetLoopInfo()` to reset the loop table and block annotations related to loops
- Added `fgDebugCheckBBNumIncreasing()` to allow asserting that the bbNum
order of blocks is increasing. This should be used in phases that depend
on this order to do bbNum comparisons.
- Add a lot more loop table validation in `fgDebugCheckLoopTable()`

* Inline fgBuildBlockNumMap to allow using _alloca

* Fix BBJ_SWITCH output

1. Change `dspSuccs()` to not call code that will call `GetDescriptorForSwitch()`
2. Change `GetDescriptorForSwitch()` to use the correct max block number while
inlining. We probably don't or shouldn't call GetDescriptorForSwitch while inlining,
especially after (1), but this change doesn't hurt.

* Remove incorrect assertion

There was an assertion when considering an existing `head` block as
a potential pre-header, that the `entry` block have the `head`
block as a predecessor. However, we early exit if we find a non-head,
non-loop edge. This could happen before we encounter the `head` block,
making the assert incorrect. We don't want to run the entire loop just
for the purpose of the assert (at least not here), so just remove the
assert.

* Formatting

* Use `_alloca` instead of `alloca` name

* Convert fgBBNumMax usage

Change:
```
compIsForInlining() ? impInlineInfo->InlinerCompiler->fgBBNumMax : fgBBNumMax
```
to:
```
impInlineRoot()->fgBBNumMax
```

* Code review feedback

1. Added loop epoch concept. Currently set but never checked.
2. Added disabled assert about return blocks always being moved
out of line of loop body.
3. Fixed bug checking `totalIter` after it was decremented to zero
as a loop variable
4. Added more comments on incremental loop block `bbNatLoopNum`
setting.

* Add EH condition when converting head to pre-header

When considering converting an existing loop `head` block to a pre-header,
verify that the block has the same EH try region that we would create
for a new pre-header. If not, we go ahead and create the new pre-header.

2 years agoRename 'excludemonofailures' to 'mono' (#62749)
Tomáš Rylek [Tue, 14 Dec 2021 06:38:55 +0000 (07:38 +0100)]
Rename 'excludemonofailures' to 'mono' (#62749)

2 years agoAdd NativeAOT to build (#62569)
Michal Strehovský [Tue, 14 Dec 2021 05:23:32 +0000 (14:23 +0900)]
Add NativeAOT to build (#62569)

2 years agoAdd more precise descriptor for RuntimeAssembly (#62737)
Marek Safar [Tue, 14 Dec 2021 00:54:03 +0000 (01:54 +0100)]
Add more precise descriptor for RuntimeAssembly (#62737)

to remove more unused fields

2 years agoMade mono runs stop depending on coreclr, and stop using patching. (#62652)
Nathan Ricci [Tue, 14 Dec 2021 00:22:36 +0000 (19:22 -0500)]
Made mono runs stop depending on coreclr, and stop using patching. (#62652)

2 years agoAdd explicit null-check for tailcalls to VSD (#62719)
Jakob Botsch Nielsen [Tue, 14 Dec 2021 00:15:34 +0000 (01:15 +0100)]
Add explicit null-check for tailcalls to VSD (#62719)

There is already a comment that this is necessary, but it is only being
done for x86 tailcalls via jit helper. Do it for normal tailcalls to VSD
as well.

Fix #61486

2 years agoDo not perform vector save/restore around call that will never return (#62662)
Kunal Pathak [Mon, 13 Dec 2021 23:29:53 +0000 (15:29 -0800)]
Do not perform vector save/restore around call that will never return (#62662)

* Do not perform vector save/restore around call that will never return

* First check if tree is a call

* Use the IsNoReturn() method

2 years agoUnify naming style of dbg / rel-variant JIT projects (#62710)
Tomáš Rylek [Mon, 13 Dec 2021 23:19:25 +0000 (00:19 +0100)]
Unify naming style of dbg / rel-variant JIT projects (#62710)

Most JIT test projects use the _d, _do, _r and _ro name suffixes
to denote debug vs. non-debug ('release') and non-optimized vs.
optimized runs of the tests, however a smaller number of tests
use a different notation using the prefixes _dbg, _speed_dbg,
_rel and _speed_rel. I propose renaming these projects to
match the suffixes other test projects are using.

Thanks

Tomas

2 years agoFix SC tests (#62698)
Dan Moseley [Mon, 13 Dec 2021 20:20:48 +0000 (13:20 -0700)]
Fix SC tests (#62698)

2 years agoDo not promote struct locals with holes (#62645)
Kunal Pathak [Mon, 13 Dec 2021 18:35:57 +0000 (10:35 -0800)]
Do not promote struct locals with holes (#62645)

* Make sure the combined field size matches the struct size

* Fix the condition

* Update test and include containHoles condition

2 years agoEnable building StressLogAnalyzer for Alpine (#62703)
Andrew Au [Mon, 13 Dec 2021 18:05:58 +0000 (10:05 -0800)]
Enable building StressLogAnalyzer for Alpine (#62703)