platform/upstream/dotnet/runtime.git
2 years agoDo not print anything to stderr running SCD app without deps.json (#69314)
Vitek Karas [Wed, 18 May 2022 11:07:16 +0000 (04:07 -0700)]
Do not print anything to stderr running SCD app without deps.json (#69314)

When we're running self-contained app the `hostfxr` tries to figure out the location of `hostpolicy.dll`. This is done also by looking into the `.deps.json` for the app (which should have a record for `hostpolicy.dll` in it). If the file is missing the code will move on and find the `hostpolicy.dll` in the app's folder, but it will also print out a message to stderr.

This means that running such app will actually work, but the host outputs a message to stderr - effectively "corrupting" the app's own output.

Note that this doesn't affects framework dependent apps without `.deps.json` since they look into the framework's `.deps.json` for `hostpolicy.dll`.

2 years agoDisable System.Reflection tests on NativeAOT (#69477)
Jan Kotas [Wed, 18 May 2022 10:44:45 +0000 (03:44 -0700)]
Disable System.Reflection tests on NativeAOT (#69477)

Workarounds #69476

2 years agoFix several regex loop issues (#69413)
Stephen Toub [Wed, 18 May 2022 10:04:15 +0000 (06:04 -0400)]
Fix several regex loop issues (#69413)

* Fix several regex loop issues

1. Atomic greedy loop stack fixing.  We were leaving some state on the backtracking stack after an atomic greedy loop successfully matched; if an earlier construct needed to pop something from the stack, it could end up getting state from that loop rather than its own.
2. Lazy loop backtracking pos.  When a lazy loop backtracks to add an additional iteration, it needs to pick up where the previous iteration left off, but it wasn't properly storing/restoring the pos.
3. Improve RightToLeft (lookbehind) backreference matching.  This wasn't broken, but it was unnecessarily complex and making the resulting code harder to debug through.  This only affects the source generator, as RegexCompiler uses slightly different codegen due to also handling IgnoreCase.
4. Reuse loop logic for repeater atomic lazy loops.  Atomic lazy loops end up being functionally identical to the equivalent greedy loop due to having the lazy upper bound lowered to the lazy lower bound.  We can consolidate the implementations to avoid duplication.
5. .* Singeline loop in RightToLeft (lookbehind).  Mainly to reduce the noise while investigating these issues, but it avoids an unnecessary loop.

* Address PR feedback

2 years agoARM64 - Do not emit possible DIV_BY_ZERO/OVERFLOW exception blocks for non-zero/non...
Will Smith [Wed, 18 May 2022 08:03:39 +0000 (01:03 -0700)]
ARM64 - Do not emit possible DIV_BY_ZERO/OVERFLOW exception blocks for non-zero/non-(negative one) constants (#68945)

* Do not emit possible DIV_BY_ZERO exception for non-zero constants

* Added overflow check

* Added second divzero check change

* Update morph.cpp

* Update morph.cpp

2 years agoDelete securitywrapper/securityutil (#69468)
Elinor Fung [Wed, 18 May 2022 04:10:31 +0000 (21:10 -0700)]
Delete securitywrapper/securityutil (#69468)

2 years agoSpanify some Windows X.509 PAL and improve formatting
Kevin Jones [Wed, 18 May 2022 03:05:40 +0000 (23:05 -0400)]
Spanify some Windows X.509 PAL and improve formatting

2 years agoUse Rfc3279DerSequence for signatures in ECDsaX509SignatureGenerator
Kevin Jones [Wed, 18 May 2022 02:51:29 +0000 (22:51 -0400)]
Use Rfc3279DerSequence for signatures in ECDsaX509SignatureGenerator

2 years agoAdd comment about PipeReader.ReadAtLeastAsync(0) (#69217)
William Godbe [Tue, 17 May 2022 22:44:56 +0000 (15:44 -0700)]
Add comment about PipeReader.ReadAtLeastAsync(0) (#69217)

* Add comment about PipeReader.ReadAtLeastAsync(0)

* Update PipeReader.cs

* Update PipeReader.cs

* Update PipeReader.cs

* Fixup

2 years agoUOH alloc fix for hardlimit (#69345)
Maoni Stephens [Tue, 17 May 2022 22:27:01 +0000 (15:27 -0700)]
UOH alloc fix for hardlimit (#69345)

2 years agoArm64: Make unroll code for cpblk non-interruptible (#69202)
Kunal Pathak [Tue, 17 May 2022 22:20:31 +0000 (15:20 -0700)]
Arm64: Make unroll code for cpblk non-interruptible (#69202)

* make unroll code non-interruptible

* jit format

* Disable GC only in specific scenarios:

* add a comment

2 years agoReuse the throw away buffer in ZipHelper (#69439)
Eric Erhardt [Tue, 17 May 2022 22:01:04 +0000 (17:01 -0500)]
Reuse the throw away buffer in ZipHelper (#69439)

* Reuse the throw away buffer in ZipHelper

ZipHelper.AdvanceToPosition was allocating a new temporary buffer every time through the loop while reading from the stream. Changing the code to reuse the same buffer through the loop.

2 years ago#69424 disabled failing equals nan tests on tvos (#69429)
Meri Khamoyan [Tue, 17 May 2022 20:30:53 +0000 (00:30 +0400)]
#69424 disabled failing equals nan tests on tvos (#69429)

Disabling failing tests on tvos for issue #69424

2 years agoFix executable memory reservation when range is not requested (#69430)
Jan Vorlicek [Tue, 17 May 2022 20:22:14 +0000 (22:22 +0200)]
Fix executable memory reservation when range is not requested (#69430)

The VMToOSInterface::ReserveDoubleMappedMemory on Unix currently
doesn't use the range of memory reserved for executable purposes
in PAL in case there was no specific range of memory requested.
This is incorrect and it leads to steady state performance
degradation when W^X is enabled.

This change fixes it by using the PAL reserved memory even for
requests without specified range. This makes the steady state
performance the same both with and without W^X enabled.
This is very well visible on the Orchards and Fortunes benchmarks
performance where the regression was 17% resp 12% with W^X enabled.

2 years agoWasm conditional audit + remove CompileFunction (#69283)
Katelyn Gadd [Tue, 17 May 2022 20:05:05 +0000 (13:05 -0700)]
Wasm conditional audit + remove CompileFunction (#69283)

* Revise some if statements that implicitly treat the empty string as null
Add is_nullish utility function
Fix string decoder's handling of empty strings and query of string length
* Fix some uses of the logical or operator
* Remove unused CompileFunction interop API

2 years agoWrap exceptions from array constructors in TargetInvocationException (#69440)
Jan Kotas [Tue, 17 May 2022 19:21:16 +0000 (12:21 -0700)]
Wrap exceptions from array constructors in TargetInvocationException (#69440)

Fixes #69336

2 years ago[mono] Fix a crash during stack trace construction if a this object is null. (#69292)
Zoltan Varga [Tue, 17 May 2022 18:42:16 +0000 (14:42 -0400)]
[mono] Fix a crash during stack trace construction if a this object is null. (#69292)

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

2 years agoReduce max shared memory object name length (#68541)
Adam Sitnik [Tue, 17 May 2022 18:27:52 +0000 (20:27 +0200)]
Reduce max shared memory object name length (#68541)

* reduce max shared memory object name to 30

* use the fallback to be 100% safe

2 years agoRevert "Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)" (#69442)
Carlos Sanchez [Tue, 17 May 2022 17:37:21 +0000 (10:37 -0700)]
Revert "Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)" (#69442)

This reverts commit 54083237da17f8ce04a98bf70ddd716d604ce628.

2 years ago[wasm][debugger] Extract the main run loop from DevToolsClient, and (#69219)
Ankit Jain [Tue, 17 May 2022 17:01:00 +0000 (13:01 -0400)]
[wasm][debugger] Extract the main run loop from DevToolsClient, and (#69219)

* [wasm][debugger] Extract the main run loop from DevToolsClient, and

.. DevToolsProxy into a separate class, which would allow having the
same features, and having only one place for the fixes.

* Fix harness tests

* fix merge error

2 years agoAdd clang 14 to known compiler versions. (#69249)
Tom Deseyn [Tue, 17 May 2022 16:34:49 +0000 (18:34 +0200)]
Add clang 14 to known compiler versions. (#69249)

* Add clang 14 to known compiler versions.

* NativeExports: strip 'unknown compiler' and other stderr output when determining compiler path.

2 years agoSupport ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`. (#69378)
Theodore Tsirpanis [Tue, 17 May 2022 16:31:36 +0000 (19:31 +0300)]
Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`. (#69378)

* Support ref fields in `System.Reflection.Metadata.Ecma335.BlobEncoder`.
Fixes #68309.
A test case was added.

2 years agoremove duplicate Connect logic from TcpClient (#67951)
Tomas Weinfurt [Tue, 17 May 2022 16:22:41 +0000 (09:22 -0700)]
remove duplicate Connect logic from TcpClient (#67951)

2 years agoFix for GetMemberWithSameMetadataDefinitionAs (#69284)
Lakshan Fernando [Tue, 17 May 2022 14:28:28 +0000 (07:28 -0700)]
Fix for GetMemberWithSameMetadataDefinitionAs (#69284)

* Test fix for GetMemberWithSameMetadataDefinitionAs

* get reflection tests clean

* add doc info to test a library in native aot

2 years agoFixed work with QUIC_BUFFER (#69351)
Marie Píchová [Tue, 17 May 2022 14:17:47 +0000 (16:17 +0200)]
Fixed work with QUIC_BUFFER (#69351)

2 years agoAdd some assertions to Stream.Read in System.Text.Encoding.CodePages (#69414)
Eric Erhardt [Tue, 17 May 2022 13:27:07 +0000 (08:27 -0500)]
Add some assertions to Stream.Read in System.Text.Encoding.CodePages (#69414)

* Add some assertions to Stream.Read in System.Text.Encoding.CodePages

BaseCodePageEncoding is relying on Stream.Read to read a full buffer of data in a single read. This is safe to assume because the only stream ever used is an UnmanagedMemoryStream, which will just copy the data to the buffer.

Adding some asserts to the code to make this assumption explicit.

2 years agoMake json source generation cancellable (#69332)
CyrusNajmabadi [Tue, 17 May 2022 13:19:12 +0000 (06:19 -0700)]
Make json source generation cancellable (#69332)

* Make json generation cancellable

* Simplify

* no var

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

* Update src/libraries/System.Text.Json/gen/JsonSourceGenerator.Roslyn3.11.cs

Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
Co-authored-by: Sam Harwell <sam@tunnelvisionlabs.com>
2 years agoOptimize ManifestResourceStream.Read(Span<byte>) (#69412)
Eric Erhardt [Tue, 17 May 2022 10:55:34 +0000 (05:55 -0500)]
Optimize ManifestResourceStream.Read(Span<byte>) (#69412)

ManifestResourceStream is derived from UnmanagedMemoryStream. UnmanagedMemoryStream optimizes Read(Span<byte>), but only if the instance is concretely an UnmanagedMemoryStream. This is to protect in case the derived Stream overriddes Read(byte[], int, int) prior to the Read(Span<byte>) overload being introduced.

Optimize ManifestResourceStream by overriding Read(Span<byte>) and call ReadCore, so the Stream.Read(Span<byte>) logic of using a pooled byte[] buffer isn't used.

2 years agoAllow the inliner to substitute for small arguments (#69068)
Jakob Botsch Nielsen [Tue, 17 May 2022 10:19:18 +0000 (12:19 +0200)]
Allow the inliner to substitute for small arguments (#69068)

Since we no longer have contextual nodes to indicate small arguments,
this should be safe to do. For register arguments it does not matter and
for stack arguments it is handled in codegen (for macOS arm64).

2 years agoUse intrinsic for genLog2() (#69333)
Kunal Pathak [Tue, 17 May 2022 03:30:02 +0000 (20:30 -0700)]
Use intrinsic for genLog2() (#69333)

* Use intrinsic for genLog2()

* Use correct macro

* Fix non-msvc build

* fix 32-bit build

* just do for TARGET_64BIT

* Review comments

2 years agoAddress some System.Formats.Tar TODOs (infra and syscalls) (#69107)
Carlos Sanchez [Tue, 17 May 2022 02:45:30 +0000 (19:45 -0700)]
Address some System.Formats.Tar TODOs (infra and syscalls) (#69107)

* Fix Design time build errors by removing src project as dependency of the test project.

* Add Browser to target platform identifiers. Ensure Browser can consume the Unix specific ArchivingUtils file too.

* Remove nullable enable from csproj since it's now default

* Use FileStream constructor with FileMode.CreateNew to detect and throw if destination file exists when creating archive.

* No error checking on syscalls that do not set errno.

* Add RDev field in FileStatus and retrieve it with stat/lstat so devmajor and devminor get their correct values.

* Simplify some File.Open calls with direct FileStream constructor calls. Simplify FileStreamOptions objects too.

* Implement and consume p/invokes to retrieve uname from uid and gname from gid.

* size_t variables should not be checked for negative values

* FileStream calls simplified to File.OpenRead

* Remove check for RDev > 0

* Use dictionary to preserve repeated unames and gnames mapped to uids and gids

* Missing documentation in pal_uid.h new PALEXPORT methods.

* Adjust syscalls to thread-safe ones. Start with stackalloc, then use loop.

* Make dicts readonly and non-nullable, use TryGetValue

* Reuse 'GetNameFromUid' from pal_networking.c, move to pal_uid.c, use similar logic for Gid method. Simplify Interop.Sys method.

* Remove unnecessary comment

Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
* Put TargetFrameworks back in the first position of the PropertyGroup.

* Address eerhardt suggestions

* Update src/libraries/System.Formats.Tar/tests/TarWriter/TarWriter.WriteEntry.File.Tests.Unix.cs

* Clarify in pal_uid.h methods comments that new memory is returned

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
Co-authored-by: Adam Sitnik <adam.sitnik@gmail.com>
2 years agoDelete ClrDirectoryEnumerator (#69400)
Adeel Mujahid [Tue, 17 May 2022 01:43:57 +0000 (04:43 +0300)]
Delete ClrDirectoryEnumerator (#69400)

* Delete unused PAL functions

* Delete ClrDirectoryEnumerator

2 years agoAdd support for marshalling signed/unsigned boolean types. (#69402)
Aaron Robinson [Tue, 17 May 2022 01:38:26 +0000 (18:38 -0700)]
Add support for marshalling signed/unsigned boolean types. (#69402)

2 years agoCleanup some X509 PAL allocations
Kevin Jones [Tue, 17 May 2022 00:33:55 +0000 (20:33 -0400)]
Cleanup some X509 PAL allocations

2 years agoAdd correct assembly context name to InvalidCastException message (#69346)
Jan Kotas [Mon, 16 May 2022 23:57:47 +0000 (16:57 -0700)]
Add correct assembly context name to InvalidCastException message (#69346)

* Add correct assembly context name to InvalidCastException message

Fixes #69341

* Move GetNameForDiagnostics to assemblybinder.cpp/assemblybinder.h

2 years agoFix LibraryImportGenerator.UnitTests.Compiles.ValidateSnippetsFallbackForwarder ...
Elinor Fung [Mon, 16 May 2022 23:23:34 +0000 (16:23 -0700)]
Fix LibraryImportGenerator.UnitTests.Compiles.ValidateSnippetsFallbackForwarder (#69398)

2 years agoFix ASAN violation under Samsung's netcoredbg (#69339)
Mike McLaughlin [Mon, 16 May 2022 22:11:36 +0000 (15:11 -0700)]
Fix ASAN violation under Samsung's netcoredbg (#69339)

* Fix ASAN violation under Samsung's netcoredbg

Fixes issue https://github.com/dotnet/runtime/issues/62281

The wrong holder was being used in DacDbiInterfaceImpl::GetNativeVarData(); change to NewArrayHolder.

Added new/delete operators to Exception so when it is thrown from the DAC and caught/deleted in DBI, the
correct C++ allocator is used. When the DAC is called by DBI, g_pAllocator points to the DBI allocator.

* Code review feedback

2 years agoWorkaround crash in Microsoft.DiaSymReader.Native (#68990)
Mike McLaughlin [Mon, 16 May 2022 22:10:16 +0000 (15:10 -0700)]
Workaround crash in Microsoft.DiaSymReader.Native (#68990)

* Workaround crash in Microsoft.DiaSymReader.Native

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

The fix is to check if the module has a portable PDB in the debug directory
and use the well-tested managed portable PDB source/line number code.

Add support for in-memory embedded PDBs.

2 years agoMove MsQuicStream._streamId into MsQuicStream.State (#69382)
Radek Zikmund [Mon, 16 May 2022 20:58:57 +0000 (22:58 +0200)]
Move MsQuicStream._streamId into MsQuicStream.State (#69382)

* Move StreamId into State

* Code review feedback

2 years agoremove internal socket exception from NameResolution (#69270)
Tomas Weinfurt [Mon, 16 May 2022 20:44:30 +0000 (13:44 -0700)]
remove internal socket exception from NameResolution (#69270)

2 years agoavoid allocationg ApplicationProtocol in common case (#69098)
Tomas Weinfurt [Mon, 16 May 2022 20:43:42 +0000 (13:43 -0700)]
avoid allocationg ApplicationProtocol in common case (#69098)

* avoid allocationg ApplicationProtocol in common case

* ReadOnlySpan

* feedback from review

2 years agoRemoval of IBC infrastructure (#68717)
Aaron Robinson [Mon, 16 May 2022 20:18:53 +0000 (13:18 -0700)]
Removal of IBC infrastructure (#68717)

* Removal of IBC infrastructure

* Crossgen2 - remove tuning flag.

2 years agoDetect truncated GZip streams (#61768)
mfkl [Mon, 16 May 2022 20:07:48 +0000 (03:07 +0700)]
Detect truncated GZip streams (#61768)

* System.IO.Compression tests: add StreamTruncation_IsDetected

* System.IO.Compression: detect and throw on truncated streams

* account for edge case

* account for edge case in async version

* rename nonZeroInput to nonEmptyInput

* remove else to improve codegen

* run StreamTruncation_IsDetected for all three types of compression streams

* fixup test build and run

* add stream corruption test

* review feedback - cosmetics

* make BrotliStream detect truncation

* make StreamCorruption_IsDetected run for gzip only

other types of stream can't detect corruption properly

* skip byte corruption which results in correct decompression

* code style

* add zlib corruption test, no skipping needed

* clarify why we skip bytes in gzip test

* add and use truncated error data message

Co-authored-by: Marcin Krystianc <marcin.krystianc@gmail.com>
2 years agoRemove CngKeyLite
Kevin Jones [Mon, 16 May 2022 18:32:29 +0000 (14:32 -0400)]
Remove CngKeyLite

The class is no longer used after consolidating cryptographic assemblies.

2 years ago[wasm] Fix debug proxy when used with blazor (#69342)
Ankit Jain [Mon, 16 May 2022 17:45:53 +0000 (13:45 -0400)]
[wasm] Fix debug proxy when used with blazor (#69342)

Due to recent debug proxy changes, when trying to debug a blazor app, it
fails with:
```
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: No output has been recevied from the application.
         at Microsoft.AspNetCore.Builder.DebugProxyLauncher.LaunchAndGetUrl(IServiceProvider serviceProvider, String devToolsHost)
         at Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.<>c.<<UseWebAssemblyDebugging>b__0_1>d.MoveNext()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.InvokeCore(HttpContext context, PathString matchedPath, PathString remainingPath)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
```

This is because it's looking for specific lines in output. And also, it
fails if it gets an empty line.

This commits fixes the output to match what blazor expects. And
essentially, disables firefox debug proxy when the host is directly
used, which is only by blazor right now.

This will change in the future though, and blazor side can be patched to
work better.

2 years agoRemove most usages of *wprintf* family of functions (#68237)
Aaron Robinson [Mon, 16 May 2022 16:53:31 +0000 (09:53 -0700)]
Remove most usages of *wprintf* family of functions (#68237)

* Remove most usage of *wprintf* family of functions

* Revert updates to Windows only source

* Make constants for integer max string lengths

2 years agoUpdate ActiveIIssue on NtlmSignatureTest (#69389)
Filip Navara [Mon, 16 May 2022 16:51:41 +0000 (18:51 +0200)]
Update ActiveIIssue on NtlmSignatureTest (#69389)

2 years ago[wasm][debugger] Refactor: narrow down SdbHelper responsibility (#66821)
Ilona Tomkowicz [Mon, 16 May 2022 15:53:54 +0000 (17:53 +0200)]
[wasm][debugger] Refactor: narrow down SdbHelper responsibility (#66821)

* Refactor.

* Applied @radical's suggestions about expression body.

* On refactor-createjobj-66068: Applied @radical's https://github.com/radical/runtime/commit/69f5cea4dfe30f3dbd74333b1b23fd8feb665e18.

* Revert test fix and separate it to another PR.

* Reverted whitespaces.

* Overlooked whitespaces - undo.

* Made static what can be static.

* Removed whitespaces.

* Removed whitespaces.

* Blocked tests failing on Firefox.

2 years agoAdd `IntPtr` conversion APIs for some runtime handles (#69363)
Aaron Robinson [Mon, 16 May 2022 14:40:22 +0000 (07:40 -0700)]
Add `IntPtr` conversion APIs for some runtime handles (#69363)

* Add conversion APIs for runtime handles

2 years agoOnly fold Type.op_Equality calls before morphing args (#69367)
Jakob Botsch Nielsen [Mon, 16 May 2022 14:36:35 +0000 (16:36 +0200)]
Only fold Type.op_Equality calls before morphing args (#69367)

Otherwise we may discard setup nodes.

Fix #68513

2 years agoFix KeepNativeSymbols to work on mono as well (#66594)
Omair Majid [Mon, 16 May 2022 12:27:40 +0000 (08:27 -0400)]
Fix KeepNativeSymbols to work on mono as well (#66594)

When packaging .NET on s390x through source-build, we want to keep debug
symbols enabled in the build. The package manager (debbuild, rpmbuild,
etc) generally strips the binaries to create distro-standard
-debug/-debuginfo packages. This was supported in coreclr via
--keepnativesymbols flag, but wasn't supported in mono (ie, s390x). Fix
that.

2 years agosupport only Ordinal comparison inside WildcardPathSegment (#69079)
Badre BSAILA [Mon, 16 May 2022 12:11:53 +0000 (14:11 +0200)]
support only Ordinal comparison inside WildcardPathSegment (#69079)

2 years agoUpdate signing of JS files (#69366)
Juan Hoyos [Mon, 16 May 2022 10:01:07 +0000 (03:01 -0700)]
Update signing of JS files (#69366)

Fixes part of #69317

2 years agoAdd OpenTelemetry with Geneva exporter to test server (#69304)
Radek Zikmund [Mon, 16 May 2022 08:28:13 +0000 (10:28 +0200)]
Add OpenTelemetry with Geneva exporter to test server (#69304)

2 years agoFix UTF8 string marshalling regression (#69360)
Jan Kotas [Sun, 15 May 2022 18:57:22 +0000 (11:57 -0700)]
Fix UTF8 string marshalling regression (#69360)

* Fix UTF8 string marshalling regression

We need to compensate for the differences in lifetime management patterns used by built-in marshalling system vs. the publicly explosed marshallers.

Fixes #69349

* Call Marshal.FreeCoTaskMem in the AOT compiler built-in marshalling

* Use Marshal.StringToCoTaskMemUni in Utf16StringMarshaller implementation

2 years agoRevert "Add IL Emit support for MethodInfo.Invoke() and friends" (#69373)
Jan Kotas [Sun, 15 May 2022 18:24:49 +0000 (11:24 -0700)]
Revert "Add IL Emit support for MethodInfo.Invoke() and friends" (#69373)

* Revert "Fix Assembly.GetCallingAssembly() (#69225)"

This reverts commit 8420dae8e84e03b7658a21f4b18831a8a2f0db79.

* Revert "Add IL Emit support for MethodInfo.Invoke() and friends (#67917)"

This reverts commit 5195418426468d13b042ae079c65aa05595295b4.

2 years agoFix typo in 'parameter'. (#69370)
Bradley Grainger [Sun, 15 May 2022 15:27:46 +0000 (08:27 -0700)]
Fix typo in 'parameter'. (#69370)

2 years agoImplement constant-folding for `VNF_BitCast` (#68979)
SingleAccretion [Sun, 15 May 2022 09:56:58 +0000 (12:56 +0300)]
Implement constant-folding for `VNF_BitCast` (#68979)

A few small diffs in tests where we now form new constants
for "long/int <-> double/float>" reinterpretations.

Completes the support for "VNF_BitCast" and removes the SIMD
quirk from "VNForLoadStoreBitCast".

2 years agoImprove some use of Regex (#68961)
Stephen Toub [Sat, 14 May 2022 21:55:38 +0000 (17:55 -0400)]
Improve some use of Regex (#68961)

- Use IsMatch instead of Match(...).Success
- Use EnumerateMatches when Index/Length are needed but not captures
- Remove Regex that could just be IndexOf

2 years agoFix buffer overrun in dbgutil (#69358)
Jan Kotas [Sat, 14 May 2022 20:55:12 +0000 (13:55 -0700)]
Fix buffer overrun in dbgutil (#69358)

Fixes #69353

2 years agoDelete a few unused definitions from coreclr pal (#69357)
Adeel Mujahid [Sat, 14 May 2022 20:07:13 +0000 (23:07 +0300)]
Delete a few unused definitions from coreclr pal (#69357)

2 years agoDelete incorrect asserts (#69354)
SingleAccretion [Sat, 14 May 2022 19:15:13 +0000 (22:15 +0300)]
Delete incorrect asserts (#69354)

* Delete incorrect asserts

In an "OBJ(LCL_VAR_ADDR)" argument, the underlying local can be of any type/HFA-ness.

* Add tests

2 years agoDo not fold mismatched `OBJ(ADDR(LCL_VAR))` (#69271)
SingleAccretion [Sat, 14 May 2022 18:35:20 +0000 (21:35 +0300)]
Do not fold mismatched `OBJ(ADDR(LCL_VAR))` (#69271)

* Do not fold mismatched OBJ(ADDR(LCL_VAR))

The transforms in question could fold, e. g. "OBJ<8>(ADDR(LCL_VAR<16>))"
to just the "LCL_VAR", necessitating workarounds in block morphing that
had to rematerialize the block node to restore IR's validity.

It is better to simply not create questionable IR in the first place.

* Add a test

* Re-enable tests

* Fix regressions

By using layout compatibility in "gtNewStructVal" instead of handle equality.

This is safe to do because "gtNewStructVal" is only used in contexts of block
copies (as opposed to call arguments).

2 years ago[mono][llvm] More LLVM 14.x changes. (#69239)
Zoltan Varga [Sat, 14 May 2022 16:08:59 +0000 (12:08 -0400)]
[mono][llvm] More LLVM 14.x changes. (#69239)

* Add a type to the 'sret' parameter attribute.
* Add helper functions for creating pointer types and pointer casts.

2 years agoAvoid unnecessary or duplicate PackageReferences - 7.0 Preview4 SDK work (#69260)
Viktor Hofer [Sat, 14 May 2022 07:50:35 +0000 (09:50 +0200)]
Avoid unnecessary or duplicate PackageReferences - 7.0 Preview4 SDK work (#69260)

* [WIP - Validation] Update the SDK to Preview4

* Avoid duplicate PackageReference

* Fix duplicated PackageReference

* Remove duplicate PackageRefs

* Update llvm-init.proj

* Update global.json

* Update xunit.props

2 years agoLocalized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 177079...
dotnet bot [Sat, 14 May 2022 07:45:23 +0000 (00:45 -0700)]
Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID 1770798 (#69337)

2 years agoEnsure non-numeric types don't implement the numeric only generic math interfaces...
Tanner Gooding [Sat, 14 May 2022 04:46:08 +0000 (21:46 -0700)]
Ensure non-numeric types don't implement the numeric only generic math interfaces (#69331)

2 years agoAdd windows runtime packs as a workload (#68981)
Steve Pfister [Sat, 14 May 2022 04:12:09 +0000 (00:12 -0400)]
Add windows runtime packs as a workload (#68981)

At certain points in time internally, the sdk will rev its version and insert into VS. It's at this point the sdk version will be ahead of the runtime version as we have not published anything into nuget. In MAUI and WinUI scenarios, this creates a bit of a pickle as the sdk will try to download a new version of the windows runtime pack, but it will not be available.

To get around this limitation, we are introducing a workload that will be inserted into VS where you can optionally install Windows runtime packs.

2 years agoUse more specific types in Interop.WideCharToMultiByte signature (#69338)
Jan Kotas [Sat, 14 May 2022 02:55:25 +0000 (19:55 -0700)]
Use more specific types in Interop.WideCharToMultiByte signature (#69338)

2 years ago[mono] Fix parsing the 'nunbox-arbitrary-trampolines' aot argument. (#69319)
Rolf Bjarne Kvinge [Sat, 14 May 2022 00:06:14 +0000 (02:06 +0200)]
[mono] Fix parsing the 'nunbox-arbitrary-trampolines' aot argument. (#69319)

2 years agoExpose the RuntimeFeature.NumericIntPtr member for C# 11 (#69322)
Tanner Gooding [Fri, 13 May 2022 21:52:07 +0000 (14:52 -0700)]
Expose the RuntimeFeature.NumericIntPtr member for C# 11 (#69322)

2 years agoenable NoCallback_RevokedCertificate_NoRevocationChecking_Succeeds (#69264)
Tomas Weinfurt [Fri, 13 May 2022 21:36:10 +0000 (14:36 -0700)]
enable NoCallback_RevokedCertificate_NoRevocationChecking_Succeeds (#69264)

2 years agoDo not sign the .js files (#69317)
Ankit Jain [Fri, 13 May 2022 21:08:41 +0000 (17:08 -0400)]
Do not sign the .js files (#69317)

* Do not sign the .js files

We want to avoid the js files in wasm templates from getting the
signature block in user visible files.

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

* Update eng/Signing.props

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2 years agoUse static abstract members on two occasions. (#69278)
Theodore Tsirpanis [Fri, 13 May 2022 20:28:02 +0000 (23:28 +0300)]
Use static abstract members on two occasions. (#69278)

2 years agoFix a typo (#69145)
Andrew Au [Fri, 13 May 2022 19:55:22 +0000 (12:55 -0700)]
Fix a typo (#69145)

2 years agoAdd DateOnly and TimeOnly support to System.Text.Json (#69160)
Eirik Tsarpalis [Fri, 13 May 2022 17:31:28 +0000 (18:31 +0100)]
Add DateOnly and TimeOnly support to System.Text.Json (#69160)

* Add DateOnly and TimeOnly support to System.Text.Json

* Constrain DateOnly supported formats to calendar dates only.

* Update src/libraries/System.Text.Json/src/System/Text/Json/ThrowHelper.cs

Co-authored-by: Layomi Akinrinade <layomia@gmail.com>
* Replace NETx_OR_GREATER with NETCOREAPP

Co-authored-by: Layomi Akinrinade <layomia@gmail.com>
2 years agoFix handling of custom type marshaller pinning with a different type than the native...
Jeremy Koritzinsky [Fri, 13 May 2022 16:45:01 +0000 (09:45 -0700)]
Fix handling of custom type marshaller pinning with a different type than the native type. (#69214)

Co-authored-by: Aaron Robinson <arobins@microsoft.com>
2 years agoRemove ActiveIssue for S.S.C.Xml tests that rely on DSA key generation
Kevin Jones [Fri, 13 May 2022 16:05:59 +0000 (12:05 -0400)]
Remove ActiveIssue for S.S.C.Xml tests that rely on DSA key generation

MacOS cannot generate DSA keys, so make a pre-generated key and use that.

Only used the fixed key on macOS so other platforms continue to test with a random key.

2 years agoAdd versioning info to clrgc (#69295)
Juan Hoyos [Fri, 13 May 2022 15:47:46 +0000 (08:47 -0700)]
Add versioning info to clrgc (#69295)

2 years agofix typo in LoggerFactoryExtensions (#69303)
havalli [Fri, 13 May 2022 14:49:07 +0000 (16:49 +0200)]
fix typo in LoggerFactoryExtensions (#69303)

2 years agoEnable System.Globalization.Native for NativeAOT (#69297)
Jan Kotas [Fri, 13 May 2022 14:36:09 +0000 (07:36 -0700)]
Enable System.Globalization.Native for NativeAOT (#69297)

Fixes #68889

2 years agoFixed System.Text.Json failures on x86 android (#69248)
Meri Khamoyan [Fri, 13 May 2022 14:27:51 +0000 (18:27 +0400)]
Fixed System.Text.Json failures on x86 android (#69248)

#49936

2 years agoShare code between source-generated and built-in Utf8 string marshallers (#69043)
Jan Kotas [Fri, 13 May 2022 13:48:06 +0000 (06:48 -0700)]
Share code between source-generated and built-in Utf8 string marshallers (#69043)

2 years agoAdd regex test that reuses RegexMatchTests data for captures (#69252)
Stephen Toub [Fri, 13 May 2022 11:25:51 +0000 (07:25 -0400)]
Add regex test that reuses RegexMatchTests data for captures (#69252)

* Add regex test that reuses RegexMatchTests data for captures

An additional test to help validate that all of the engines are producing the same captures information.

* Address PR feedback

2 years agoGet StreamID while still in the MsQuic callback (#69301)
Radek Zikmund [Fri, 13 May 2022 10:48:07 +0000 (03:48 -0700)]
Get StreamID while still in the MsQuic callback (#69301)

2 years agoMethods on primitives 65707 (#66654)
Ilona Tomkowicz [Fri, 13 May 2022 10:26:12 +0000 (12:26 +0200)]
Methods on primitives 65707 (#66654)

* Prepared tests for calling method on primitive types.

* Added support for most methods on primitives.

* Corrected other tests - TBool is supported.

* Corrected test to match current exception texts.

* Fixed evaluation with enums.

* Fixed another error message to match.

* Fixed firefox test on EvaluateMethodsOnPrimitiveTypesReturningPrimitives.

* Revert moving ContinueWith() out of the try block.

* Removed comment that is not longer true after 2fef3c218b5bca5494797e1134da64e62d433418.

* Applied radical's suggestions.

2 years agoSubstitute GT_RET_EXPR in inline candidate arguments (#69117)
Jakob Botsch Nielsen [Fri, 13 May 2022 07:38:09 +0000 (09:38 +0200)]
Substitute GT_RET_EXPR in inline candidate arguments (#69117)

Also rename GTF_CALL_M_LATE_DEVIRT -> GTF_CALL_M_HAS_LATE_DEVIRT_INFO

2 years agoSupport Requires on type in NativeAot (#68978)
Tlakaelel Axayakatl Ceja [Fri, 13 May 2022 05:25:17 +0000 (22:25 -0700)]
Support Requires on type in NativeAot (#68978)

Support Requires on type in NativeAot
- Adds new overload for MessageOrigin creation that uses MethodIL and an offset as parameters. Eventually, this will be used to produce warnings
- Share methods used in linker/analyzer for asking questions about members being in RequiresScope, members Requiring and Requires warning generation. These methods include handling of Requires on a type.
- The ReflectionMethodBodyScanner on field access now verifies for requires on type, since implicitly can call the static constructor
- Updated the mismatch attribute rules to take into account Requires on type
- Added support for RequiresAssemblyFilesAttribute, now the code checks for RAF and warns about it
- Added support to check and retrieve attributes in a property
- Added overloads to IsInRequiresScope that verify associated properties
- Add RequiresOnStaticConstructor id

2 years agoUpdate LibraryImportGenerator unit tests with interpolated string arguments (#69285)
Elinor Fung [Fri, 13 May 2022 04:25:12 +0000 (21:25 -0700)]
Update LibraryImportGenerator unit tests with interpolated string arguments (#69285)

2 years agoAdd missing (uint) cast in regex generated code (#69198)
Stephen Toub [Fri, 13 May 2022 03:42:16 +0000 (23:42 -0400)]
Add missing (uint) cast in regex generated code (#69198)

Avoids a possible bounds check

2 years agoNormalize Nil PublicKeyToken to an empty array (#69169)
Vladimir Sadov [Fri, 13 May 2022 02:40:35 +0000 (19:40 -0700)]
Normalize Nil PublicKeyToken to an empty array (#69169)

* Normalize Nil PublicKeyToken to an empty array

* Fix tests

* Do not parse assembly name from metadata

* Force PublicKey bit on assembly names fetched from definitions.

* better comment

* PR feedback.

2 years agoConvert RsaPaddingProcessor to statics
Kevin Jones [Fri, 13 May 2022 02:06:07 +0000 (22:06 -0400)]
Convert RsaPaddingProcessor to statics

The RsaPaddingProcessor is now entirely static methods so we do not need to keep instances cached.

2 years ago[wasm] Misc debugger improvements (#68988)
Ankit Jain [Fri, 13 May 2022 01:59:59 +0000 (21:59 -0400)]
[wasm] Misc debugger improvements (#68988)

* [wasm] Move the browser provisioning stuff to a new targets file

.. from `DebuggerTestSuite.csproj`. This will allow other projects to
use this too.

* [wasm][debugger] Handle failure to connect to the browser

* [wasm] Improve the browser path lookup

so it can be used outside the debugger tests project too. For example,
with Wasm.Build.Tests+playwright .

* [wasm][debugger] Throw exceptions from tasks correctly

.. using `ExceptionDispatchInfo.Capture` so we get the original stack
trace.

* [wasm][debugger] General improvements in debug proxy

- like logging
- updated API to make it easier to use by other projects, like the
  upcoming wasm-app-host .

* [wasm][debugger] Add support for setting an automatic breakpoint

.. on the first line of the entrypoint method (`Main`). This will be
useful for debugging with the upcoming wasm-app-host, along with the use
of `wait-for-debugger`.

Implemented by @thaystg .

* [wasm][debugger] Add support for wait_for_debugger

If requested, then it will cause invocation of `main` to be delayed till
a debugger is attached.

Implemented by @thaystg

* [wasm] Cleanup in Wasm.Build.Tests

.. in the lead up to wasm-app-host tests.

* [wasm] Update the default paths used to trigger builds on CI

.. to include templates, and provisioning props.

* disable non-wasm builds

* [wasm][debugger] Fix path to artifacts dir

* [wasm] Emit message with bundle path

* [wasm][templates] Make the project use the target dir's name as the

.. project name, instead of always creating `browser.dll`, and
`console.dll`.

* [wasm][debugger] Use a single static instance of HttpClient

.. as recommended by the documentation.

* Revert "disable non-wasm builds"

This reverts commit 7b8b60d58c886e7e66cf2fea910f1feb4d6374f1.

* Address review feedback, and improve the autogenerated bpid

2 years agoUse PopCount in DriveInfoInternal.Windows.cs. (#69279)
Theodore Tsirpanis [Fri, 13 May 2022 01:15:09 +0000 (04:15 +0300)]
Use PopCount in DriveInfoInternal.Windows.cs. (#69279)

2 years agoCollect more info for host tests (#69282)
Elinor Fung [Fri, 13 May 2022 00:20:17 +0000 (17:20 -0700)]
Collect more info for host tests (#69282)

2 years agoEnable nullable=enable by default for anything except tests (#69256)
Viktor Hofer [Thu, 12 May 2022 23:44:33 +0000 (01:44 +0200)]
Enable nullable=enable by default for anything except tests (#69256)

* Set nullable=enable for source generators

* Only add NullableAttribute.cs for C# projects

* Update Directory.Build.props

2 years agoFix memory leak at AssemblyLoadContext unload (#69263)
Jan Vorlicek [Thu, 12 May 2022 23:32:05 +0000 (01:32 +0200)]
Fix memory leak at AssemblyLoadContext unload (#69263)

I have found there was a small memory leak when unloading
AssemblyLoadContext. A customer had a quite extreme testing case that
ran millions of iterations of creating an AssemblyLoadContext, loading
some assemblies into it and then unloading it. After 80 million
iterations on their machine with 8GB memory, the testing app was getting
out of memory.

Using PerfView, I was able to locate the source of the leak. It was a
missing destruction of the Module::m_pJitInlinerTrackingMap.

2 years agoAdd Akhil to fabricbot-config (#69276)
Eric StJohn [Thu, 12 May 2022 23:28:28 +0000 (16:28 -0700)]
Add Akhil to fabricbot-config (#69276)

* Add Akhil to fabricbot-config

* Make names alphabetical

2 years agoGenerate the DAC table on Windows with MSVC linker directives instead of resource...
Jeremy Koritzinsky [Thu, 12 May 2022 21:53:12 +0000 (14:53 -0700)]
Generate the DAC table on Windows with MSVC linker directives instead of resource injection (#68065)

2 years ago[wasm] Wasm.Build.Tests: Capture test output with xunit, so the output is cleaner...
Ankit Jain [Thu, 12 May 2022 20:19:09 +0000 (16:19 -0400)]
[wasm] Wasm.Build.Tests: Capture test output with xunit, so the output is cleaner, and the (#69201)

* [wasm] Capture test output with xunit, so the output is cleaner, and the

.. test results have the full text.

* [wasm] Wasm.Build.Tests: remove unncessary output

.. like test args. And add some start/end banners for tests, since they
can be long running.

* Don't use _testOutput in the test programs

* fixup

2 years agoFix CoreLib fast up-to-date check (#69240)
Viktor Hofer [Thu, 12 May 2022 19:56:02 +0000 (21:56 +0200)]
Fix CoreLib fast up-to-date check (#69240)

* Fix CoreLib fast up-to-date check

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

CoreLib's fast up-to-date check was broken because the output pdb was
moved into a different folder. Changing this to use a copy task instead
and consolidate the two targets into one.

I couldn't find a publicly exposed property that allows to change the
pdb's output path, hence I decided to copy.