platform/upstream/dotnet/runtime.git
3 years agoSome cleanup around PInvokeStaticSigInfo (#52232)
Elinor Fung [Wed, 5 May 2021 17:31:47 +0000 (10:31 -0700)]
Some cleanup around PInvokeStaticSigInfo (#52232)

3 years agoMove Logging Generator and attribute to Logging.Abstractions (#52256)
Maryam Ariyan [Wed, 5 May 2021 15:57:28 +0000 (11:57 -0400)]
Move Logging Generator and attribute to Logging.Abstractions (#52256)

* Move Logging Generator and LoggerMessageAttribute to Logging.Abstractions

Fixes: #52222

3 years ago[debugger][mono] Run icordbg tests on android (#52127)
Thays Grazia [Wed, 5 May 2021 14:37:50 +0000 (11:37 -0300)]
[debugger][mono] Run icordbg tests on android (#52127)

Run icordbg debuggert tests on android

3 years agoAdd entries to the glossary (#52291)
Hadrian Tang [Wed, 5 May 2021 14:26:35 +0000 (22:26 +0800)]
Add entries to the glossary (#52291)

3 years ago[wasm] Move EnableAggressiveTrimming build to `runtime` pipeline (#52252)
Ankit Jain [Wed, 5 May 2021 13:58:59 +0000 (09:58 -0400)]
[wasm] Move EnableAggressiveTrimming build to `runtime` pipeline (#52252)

.. from runtime-staging, so any changes that break that can be caught,
and fixed. Any test failures in runtime-staging don't fail the job
itself, so it gets missed.

3 years agoAdd support to disable default diagnostic server listener. (#52184)
Johan Lorensson [Wed, 5 May 2021 13:56:10 +0000 (15:56 +0200)]
Add support to disable default diagnostic server listener. (#52184)

3 years ago[tests] Fix integer rounding error in GetTestFileName (#52266)
Mitchell Hwang [Wed, 5 May 2021 13:46:17 +0000 (09:46 -0400)]
[tests] Fix integer rounding error in GetTestFileName (#52266)

* [tests] Fix integer rounding error in GetTestFileName

* Update src/libraries/Common/tests/TestUtilities/System/IO/FileCleanupTestBase.cs

* Update src/libraries/Common/tests/TestUtilities/System/IO/FileCleanupTestBase.cs

Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
Co-authored-by: Dan Moseley <danmose@microsoft.com>
3 years agoDont throw exception in SerialStream constructor if dtr or rts is not available ...
Stephan van Leeuwen [Wed, 5 May 2021 13:35:52 +0000 (15:35 +0200)]
Dont throw exception in SerialStream constructor if dtr or rts is not available (#48577)

* Dont throw exception in SerialStream constructor

Dont throw IOException in SerialStream constructor when using a virtual port on
linux.
Setting DtrEnable or RtsEnable are not possible due to the termios commands not
implemented by socat sockets. This fix ensures no exception is thrown in the
constructor when we didn't even set the dtrEnable or rtsEnable parameters
explicitly and allows the usage of SerialStream with those virtual ports.

* Remove unused variables

* Only swallow the exception if it is set to false

3 years agoRelease GCHandle in FSEventStreamContext release callback (#52275)
Jan Kotas [Wed, 5 May 2021 13:28:58 +0000 (06:28 -0700)]
Release GCHandle in FSEventStreamContext release callback (#52275)

The callbacks are sometimes delivered even after the FSEventStream is disposed

3 years agoHkdf check output length (#52260)
Daniel Hix [Wed, 5 May 2021 13:23:25 +0000 (08:23 -0500)]
Hkdf check output length (#52260)

* Add tests to check for output legnth and outputLength size

* Change Expand and DeriveKey to check the output size

* PR change requests

* Add newline back

* XML tidying, and swapped the exception text and type

* Some more exception xml cleanup

* Combined exception text, and updated tests

3 years agoTrim unnecessary AssemblyMetadataAttribute attributes (#50903)
Marek Safar [Wed, 5 May 2021 09:55:12 +0000 (11:55 +0200)]
Trim unnecessary AssemblyMetadataAttribute attributes (#50903)

* Trim unnecessary AssemblyMetadataAttribute attributes

* Feedback

3 years agoPrepare JIT backend for structs in registers. (#52039)
Sergey Andreenko [Wed, 5 May 2021 08:33:25 +0000 (01:33 -0700)]
Prepare JIT backend for structs in registers. (#52039)

* Prepare backend for structs in registers.

* restore an old assert about normalizeOnStore

* Add `GetActualRegisterType`.

* improve siVarLoc logic.

* Bruce's suggestion.

3 years agoRemove two dead props (#52263)
Viktor Hofer [Wed, 5 May 2021 06:58:01 +0000 (08:58 +0200)]
Remove two dead props (#52263)

* Remove two dead props

* Update Versions.props

3 years agoDelete Microsoft.NETCore.Targets package (#52261)
Viktor Hofer [Wed, 5 May 2021 06:56:29 +0000 (08:56 +0200)]
Delete Microsoft.NETCore.Targets package (#52261)

That package was needed in the 1.x timeframe and later in 2.x brought
back to trim out 1.x runtime references. As the live version of that
package isn't directly referenced anymore by any component in at least
the dotnet org. Source build has a checked in state so that the
dependent packages in 2.x can still build with it.

3 years agoFix crash in mono_resolve_patch_target_ext when method is NULL. (#52243)
Johan Lorensson [Wed, 5 May 2021 06:44:10 +0000 (08:44 +0200)]
Fix crash in mono_resolve_patch_target_ext when method is NULL. (#52243)

3 years agoDon't run "reserved device names" tests on Win10 (#52282)
Levi Broderick [Wed, 5 May 2021 05:14:04 +0000 (22:14 -0700)]
Don't run "reserved device names" tests on Win10 (#52282)

3 years agoFixes issue #51612 (#52231)
Egor Chesakov [Wed, 5 May 2021 03:17:57 +0000 (20:17 -0700)]
Fixes issue #51612 (#52231)

* Add regression test for https://github.com/dotnet/runtime/issues/51612

* Allocate a dummy local when an inlinee needs GSCookie but the root method does not in src/coreclr/jit/fginline.cpp

3 years agoAdd CopyToAsync optimized implementations for StreamPipeReader (#52159)
Emmanuel André [Wed, 5 May 2021 03:04:16 +0000 (05:04 +0200)]
Add CopyToAsync optimized implementations for StreamPipeReader (#52159)

* Add CopyToAsync optimized implementations for StreamPipeReader

3 years ago[wasm] Fix Emscripten SDK provisioning for tests (#52273)
Ankit Jain [Wed, 5 May 2021 02:11:10 +0000 (22:11 -0400)]
[wasm] Fix Emscripten SDK provisioning for tests (#52273)

- For running on AOT tests on helix, we need to send emsdk as a payload
- On the CI machines, emscripten is available in `/usr/local/emscripten/`
- but the helix tasks try to write a `.payload` file in that dir, which fails
  because of permissions

- So, we copy emsdk to local `src/mono/wasm/emsdk`
- But we were doing it as part of *every* test build!
    - this meant unncessarily copying, and races causing errors like:

```
/__w/1/s/eng/testing/tests.wasm.targets(138,5):
    error MSB3026: Could not copy "/usr/local/emscripten/emsdk/node/14.15.5_64bit/bin/node" to "/__w/1/s/src/mono/wasm/emsdk/node/14.15.5_64bit/bin/node".

    Beginning retry 1 in 1000ms. The process cannot access the file '/__w/1/s/src/mono/wasm/emsdk/node/14.15.5_64bit/bin/node' because it is being used by another process.  [/__w/1/s/src/libraries/System.Collections.Specialized/tests/System.Collections.Specialized.Tests.csproj]
```

- Instead, do that once when preparing work items for helix

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

3 years agoFix Hosting tests in runtime-staging runs (#52265)
Eric Erhardt [Wed, 5 May 2021 01:29:18 +0000 (20:29 -0500)]
Fix Hosting tests in runtime-staging runs (#52265)

* Fix HostFactoryResolverTests to work with EnableAggressiveTrimming

* Disable hosting tests on Windows running on mono

See https://github.com/dotnet/runtime/issues/34582

3 years agoImprove SuperPMI missing data asserts (#52129)
Bruce Forstall [Tue, 4 May 2021 22:31:30 +0000 (15:31 -0700)]
Improve SuperPMI missing data asserts (#52129)

* Improve SuperPMI missing data asserts

SuperPMI has many asserts for missing data that are specially handled
to return a "missing data" error code. We typically ignore these, except
to note that a new collection might be needed. In particular, we prefer a
"missing data" error to an unidentified (caught) crash, which might indicate a JIT crash.

A recent change exposed a case where we were missing an assert, leading
to a crash. I went through all the methodcontext.cpp "rep" functions and added
appropriate asserts to all cases where they were missing.

To do this, add new `AssertMapExists`, `AssertKeyExists`, and `AssertMapAndKeyExist`
macros to make this consistent, easy, and compact, and converted all existing map and key
asserts to use these new forms.

In addition,
1. Rewrite the code to be much more regular and consistent.
2. Add many missing `DEBUG_REC` and `DEBUG_REP` cases, and fix some that were wrong.
3. Create a `key` variable almost everywhere, to avoid repeated `CastHandle` calls.
4. Simplify/commonize the `ZeroMemory` calls.
5. Remove all BOOL; use bool as appropriate.

There are no asm diffs (as expected). I verified the new asserts properly fire by using
`superpmi.py replay -jitoption JitStress=2`.

(Re-revert change, with fix)

* Fix clang compilation failures, more

clang is less permissive about empty variatic macros `__VA_ARGS__`,
so add `AssertMapExistsNoMessage`, `AssertKeyExistsNoMessage`, and
`AssertMapAndKeyExistNoMessage` for cases where we haven't bothered
to write a failure message, to avoid compiler problems. It's also more
clear in the code.

Change all the functions to explicity compute and use a `value` variable
for the key=>value map, to reduce duplicate casting, and make the code
more clear.

* clang build fix

3 years agoReduce the memory footprint of ManagedWebSocket (#52022)
Ivan Zlatanov [Tue, 4 May 2021 22:10:20 +0000 (01:10 +0300)]
Reduce the memory footprint of ManagedWebSocket (#52022)

Removed unused CancellationTokenSource. Using RandomNumberGenerator.Fill instead of custom instance of RandomNumberGenerator.

3 years agoAllow DataContractSerializer to serialize MemoryStream instances (#50830)
Levi Broderick [Tue, 4 May 2021 21:43:56 +0000 (14:43 -0700)]
Allow DataContractSerializer to serialize MemoryStream instances (#50830)

3 years agoRename S.T.J.Node namespace to S.T.J.Nodes (#52200)
Steve Harter [Tue, 4 May 2021 20:36:41 +0000 (15:36 -0500)]
Rename S.T.J.Node namespace to S.T.J.Nodes (#52200)

3 years agoupdate enterpriseTests setup (#48804)
Tomas Weinfurt [Tue, 4 May 2021 19:19:36 +0000 (12:19 -0700)]
update enterpriseTests setup (#48804)

* update enterpriseTests setup

* add ntlm & digest tests

* update README

3 years agoAdd a tag to the type declarations generated by `TYPED_HANDLE_DECL`. (#52250)
imhameed [Tue, 4 May 2021 19:10:29 +0000 (12:10 -0700)]
Add a tag to the type declarations generated by `TYPED_HANDLE_DECL`. (#52250)

Workaround for https://reviews.llvm.org/D74103.

3 years agoUnify QuicTestBase and add test repros for flaky under-stress failures (#52050)
Natalia Kondratyeva [Tue, 4 May 2021 18:51:16 +0000 (20:51 +0200)]
Unify QuicTestBase and add test repros for flaky under-stress failures (#52050)

Removed MsQuicTestBase class as it was essentially the same as QuicTestBase. Updated ActiveIssue comments with newly created issues #52047 and #52048 and added repros from them as new tests.

3 years ago[mono] Revert Mac Catalyst arm64 JITing hack (#52249)
Aleksey Kliger (λgeek) [Tue, 4 May 2021 18:32:27 +0000 (14:32 -0400)]
[mono] Revert Mac Catalyst arm64 JITing hack (#52249)

JITing in Catalyst apps is not allowed on Apple Silicon.

Partly reverts a9f1207d9f14d6bdf6e4be0f206d11df8e032382

3 years agoUpdate the SDK to 6.0 Preview 3 (#52196)
Viktor Hofer [Tue, 4 May 2021 18:29:02 +0000 (20:29 +0200)]
Update the SDK to 6.0 Preview 3 (#52196)

* Update the SDK to 6.0 Preview 3

Updating the minimum and target version of the SDK to 6.0 Preview 3.

Contributes to https://github.com/dotnet/runtime/issues/51716

* Fix Linker Trimming tests

* Fix ILLink warnings for latest SDK

- Remove ILLink.Descriptors entry for non-existant method
- Suppress ILLink warnings in mobile tests

Co-authored-by: Jose Perez Rodriguez <joperezr@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
3 years agoDownload Mono AOT workload .nupkg in prepare-artifacts.proj (#52247)
Alexander Köplinger [Tue, 4 May 2021 17:19:09 +0000 (19:19 +0200)]
Download Mono AOT workload .nupkg in prepare-artifacts.proj (#52247)

* Download Mono AOT workload .nupkg in prepare-artifacts.proj

Fixes the official build failure since the pattern we were using didn't include it.

* PR feedback

3 years agomono.proj: skip running CMake configure if the arguments didn't change (#51754)
Alexander Köplinger [Tue, 4 May 2021 16:45:45 +0000 (18:45 +0200)]
mono.proj: skip running CMake configure if the arguments didn't change (#51754)

This speeds up the incremental build. Similar to what coreclr/libraries do here: https://github.com/dotnet/runtime/blob/44ae6ca9cdf75e4892e054f9ac37deb52903b51c/eng/native/gen-buildsys.cmd#L77-L84

3 years agoUse live pkcs build instead of packagereference (#52239)
Viktor Hofer [Tue, 4 May 2021 16:40:05 +0000 (18:40 +0200)]
Use live pkcs build instead of packagereference (#52239)

3 years ago[iOS/macOS] Split S.S.C.Native.Apple into platform specific files where needed
Filip Navara [Tue, 4 May 2021 16:23:36 +0000 (18:23 +0200)]
[iOS/macOS] Split S.S.C.Native.Apple into platform specific files where needed

Instead of using #if to remove functions that don't work/make sense on iOS,
move them to a file that is conditionally included in the library compile.

3 years agoPlace HKDF info in to a temporary buffer if required.
Kevin Jones [Tue, 4 May 2021 16:11:49 +0000 (12:11 -0400)]
Place HKDF info in to a temporary buffer if required.

If the info input overlaps with the output destination, copy
the info to a temporary buffer first. As the HKDF expansion
is performed, the output buffer is filled by hash size. However
this will overwrite the info, should the buffers overlap.

The other parameters, like prk, salt, and ikm do not need any addional
handling for overlaps.

3 years agoAddress feedback from STJ source-gen PR #51300 (#52147)
Layomi Akinrinade [Tue, 4 May 2021 15:48:13 +0000 (08:48 -0700)]
Address feedback from STJ source-gen PR #51300 (#52147)

* Address feedback from STJ source-gen PR #51300

* Address review feedback

3 years agoFix issue 47805 (#52183)
Peter Sollich [Tue, 4 May 2021 15:46:32 +0000 (17:46 +0200)]
Fix issue 47805 (#52183)

Fix issue https://github.com/dotnet/runtime/issues/47805 - in this case, the BGC_MARKED_BY_FGC bit (0x2) set in the method table leaked out and caused issues for the user program.

In the cases that I've been able to repro, this happened because the bit got set for a short object right in front of a pinned plug, and then saved away by enque_pinned_plug.

Later on, in the case of mark & sweep, we check for the bit and reset it, but later we copy the saved object back by calling recover_saved_pinned_info which calls recover_plug_info to do the actual work. This isn't a problem for the compact case, because we copy the saved object back during compact_plug, turn the bit off, then save it again at the end of compact_plug.

The fix is to turn off the extra bits at the beginning of enque_pinned_plug and save_post_plug_info for the copy that is later restored in mark & sweep (there are actually two copies saved, one for use during compact and one for use during mark & sweep). This builds on an earlier fix by Maoni for a similar problem with another bit.

3 years ago[mono] Assume C99 support (#51504)
Ryan Lucia [Tue, 4 May 2021 15:10:22 +0000 (11:10 -0400)]
[mono] Assume C99 support (#51504)

We don't seem to have been setting this define properly, but we can just remove the ifdef entirely

3 years ago[wasm] Don't use EMSDK_PATH in external builds (#52215)
Larry Ewing [Tue, 4 May 2021 14:13:27 +0000 (09:13 -0500)]
[wasm] Don't use EMSDK_PATH in external builds (#52215)

* Don't use EMSDK_PATH in external builds only when in-tree

3 years agoRemove !sig->is_inflated assert from icall wrapper generator. (#52241)
monojenkins [Tue, 4 May 2021 13:37:37 +0000 (09:37 -0400)]
Remove !sig->is_inflated assert from icall wrapper generator. (#52241)

If the method or type containing the icall instruction has a
generic parameter, the resulting signature is "inflated" even if
the generic parameter is not used in the signature. This breaks
some methods in SlimDX, and probably other C++/CLI code.

<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->

Co-authored-by: madewokherd <madewokherd@users.noreply.github.com>
3 years agoDelete empty test project (#52216)
Jan Kotas [Tue, 4 May 2021 13:18:23 +0000 (06:18 -0700)]
Delete empty test project (#52216)

Fixes #52119

3 years ago[mono] LLVM 11 support (#51993)
imhameed [Tue, 4 May 2021 12:41:05 +0000 (05:41 -0700)]
[mono] LLVM 11 support (#51993)

Changes:

- `CallSite` was removed. Add attributes to call/invoke instructions by using a
coercion to `CallBase` instead.

- `llvm/InitializePasses.h` must be included to get the prototypes for
`llvm::initializeCore` etc.

- Intrinsic IDs have been split into several different architecture-specific
enumeration types. These enumeration types collectively contain definitions
with non-overlapping values.  Each intrinsic in `llvm-intrinsics.h` is now
tagged with an architecture.

- `createLegacyLookupResolver` passes a `StringRef` to the lookup function. We
still call functions that demand an `std::string` (and that demand
zero-termination), so it is necessary to copy the `StringRef` bytes into a new
`std::string`.

- Alignment values are wrapped in what is effectively a newtype: `llvm::Align`.

- `llvm.prefetch` is overloaded in its first parameter LLVM 10 and above.

- Values of type `llvm::Align` must be non-zero. Sometimes 0 is passed to
`mono_llvm_build_alloca`; handle this by falling back to `CreateAlloca`, which
computes a default alignment based on the type of the alloca.

Some notes on LLVM 11:

- `createDefCfa` and `createDefCfaOffset` were replaced with `cfiDefCfa` and
`cfiDefCfaOffset`. Neither negates the offset parameter. All calling code was
adjusted to compensate. See
https://github.com/llvm/llvm-project/commit/7e49dc6184ef3baf421a5bb0190466cbb1a87785
and
https://github.com/llvm/llvm-project/commit/0840d725c4e7c98bb440db7b886054525be6ddf1.

- The non-Mono DWARF emitter used to unnecessarily negate the offsets for
`DW_CFA_def_cfa` and `DW_CFA_def_cfa_offset` directives. This has since been
fixed in
https://github.com/llvm/llvm-project/commit/773f8dbd1da8409f1b62e8c5692cb9a5d199d6c8
and
https://github.com/llvm/llvm-project/commit/c693b9c321d5a40d012340619674cf790c9ac86c.

- `AsmPrinter::emitAlignment` no longer takes the base-2 logarithm of the
desired alignment--it directly accepts a power of two alignment now. This is
checked dynamically by `llvm::Align`.

3 years ago[interp] Optimize conditional branches (#52130)
Vlad Brezae [Tue, 4 May 2021 12:03:57 +0000 (15:03 +0300)]
[interp] Optimize conditional branches (#52130)

* [interp] Try emitting ldc_0 instead of initlocal if possible

Unlike initlocal ldc_0 are propagated, also having smaller instruction footprint. Signal retry of cprop when we are adding such instructions, also in other cases. We could dynamically update the state, but let's not overcomplicate the cprop pass, for now.

* [interp] Also update def_index when swapping dreg

* [interp] Refactor special static field access

On netcore, there are no context static fields so all special static fields are thread static. These thread static accessors are not very common, so just remove redundant opcodes for them, and use ldind/ldobj.vt and stind/stobj.vt instead.

* [interp] Remove MINT_LDFLD_VT_* opcodes

These opcodes were used for loading a field of a VT var. This means the opcodes were loading a value from an immediate offset added to a var offset. We can use the standard MINT_MOV opcodes for this, however we need to resolve the offsets at the very end, so it doesn't interfere with other compilation passes, since the final offset is not the real offset of a variable, but rather an offset inside a VT var.

* [interp] Remove MINT_CHECKPOINT opcode

It was used to check for abort requests during backward branches. Also stop checking for abort requests in other places.

* [interp] Add super instructions for conditional branches

We include the safepoint in the instruction and also the immediate comparison value if possible. Doing the safepoint by default in branching opcodes is questionable since, in a typical program, forward branches are far more common than backward branches.

We should really remove many of the branching opcodes. We now have the possibility to swap the src vars order, and use the opposite comparison instead.

3 years agoUpdate dependencies from https://github.com/mono/linker build 20210503.3 (#52238)
dotnet-maestro[bot] [Tue, 4 May 2021 11:48:05 +0000 (11:48 +0000)]
Update dependencies from https://github.com/mono/linker build 20210503.3 (#52238)

[main] Update dependencies from mono/linker

3 years agoAdd parameter descriptions (#51845)
John Call [Tue, 4 May 2021 10:57:12 +0000 (03:57 -0700)]
Add parameter descriptions (#51845)

3 years agoChanged all tests using random to use a seed in JIT/Methodical (#50767)
Daniel Hix [Tue, 4 May 2021 08:15:25 +0000 (03:15 -0500)]
Changed all tests using random to use a seed in JIT/Methodical (#50767)

* Changed all tests using random to use a seed in JIT/Methodical

* Cleaned up code from suggestion

* Added seeds to the tests using unseeded random in JIT

* Update Span indexer to not rely on the order of random data

* Change circle in convex to not rely on specific random values

* Undo changes to tests with seed specified

3 years agoStop harvesting S.Security.Cryptography.Pkcs (#52045)
Viktor Hofer [Tue, 4 May 2021 06:03:46 +0000 (08:03 +0200)]
Stop harvesting S.Security.Cryptography.Pkcs (#52045)

* Stop harvesting S.Sec.Cryptography.Pkcs

The removed configurations (netstandard1.3, netcoreapp2.1, net46)
of the touched packages aren't built anymore. Instead
the already built matching binaries from the latest available packages
are redistributed when packaging these libraries.

Dropping these assets as the minimum supported set of platforms are ones
that support netstandard2.0 and are still in-support. As an example,
also dropping the netcoreapp2.1 asset which isn't supported anymore and
adding a target to prevent the package being used for netcoreapp2.x.
For .NET Framework, there's still a net461
configuration present to avoid binding redirect issues.

Contributes to #47530

* Fix the build

* Remove workaround and mark Xamarin supported

3 years agoDispose of hash handles for Windows 7. (#52213)
Kevin Jones [Tue, 4 May 2021 03:44:28 +0000 (23:44 -0400)]
Dispose of hash handles for Windows 7. (#52213)

The handle will never be null, it will be an owned handle that points
to nothing. Dispose of it so it doesn't need to get finalized.

3 years ago[aot] Avoid associating the same AOT image with multiple assemblies (#52181)
Zoltan Varga [Tue, 4 May 2021 02:25:40 +0000 (22:25 -0400)]
[aot] Avoid associating the same AOT image with multiple assemblies (#52181)

loaded in different ALCs.

This caused crashes in the generic sharing code on wasm.

3 years agoFix incorrect quoting (#52219)
Larry Ewing [Tue, 4 May 2021 01:12:06 +0000 (20:12 -0500)]
Fix incorrect quoting (#52219)

3 years agoRemove unreachable code (#52207)
Fan Yang [Tue, 4 May 2021 00:43:43 +0000 (20:43 -0400)]
Remove unreachable code (#52207)

* Remove unreached code

* Remove all the remaining reference to reflectionOly

3 years agoGenerate coredumps on signals (#52024)
Mike McLaughlin [Tue, 4 May 2021 00:31:40 +0000 (17:31 -0700)]
Generate coredumps on signals (#52024)

Generate coredumps on signals

On MacOS, coredumps are generated if there is an unhandled managed exception
but signals don't generate them.

Enable a stripped down version of the Linux signal handlers for MacOS.

Add a SIGABRT handler so calls to abort() in other native code causes dump to be generated.

Add COMPlus_EnableDumpOnSigTerm that enables dump generation on SIGTERM.

Moved the "generate dump on SIGTERM" logic out of the PAL into runtime's
HandleTerminationRequest callback and passed a new SCA enum down to
SafeExitProcess that calls TerminateProcess instead of ExitProcess
which generates a core dump.

3 years agoApple Silicon use default XCode version (#52214)
Steve MacLean [Mon, 3 May 2021 23:48:24 +0000 (19:48 -0400)]
Apple Silicon use default XCode version (#52214)

Current default for vmImage 10.15 is XCode 12.4

Remove pin to Xcode 12.2 for Apple Silicon

3 years agoUse data keys on macOS for RSA, EC cryptography
Filip Navara [Mon, 3 May 2021 22:10:04 +0000 (00:10 +0200)]
Use data keys on macOS for RSA, EC cryptography

3 years agoCompile Microsoft.Extensions.HostFactoryResolver test file (#52194)
Eric Erhardt [Mon, 3 May 2021 21:48:03 +0000 (16:48 -0500)]
Compile Microsoft.Extensions.HostFactoryResolver test file (#52194)

Fix #52118

3 years ago[interp] Remove abort protection of finally blocks (#51309)
Vlad Brezae [Mon, 3 May 2021 21:45:18 +0000 (00:45 +0300)]
[interp] Remove abort protection of finally blocks (#51309)

3 years ago[mono] Update wasm debugging docs. (#52211)
Zoltan Varga [Mon, 3 May 2021 20:25:13 +0000 (16:25 -0400)]
[mono] Update wasm debugging docs. (#52211)

3 years ago[wasm] Use '/' directory separator in .blat (#52066)
Radek Doulik [Mon, 3 May 2021 19:21:40 +0000 (21:21 +0200)]
[wasm] Use '/' directory separator in .blat (#52066)

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

We were using host system `PathSeparator`s, which lead to problems when
building the app on windows.

This change makes the `System.Runtime` library tests pass on windows.

3 years agouse AssertExtensions.SequenceEqual in a few places (#52054)
Geoff Kizer [Mon, 3 May 2021 18:23:28 +0000 (11:23 -0700)]
use AssertExtensions.SequenceEqual in a few places (#52054)

Co-authored-by: Geoffrey Kizer <geoffrek@windows.microsoft.com>
3 years agoMono toolchain workload (#51327)
Steve Pfister [Mon, 3 May 2021 17:53:23 +0000 (13:53 -0400)]
Mono toolchain workload (#51327)

First pass at a more comprehensive mono workload that includes wasm, the aot compilers, and the runtime config task.

Co-authored-by: Steve Pfister <steve.pfister@microsoft.com>
Co-authored-by: Larry Ewing <lewing@microsoft.com>
3 years agoAdd JsonObject\JsonArray XML doc and tests regarding thread safety (#52010)
Steve Harter [Mon, 3 May 2021 17:33:15 +0000 (12:33 -0500)]
Add JsonObject\JsonArray XML doc and tests regarding thread safety (#52010)

3 years ago[main] Update dependencies from mono/linker (#51921)
dotnet-maestro[bot] [Mon, 3 May 2021 17:26:09 +0000 (19:26 +0200)]
[main] Update dependencies from mono/linker (#51921)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Marek Safar <marek.safar@gmail.com>
Co-authored-by: vitek-karas <vitek.karas@microsoft.com>
3 years agoRemove unused string resources from System.Text.Json (#52005)
Steve Harter [Mon, 3 May 2021 16:03:17 +0000 (11:03 -0500)]
Remove unused string resources from System.Text.Json (#52005)

3 years agoFixed issues with caching in the wrong slot (#52168)
David Fowler [Mon, 3 May 2021 14:54:10 +0000 (07:54 -0700)]
Fixed issues with caching in the wrong slot (#52168)

* Fixed issues with caching in the wrong slot
- When using ValidateOnBuild we build the callsite for each ServiceDescriptor but using the wrong slot. This didn't matter before but it breaks service overrides.
- Run the spec tests with ValidateOnBuild set to true when it doesn't throw.

* Only catch AggregateExceptions
- Those are the ones that ValidateOnBuild throws

3 years agoUse integer division trick to get exact base64 length (#50549)
Günther Foidl [Mon, 3 May 2021 12:58:26 +0000 (14:58 +0200)]
Use integer division trick to get exact base64 length  (#50549)

* Use integer division trick to get exact base64 length and avoid modulo operation

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
3 years agoAdd option to instrument using 64-bit counts (#51625)
Jakob Botsch Nielsen [Mon, 3 May 2021 12:39:06 +0000 (14:39 +0200)]
Add option to instrument using 64-bit counts (#51625)

Add COMPlus_JitCollect64BitCounts which makes the JIT instrument using
64-bit counts instead of 32-bit counts. No support for consuming these
counts is added, only support for producing them.

I also changed the printing of relocs to include their values when
diffable disassembly is off.

3 years agoAdd a mono_static_field_get_addr () helper function. (#52185)
Zoltan Varga [Mon, 3 May 2021 12:15:07 +0000 (08:15 -0400)]
Add a mono_static_field_get_addr () helper function. (#52185)

3 years agoAdd SupportedOSPlatformGuard, UnsupportedOSPlatformGuard attributes (#52028)
Buyaa Namnan [Mon, 3 May 2021 05:55:46 +0000 (22:55 -0700)]
Add SupportedOSPlatformGuard, UnsupportedOSPlatformGuard attributes (#52028)

* Add SupportedOSPlatformGuard, UnsupportedOSPlatformGuard attributes
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
3 years agoRemove redundant enums (#52171)
Andrii Kurdiumov [Mon, 3 May 2021 04:23:07 +0000 (10:23 +0600)]
Remove redundant enums (#52171)

I cannot find any reference to these declarations in the repo
Also seems to be they have name which does not make sense.
What's purpose Int name has over SysInt and can only raise confusion with I4

3 years agoUse non-copyleft RNG implementation (#51448)
Kevin Cathcart [Sat, 1 May 2021 20:19:55 +0000 (16:19 -0400)]
Use non-copyleft RNG implementation (#51448)

Using xorshiro128** because it is already used in the project, and licensed under CC0.

3 years agoFix __NumProc setup if nproc is not available (#51002)
Gleb Balykov [Sat, 1 May 2021 18:24:00 +0000 (21:24 +0300)]
Fix __NumProc setup if nproc is not available (#51002)

3 years agoDispose of hash provider. (#52051)
Kevin Jones [Sat, 1 May 2021 17:55:59 +0000 (13:55 -0400)]
Dispose of hash provider. (#52051)

Explicitly dispose of the _lazyHashProvider so that it does not
end up in the finalization queue.

3 years agoCorrect grammar (#52151)
Steve Dunn [Sat, 1 May 2021 17:55:00 +0000 (18:55 +0100)]
Correct grammar (#52151)

3 years agoDelete the unused dummyBB variable (#52155)
SingleAccretion [Sat, 1 May 2021 17:54:34 +0000 (20:54 +0300)]
Delete the unused dummyBB variable (#52155)

3 years agoDelete functions reading integers in big-endian format (#52154)
SingleAccretion [Sat, 1 May 2021 14:05:29 +0000 (17:05 +0300)]
Delete functions reading integers in big-endian format (#52154)

3 years ago[mono] Use the proper memory manager in more places. (#52071)
Zoltan Varga [Sat, 1 May 2021 07:37:25 +0000 (03:37 -0400)]
[mono] Use the proper memory manager in more places. (#52071)

* Store reflection cache entries into the proper memory manager.

* [mono] Use the proper memory manager in more places.

3 years agoHandle null Type in GetHashCode (#52115)
Stefan [Sat, 1 May 2021 05:07:15 +0000 (07:07 +0200)]
Handle null Type in GetHashCode (#52115)

3 years agoImplemented ReadAtLeastAsync (#51979)
David Fowler [Sat, 1 May 2021 03:33:24 +0000 (20:33 -0700)]
Implemented ReadAtLeastAsync (#51979)

- Implemented the PipeReader implementation and override the method on Pipe.
- The Pipe implementation has some caveats. Calling ReadAtLeast messes with the pipe back pressure since it's trying to prevent deadlocks. This means that if ReadAsync is called with a big threshold, the writer will write as fast as it can ignoring the PauseThreshold up until the reader is unblocked. In a sense, the call to ReadAtLeast async overrides the pause threshold for that one read.
- Added tests

3 years agoSplit ComActivator into separate files for supported and not supported (#52126)
Elinor Fung [Sat, 1 May 2021 02:21:39 +0000 (19:21 -0700)]
Split ComActivator into separate files for supported and not supported (#52126)

3 years agoAssemblyName.ToString() returns an empty string for an empty `Name` property (#52080)
Bartosz Klonowski [Sat, 1 May 2021 01:05:08 +0000 (03:05 +0200)]
AssemblyName.ToString() returns an empty string for an empty `Name` property (#52080)

* Return empty FullName of AssemblyName for empty Name

The empty Name of AssemblyName does not mean that there's a FileLoad
errror so there should not be the FileLoadException thrown for that
case.
This commit modifies the behavior of FullName getter, so the ToString
will return empty string "" when the Name is set to be empty.

NOTE: The null condition is left as is, even if the conditions of null
and empty are now combined.

* Cover the empty assembly name with unit tests

* Test the AssemblyName.ToString method for empty Name

The empty name of AssemblyName needs to be tested separately so that the
ToStringTest will stay unmodified and the test scenario won't change,
but at the same time the empty string can be passed without using the
constructor.
Note that the AssemblyName constructor throws the exception when an empty
string is given as the name.

* Simplify the unit test for empty AssemblyName.Name

The simplification includes:
1. Removing the redundant test for empty FullName as it now checks the
   same case as the Name_Set_FullName Theory
2. Make the ToStringEmptyNameTest a Fact instead of Theory as there's
   only one case which can be done as an InlineData.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
3 years ago[wasm] Port additional fixes in #52078 main (#52125)
Larry Ewing [Sat, 1 May 2021 00:28:54 +0000 (19:28 -0500)]
[wasm] Port additional fixes in #52078 main (#52125)

* Port additional fixes in #52078 main

* Update src/tasks/AotCompilerTask/MonoAOTCompiler.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Update src/tasks/WasmAppBuilder/WasmAppBuilder.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Update src/tasks/WasmAppBuilder/WasmAppBuilder.csproj

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Apply suggestions from code review

Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
* Use a property for net472

* Use consistent separator character

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
Co-authored-by: Daniel Plaisted <dsplaisted@gmail.com>
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
3 years agoDisable ComDisabled tests on Mono (#52128)
Elinor Fung [Fri, 30 Apr 2021 21:47:40 +0000 (14:47 -0700)]
Disable ComDisabled tests on Mono (#52128)

3 years agoRevert "Disable regression test 49826 failing after a library refactoring (#51759...
Layomi Akinrinade [Fri, 30 Apr 2021 21:39:15 +0000 (14:39 -0700)]
Revert "Disable regression test 49826 failing after a library refactoring (#51759)" (#52123)

This reverts commit 86c113260fd7a998f01b394ef8916039dcc62ec8.

3 years agoFix building tests on Windows ARM64 (#52093)
Anton Lapounov [Fri, 30 Apr 2021 20:59:12 +0000 (13:59 -0700)]
Fix building tests on Windows ARM64 (#52093)

3 years agoAvoid dictionary lookup for singleton services (#52035)
David Fowler [Fri, 30 Apr 2021 19:46:45 +0000 (12:46 -0700)]
Avoid dictionary lookup for singleton services (#52035)

- Stash the instance on the callsite itself and avoid the resolved services lookup.
- This mainly benefits the reflection only path as the ILEmit codegen path will replace this code with an optimized delegate. This should help resolving singletons in the blazor code path and for nativeAOT.
- The other benefit is that the concurrent dictionary that was used before to store singletons will be empty in the common case.
- This change also introduces callsite caching (memoization). Today callsites are cached but only the root type (A -> B -> C), `GetService<A>` will only cache the A callsite. This change will result in caching A, B and C.

3 years agoUpdate pgo data versions, and remove excess nuget details handling old ibc data ...
David Wrighton [Fri, 30 Apr 2021 19:21:00 +0000 (12:21 -0700)]
Update pgo data versions, and remove excess nuget details handling old ibc data (#52082)

3 years agoFix unboxing handling of Method_Handles (#52060)
Manish Godse [Fri, 30 Apr 2021 17:54:48 +0000 (10:54 -0700)]
Fix unboxing handling of Method_Handles (#52060)

* Fix log to flag valuetype methods as requiring [UNBOX]

* Inline unboxing check

* check IsVirtual to flag it as unboxingStub.

* Added comments for clarity.

3 years agoImprove loop unrolling documentation (#52099)
Bruce Forstall [Fri, 30 Apr 2021 15:50:58 +0000 (08:50 -0700)]
Improve loop unrolling documentation (#52099)

Minor cleanups to loop unrolling:
1. Add header comments with documentation
2. Make jitIterSmallOverflow/jitIterSmallUnderflow private static `Compiler`
class members, and not just "loose" functions.
3. Manually loop hoist ITER_LIMIT and UNROLL_LIMIT_SZ and dependent
asserts, plus `iterLimit` setting.

Also, make `optCloneLoops` and `optUnrollLoops` return a PhaseStatus,
so for early-out cases they can return MODIFIED_NOTHING.

3 years agoRevert "Improve SuperPMI missing data asserts (#52097)" (#52111)
Jan Kotas [Fri, 30 Apr 2021 15:30:25 +0000 (08:30 -0700)]
Revert "Improve SuperPMI missing data asserts (#52097)" (#52111)

This reverts commit 7512c89d0605f9ec99a580b4d6cc5ded39d2f907.

3 years ago[mono] Pop the interpreter LMF frame if the EH code throws a C++ exception in mixed...
Zoltan Varga [Fri, 30 Apr 2021 15:00:39 +0000 (11:00 -0400)]
[mono] Pop the interpreter LMF frame if the EH code throws a C++ exception in mixed mode. (#52075)

This would cause random crashes in AOT mode on wasm since the LMF frame was still in the LMF
chain, but it was allocated on the stack.

3 years agoUpdating the JIT to recognize and handle Vector64/128/256<T> for nint/nuint (#52016)
Tanner Gooding [Fri, 30 Apr 2021 14:40:09 +0000 (07:40 -0700)]
Updating the JIT to recognize and handle Vector64/128/256<T> for nint/nuint (#52016)

* Updating the JIT to recognize and handle Vector64/128/256<T> for nint/nuint

* Update src/coreclr/jit/simd.cpp

Co-authored-by: Anton Lapounov <anton.lapounov@microsoft.com>
* Applying formatting patch

* Updating the VM to treat Vector<nint> and Vector<nuint> as vector types

Co-authored-by: Anton Lapounov <anton.lapounov@microsoft.com>
3 years ago[mono] Fix Mono's logging profiler build for mobile (#52068)
Marek Habersack [Fri, 30 Apr 2021 13:30:30 +0000 (15:30 +0200)]
[mono] Fix Mono's logging profiler build for mobile (#52068)

Enable build of the logging profiler on mobile platforms (Android, iOS
and tvOS)

Profiler code used a handful of deprecated functions which caused build
errors.  Replace the functions with local dummy implementations.

Build both static and dynamic versions of the logging profiler.

3 years agoUse function pointers in OSX FileSystemWatcher (#52090)
Jan Kotas [Fri, 30 Apr 2021 12:29:16 +0000 (05:29 -0700)]
Use function pointers in OSX FileSystemWatcher (#52090)

3 years agoincrease timeout for websocket compression tests (#52086)
Dan Moseley [Fri, 30 Apr 2021 08:12:25 +0000 (01:12 -0700)]
increase timeout for websocket compression tests (#52086)

* increase timeout for websocket compression tests
* disable for 14 and 15 on ARM

3 years agoImprove SuperPMI missing data asserts (#52097)
Bruce Forstall [Fri, 30 Apr 2021 08:02:57 +0000 (01:02 -0700)]
Improve SuperPMI missing data asserts (#52097)

SuperPMI has many asserts for missing data that are specially handled
to return a "missing data" error code. We typically ignore these, except
to note that a new collection might be needed. In particular, we prefer a
"missing data" error to an unidentified (caught) crash, which might indicate a JIT crash.

A recent change exposed a case where we were missing an assert, leading
to a crash. I went through all the methodcontext.cpp "rep" functions and added
appropriate asserts to all cases where they were missing.

To do this, add new `AssertMapExists`, `AssertKeyExists`, and `AssertMapAndKeyExist`
macros to make this consistent, easy, and compact, and converted all existing map and key
asserts to use these new forms.

In addition,
1. Rewrite the code to be much more regular and consistent.
2. Add many missing `DEBUG_REC` and `DEBUG_REP` cases, and fix some that were wrong.
3. Create a `key` variable almost everywhere, to avoid repeated `CastHandle` calls.
4. Simplify/commonize the `ZeroMemory` calls.
5. Remove all BOOL; use bool as appropriate.

There are no asm diffs (as expected). I verified the new asserts properly fire by using
`superpmi.py replay -jitoption JitStress=2`.

3 years agoRoot built-in converters in JsonSerializerOptions.GetConverter(Type) (#51897)
Layomi Akinrinade [Fri, 30 Apr 2021 04:17:27 +0000 (21:17 -0700)]
Root built-in converters in JsonSerializerOptions.GetConverter(Type) (#51897)

* Root built-in converters in JsonSerializerOptions.GetConverter(Type)

* Address review feedback

* Clean up changes

* Mark JsonSerializerOptions.GetConverter(Type) as 'requires unreferenced code'

* Address review feedback

3 years agoSystem.Runtime.InteropServices readonly annotation (#51784)
hrrrrustic [Fri, 30 Apr 2021 02:38:26 +0000 (05:38 +0300)]
System.Runtime.InteropServices readonly annotation (#51784)

* mark whole struct as readonly

3 years ago[wasm] Fix loading WebAssembly tasks in VS (#52076)
Ankit Jain [Thu, 29 Apr 2021 23:43:29 +0000 (19:43 -0400)]
[wasm] Fix loading WebAssembly tasks in VS (#52076)

- In case of `WasmAppBuilder.dll`, we were packaging only the task assembly, and
  `System.Reflection.MetadataLoadContext` for net472, same as net6.0 .

- But for net472, VS fails with errors like:

```
C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\6.0.0-preview.4.21222.10\Sdk\WasmApp.targets(424,4): Error MSB4018: The "PInvokeTableGenerator" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.Metadata, Version=1.4.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Reflection.Metadata, Version=1.4.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.MetadataLoadContext.LoadFromStreamCore(Stream peStream)
   at System.Reflection.MetadataLoadContext.LoadFromAssemblyPath(String assemblyPath)
   at System.Reflection.PathAssemblyResolver.Resolve(MetadataLoadContext context, AssemblyName assemblyName)
   at System.Reflection.MetadataLoadContext.TryFindAssemblyByCallingResolveHandler(RoAssemblyName refName)
   at System.Reflection.MetadataLoadContext.ResolveToAssemblyOrExceptionAssembly(RoAssemblyName refName)
   at System.Reflection.MetadataLoadContext.TryResolveAssembly(RoAssemblyName refName, Exception& e)
   at System.Reflection.MetadataLoadContext.TryGetCoreAssembly(String coreAssemblyName, Exception& e)
   at System.Reflection.TypeLoading.CoreTypes..ctor(MetadataLoadContext loader, String coreAssemblyName)
   at System.Reflection.MetadataLoadContext..ctor(MetadataAssemblyResolver resolver, String coreAssemblyName)
   at PInvokeTableGenerator.GenPInvokeTable(String[] pinvokeModules, String[] assemblies) in /Users/radical/dev/r2/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 42
   at PInvokeTableGenerator.Execute() in /Users/radical/dev/r2/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs:line 28
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
```

- So, bundle all the dependent assemblies from the publish folder

3 years agoTask/use get last p invoke error (#52003)
Kareem Zedan [Thu, 29 Apr 2021 23:01:12 +0000 (00:01 +0100)]
Task/use get last p invoke error (#52003)

* remove Marshal.GetLastWin32Error

3 years agoSystem.Numerics readonly annotation (#51797)
hrrrrustic [Thu, 29 Apr 2021 22:46:51 +0000 (01:46 +0300)]
System.Numerics readonly annotation (#51797)

* readonly annotation

* refactor Sqrt method

* Mark Complex readonly

* return rescale flag

* remove redundant readonly keywords

* revert BitsBuffer

3 years agoAdd Infra for porting lib only packages to use dotnet pack instead of pkgprojs (...
Anirudh Agnihotry [Thu, 29 Apr 2021 22:07:46 +0000 (15:07 -0700)]
Add Infra for porting lib only packages to use dotnet pack instead of pkgprojs (#51765)

* add infra and move projects to use dotnet pack

* adddress feedback

* address feedback

* donot include buildoutput from netfx during sourcebuild

* some more feedback points

* add  SuppressDependenciesWhenPacking as well

* Apply suggestions from code review

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
* Update src/libraries/Directory.Build.targets

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

* Update src/libraries/Directory.Build.targets

Co-authored-by: Viktor Hofer <viktor.hofer@microsoft.com>
* donot set includebuild output in outerbuild

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