platform/upstream/dotnet/runtime.git
3 years agoInitial implementation of call chain statistics (#47547)
Tomáš Rylek [Fri, 29 Jan 2021 20:10:31 +0000 (21:10 +0100)]
Initial implementation of call chain statistics (#47547)

Add support for producing "callchain profile quality map", a new
auxiliary output file describing code layout properties w.r.t.
a given call chain profile.

Sample output for System.Private.CoreLib:

CHARACTERISTIC            | PAIR COUNT | CALL COUNT | PERCENTAGE
----------------------------------------------------------------
ENTRIES TOTAL             |        291 |     266229 |     100.00
RESOLVED ENTRIES          |        267 |     260172 |      97.72
UNRESOLVED ENTRIES        |         24 |       6057 |       2.28
NEAR (INTRA-PAGE) CALLS   |        145 |     109055 |      40.96
FAR (CROSS-PAGE) CALLS    |        122 |     151117 |      56.76

Thanks

Tomas

3 years agoBinaryWriter perf and memory usage improvements (#47316)
Levi Broderick [Fri, 29 Jan 2021 20:06:44 +0000 (12:06 -0800)]
BinaryWriter perf and memory usage improvements (#47316)

3 years agoEventSourceGenerator for Guid+Name .ctor and Metadata (#45699)
Ben Adams [Fri, 29 Jan 2021 19:17:02 +0000 (19:17 +0000)]
EventSourceGenerator for Guid+Name .ctor and Metadata (#45699)

3 years agoFixes for SuperPMI collection of crossgen2 (#47609)
Bruce Forstall [Fri, 29 Jan 2021 19:00:59 +0000 (09:00 -1000)]
Fixes for SuperPMI collection of crossgen2 (#47609)

1. Use superpmi.py parallelism (per assembly), not crossgen2 parallelism.
This is both faster, and it avoids a problem I was seeing of sharing
violations opening the method context file during collection.
2. Work around https://github.com/dotnet/runtime/issues/47554:
crossgen2 doesn't like EnableExtraSuperPmiQueries=1, so disable it
for crossgen2 collections.
3. Fix issue when `resolveToken` throws an exception: the resulting
resolved token structure could be corrupt (it was for crossgen2 in
a case I saw that led to SPMI crashing), so zero it out and record
that instead.

With this, there is only one crashing issue for collecting Core_Root
libraries (Windows x64 Checked), but there are 77835 compilation
failures on replay (see https://github.com/dotnet/runtime/issues/47540).

3 years agoAdd APIs to make nint/nuint match Int32 and others (#47595)
Cyl18 [Fri, 29 Jan 2021 16:16:03 +0000 (00:16 +0800)]
Add APIs to make nint/nuint match Int32 and others (#47595)

* Add APIs to make nint/nuint match Int32 and others

* Add default argument to nint/nuint TryFormat

* Fix Api Compat error

* Add test to nint/nuint

* fix test error

3 years agoRevert "Use socketpair to implement Process.Start redirection" (#47461)
Eirik Tsarpalis [Fri, 29 Jan 2021 14:51:03 +0000 (14:51 +0000)]
Revert "Use socketpair to implement Process.Start redirection" (#47461)

* Revert #34861

* reinstate removed test

* Update src/libraries/System.Diagnostics.Process/tests/ProcessStreamReadTests.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
3 years agoRemove WebSocketProtocol assembly (#47578)
Natalia Kondratyeva [Fri, 29 Jan 2021 14:50:21 +0000 (15:50 +0100)]
Remove WebSocketProtocol assembly (#47578)

Removed WebSocketProtocol code and mentions of the assembly.
Moved ManagedWebSocket.cs from Common to System.Net.WebSockets.

Fixes #1493

3 years agopal: free tempfile_name if GetTempFileNameA fails (#47477)
Omair Majid [Fri, 29 Jan 2021 14:42:52 +0000 (09:42 -0500)]
pal: free tempfile_name if GetTempFileNameA fails (#47477)

If GetTempFileNameA fails, we don't free up the dynamically allocated
memory that tempfile_name points to.

3 years agoAvoid Marshal.SizeOf in EventSource (#47521)
Michal Strehovský [Fri, 29 Jan 2021 14:42:04 +0000 (15:42 +0100)]
Avoid Marshal.SizeOf in EventSource (#47521)

* Avoid Marshal.SizeOf in EventSource

We're getting the marshalling size of an enum underlying type - there are not that many of those. I chose not to treat `char` and `bool`, but we could (the only other remaining options).

Calling into `Marshal.SizeOf` increases the risk that `EventSource` is going call itself recursively - see the comment at the beginning of the method.

This was originally introduced in https://github.com/dotnet/coreclr/pull/19205.

* Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

* Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

* Update src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs

3 years agoDispose of ClientWebSocket when it fails to connect (#47616)
Stephen Toub [Fri, 29 Jan 2021 14:25:39 +0000 (09:25 -0500)]
Dispose of ClientWebSocket when it fails to connect (#47616)

Somehow when it was ported to .NET Core, the transition from connecting to connected was switched to being done before the connect rather than after.  As a result, if the connection fails and the websocket is never initialized, subsequent use (misuse) ends up null ref'ing.  This restores the .NET Framework behavior, which was to dispose of the instance if the connect fails; subsequent operations then throw ObjectDisposedException.

3 years agoFix some valgrind warnings about jumps based on uninitialized values. (#47620)
Tom Deseyn [Fri, 29 Jan 2021 14:23:07 +0000 (15:23 +0100)]
Fix some valgrind warnings about jumps based on uninitialized values. (#47620)

3 years ago[Bug Fixed] Modify the exception handling when reading the status of "/proc/" (#47611)
JongHeonChoi [Fri, 29 Jan 2021 09:48:03 +0000 (18:48 +0900)]
[Bug Fixed] Modify the exception handling when reading the status of "/proc/" (#47611)

3 years agoJIT: let instrumentor decide which blocks to process (#47597)
Andy Ayers [Fri, 29 Jan 2021 01:24:02 +0000 (17:24 -0800)]
JIT: let instrumentor decide which blocks to process (#47597)

Forthcoming edge-based instrumentation will need to handle some BBF_INTERNAL
blocks, so update main processing logic to accomodate this.

Also have `fgInstrument` return proper phase status, so we get after-phase
dumping if any instrumentation is added.

3 years ago[debugger] Fix comparison between pointer and zero (#47590)
monojenkins [Fri, 29 Jan 2021 00:18:25 +0000 (19:18 -0500)]
[debugger] Fix comparison between pointer and zero (#47590)

During my last PR about icordebug I included this error, fixing it.

Co-authored-by: thaystg <thaystg@users.noreply.github.com>
3 years agoUnify mono/coreclr xplat-job.yml templates (#47588)
Alexander Köplinger [Thu, 28 Jan 2021 22:38:08 +0000 (23:38 +0100)]
Unify mono/coreclr xplat-job.yml templates (#47588)

They were nearly identical already, move them to a common location.

3 years agoDisable TryGetAddrInfo_ExternalHost on android (#47594)
Juan Hoyos [Thu, 28 Jan 2021 20:53:30 +0000 (12:53 -0800)]
Disable TryGetAddrInfo_ExternalHost on android (#47594)

3 years agoAdd NotNullWhen(true) on Directory/File.Exists (#47579)
Huo Yaoyuan [Thu, 28 Jan 2021 20:30:21 +0000 (04:30 +0800)]
Add NotNullWhen(true) on Directory/File.Exists (#47579)

* Add NotNullWhen(true) on Directory/File.Exists.

* Apply suggestions.

3 years agoImprove msg for missing libicu (#47511)
Dan Moseley [Thu, 28 Jan 2021 17:26:35 +0000 (09:26 -0800)]
Improve msg for missing libicu (#47511)

* Improve msg for missing libicu

* add comment

* add aka.ms

* better link

3 years agoRetry sem_wait() on EINTR (#47536)
Steve MacLean [Thu, 28 Jan 2021 17:22:14 +0000 (12:22 -0500)]
Retry sem_wait() on EINTR (#47536)

3 years agoUpdate CredScanSuppressions.json (#47572)
Juan Hoyos [Thu, 28 Jan 2021 17:08:49 +0000 (09:08 -0800)]
Update CredScanSuppressions.json (#47572)

3 years agoFix a warning in mono/mini/tramp-arm.c and tramp-ppc.c (#47576)
Alexander Köplinger [Thu, 28 Jan 2021 16:33:09 +0000 (17:33 +0100)]
Fix a warning in mono/mini/tramp-arm.c and tramp-ppc.c (#47576)

Same as https://github.com/dotnet/runtime/pull/47417

3 years agoCause a connection abort when HTTP/2-only frame and settings types are received in...
Cory Nelson [Thu, 28 Jan 2021 16:27:46 +0000 (08:27 -0800)]
Cause a connection abort when HTTP/2-only frame and settings types are received in HTTP/3. (Progress toward HTTP/3 draft 31 compat) (#43287)

Send h3-29 through h3-31 for ALPN as we are compatible with all of them.
Move some of the loopback test code into the stream class rather than connection class.
Add a basic test for SETTINGS frame receipt.
Fix some tests that were explicitly using Http3LoopbackServer and did not see the new "Mock" QUIC setting introduced in https://github.com/dotnet/runtime/pull/43076

3 years agoMake SNI unique in TLS test (#47459)
Jan Jahoda [Thu, 28 Jan 2021 16:23:39 +0000 (17:23 +0100)]
Make SNI unique in TLS test (#47459)

* Randomize SNI

* remove debug message

* Fix the http test

* Add explanation comment

* Remove accidental indentation

3 years agoFix mono rpm build (#47577)
monojenkins [Thu, 28 Jan 2021 15:39:36 +0000 (10:39 -0500)]
Fix mono rpm build (#47577)

debugger-protocol.h was missing from the tarball

Co-authored-by: akoeplinger <akoeplinger@users.noreply.github.com>
3 years agoResolve ILLink warnings in System.Net.Http (#47501)
Jose Perez Rodriguez [Thu, 28 Jan 2021 15:02:59 +0000 (07:02 -0800)]
Resolve ILLink warnings in System.Net.Http (#47501)

3 years ago[wasm] Add ability to link out unused icalls by setting the WasmLinkIcalls msbuild...
Zoltan Varga [Thu, 28 Jan 2021 13:51:30 +0000 (08:51 -0500)]
[wasm] Add ability to link out unused icalls by setting the WasmLinkIcalls msbuild property. (#44236)

* [wasm] Add ability to link out unused icalls by setting the WasmLinkIcalls msbuild property.

* Address review comments.

3 years agoFix assert on unhandled SIGSEGV (#47538)
Jan Vorlicek [Thu, 28 Jan 2021 13:12:40 +0000 (14:12 +0100)]
Fix assert on unhandled SIGSEGV (#47538)

When SIGSEGV is not handled by .NET runtime (e.g. when it occurs in code
out of its control), the SIGSEGV handler ends up calling
DiagnosticServer::Shutdown in the runtime via a registered shutdown callback.
That method ends up calling Thread::GetFrame, which asserts if the
current SP is out of a valid range for the regular stack. The problem is
that SIGSEGV handler is called on an alternate stack and so this
callback ends up being called on that stack too. That causes this
assertion to fail, because the current thread is not marked as executing
on alternate stack, which would skip that assert.

This change fixes it by passing through a bool flag indicating whether
the callback was called on an alternate stack or not. And in that
callback, we set the flag on the thread accordingly.

3 years ago[llvmonly] Fall back to the interpreter for methods with filter clauses. (#47551)
monojenkins [Thu, 28 Jan 2021 12:31:27 +0000 (07:31 -0500)]
[llvmonly] Fall back to the interpreter for methods with filter clauses. (#47551)

Instead of failing to compile methods with filter clauses, make them
enter the interpreter.

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
3 years agoFix a warning in mono/mini/tramp-x86.c (#47417)
monojenkins [Thu, 28 Jan 2021 12:01:06 +0000 (07:01 -0500)]
Fix a warning in mono/mini/tramp-x86.c  (#47417)

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
3 years agoDisable ClosedDuringOperation_Throws_ObjectDisposedExceptionOrSocketException (#47571)
Juan Hoyos [Thu, 28 Jan 2021 10:36:52 +0000 (02:36 -0800)]
Disable ClosedDuringOperation_Throws_ObjectDisposedExceptionOrSocketException (#47571)

3 years agoAdd Mono EventPipe rundown support. (#47339)
Johan Lorensson [Thu, 28 Jan 2021 10:31:06 +0000 (11:31 +0100)]
Add Mono EventPipe rundown support. (#47339)

* Add Mono EventPipe rundown support.

Add support into Mono VM emitting rundown events into EventPipe stream.
All rundown events emitted by CoreClr during EventPipe rundown phase
are now also emitted by Mono, making sure enough meta information
is available for tooling to correctly resolve callstacks (not yet emitted)
included in EventPipe events emitted by Mono VM.

3 years agoPrevent IpcTraceTest to hang on test failures. (#47529)
Johan Lorensson [Thu, 28 Jan 2021 10:30:07 +0000 (11:30 +0100)]
Prevent IpcTraceTest to hang on test failures. (#47529)

If an exception is throwed in IpcTraceTest::Validate readerTask before
it signals sentinelEventReceived, test will hang on:

sentinelEventReceived.WaitOne();

When hitting this case the error is hard to spot and looks like a
hanging IPC client, but when looking at it from the runtime side
you get a correct close of IPC channel and termination of streaming
thread.

I have hit this in a scenario where we hit an exception deep within
EventPipeEventSource constructor, in that case due to a runtime issue
loading a library on Windows, but since the exception is not rethrown
from the task, no error is seen on client side, the test will just hang
forever.

With this fix, the test will wait on either the sentinelEventReceived
or readerTask and if readerTask get signaled due to an exception,
it will be re-throwed all the way up to RunAndValidateEventCounts
printing test failure and exception info into the log, simplify the
debugging of these kind of failures a lot.

3 years agoStop localizing '<Unknown>' and '<In Memory Module>' strings (#47437)
Andy Gocke [Thu, 28 Jan 2021 06:42:05 +0000 (22:42 -0800)]
Stop localizing '<Unknown>' and '<In Memory Module>' strings (#47437)

GetFullyQualifiedName returns special strings for modules without
paths. Those names are currently localized. To improve predictability,
this change removes localization for these strings.

3 years agoMake the GetAppDomainStaticAddress test more stable (#47454)
Andrew Au [Thu, 28 Jan 2021 06:04:32 +0000 (22:04 -0800)]
Make the GetAppDomainStaticAddress test more stable (#47454)

* Make the GetAppDomainStaticAddress test more stable

* fix lock issues in profiler tests

* Code review feedback

Co-authored-by: David Mason <davmason@microsoft.com>
3 years agoResolve ILLink warnings in System.Diagnostics.TraceSource (#47419)
Eric Erhardt [Thu, 28 Jan 2021 02:50:07 +0000 (20:50 -0600)]
Resolve ILLink warnings in System.Diagnostics.TraceSource (#47419)

Contributes to #45623

3 years agoJIT: refactor instrumentation code (#47509)
Andy Ayers [Thu, 28 Jan 2021 02:28:22 +0000 (18:28 -0800)]
JIT: refactor instrumentation code (#47509)

Refactor `fgInstrument` and related methods and classes, so that the strategies
for block and class instrumentation are clearly separated out, and can be
varied.

3 years agoRemove more LINQ from DependencyInjection (#47496)
Stephen Toub [Thu, 28 Jan 2021 02:20:16 +0000 (21:20 -0500)]
Remove more LINQ from DependencyInjection (#47496)

3 years ago[interp] basic_blocks list improvements (#47505)
Aleksey Kliger (λgeek) [Thu, 28 Jan 2021 00:30:45 +0000 (19:30 -0500)]
[interp] basic_blocks list improvements (#47505)

* [interp] Add basic blocks in reverse order, then reverse

g_list_append has to repeatedly traverse the list using g_list_last to
find the last element.

Instead use g_list_prepend to add the new bb to the front of the list
and then reverse at the end (g_list_reverse is inplace and doesn't allocate)

* [interp] Don't generate basic_blocks list if not generating seq points

Still fill in offset_to_bb, but don't make a list unless needed.

3 years ago[Arm64] Implement MultiplyHigh (#47362)
Egor Chesakov [Thu, 28 Jan 2021 00:23:45 +0000 (16:23 -0800)]
[Arm64] Implement MultiplyHigh (#47362)

3 years agoActivity Status support (#47506)
Tarek Mahmoud Sayed [Thu, 28 Jan 2021 00:03:39 +0000 (16:03 -0800)]
Activity Status support (#47506)

* Activity Status support

* Apply the agreed on behavior

3 years ago[Mono][LLVM][ARM] Implemented Arm64 Abs intrinsic (#47482)
Nathan Ricci [Wed, 27 Jan 2021 23:16:21 +0000 (18:16 -0500)]
[Mono][LLVM][ARM] Implemented Arm64 Abs intrinsic (#47482)

* Implemented AdvSimd Abs intrinsic on arm64

3 years agoAdd initial support for System.Runtime.Intrinsics.Arm.Sha1 (#47467)
Fan Yang [Wed, 27 Jan 2021 19:38:13 +0000 (14:38 -0500)]
Add initial support for System.Runtime.Intrinsics.Arm.Sha1 (#47467)

3 years agoEnable scripting of SuperPMI collection of crossgen2 compilations (#47513)
Bruce Forstall [Wed, 27 Jan 2021 19:37:31 +0000 (09:37 -1000)]
Enable scripting of SuperPMI collection of crossgen2 compilations (#47513)

`superpmi.py collect` has a new `--crossgen2` option that specifies
to run crossgen2 on all the assemblies specified with the
`-assemblies` option.

For example:
```
py c:\rt\src\coreclr\scripts\superpmi.py collect --crossgen2 -output_mch_path c:\win-x64-cg2.mch -assemblies c:\rt\artifacts\tests\coreclr\windows.x64.Checked\Tests\Core_Root\System.Private.CoreLib.dll
```

There are currently quite a few failures during the replay
"cleaning" phase with a System.Private.CoreLib collection:
5654 compilation failures out of 14705 functions, including 100
JIT asserts.

In contrast, the crossgen(1) collection has 3 failures out
of 20165 functions.

So, there is some work to be done to make SuperPMI collection
of crossgen2 compilations work well.

The change in spmirecordhelper.h is to work around what appears to
be a crossgen2 bug: when the JIT calls `getCallInfo`, sometimes crossgen2
sets sig.sigInst.methInstCount in the result CORINFO_CALL_INFO to non-zero,
but it sets sig.sigInst.methInst to `nullptr`, which should be illegal:
the count indicates how many elements are in the array, so you can?t have a
null array with a non-zero count. Maybe the JIT doesn?t look at these fields in this
scenario for some reason, but SPMI tries to serialize/de-serialize the array,
and was crashing.

Fixes #45909

3 years agoRefactor Socket.SendFile tests and extend coverage (#47479)
Anton Firszov [Wed, 27 Jan 2021 19:00:31 +0000 (20:00 +0100)]
Refactor Socket.SendFile tests and extend coverage (#47479)

Refactor tests in SendFile.cs to utilize SocketTestHelper<T>
As a result cover some cases which were uncovered before (for example Dispose VS async).
Add more checks and tests as discussed in #47230.

3 years agoMinor cleanup for Rfc2898DeriveBytes
Kevin Jones [Wed, 27 Jan 2021 18:06:24 +0000 (13:06 -0500)]
Minor cleanup for Rfc2898DeriveBytes

The _password field is not needed since CryptDeriveKey was not ported
from the Desktop framework.

Removing the field also allows removing a defensive copy and clearing it
during disposal.

3 years agoFix parsing of standard format string (#47353)
Prashanth Govindarajan [Wed, 27 Jan 2021 17:45:25 +0000 (09:45 -0800)]
Fix parsing of standard format string (#47353)

* BigInteger changes

* sq

* Runtime side unit tests

* Half tests

* Address feedback

* sq

* Move to a ThrowHelper class

* Move to invariant number format

* Move to canonical throw

* sq

* sq

* Fix bad unicode char

* Add the percent tests back

3 years agoMark list for regions (#46979)
Peter Sollich [Wed, 27 Jan 2021 16:50:02 +0000 (17:50 +0100)]
Mark list for regions (#46979)

This checkin adapts the mark list logic for regions.

The basic idea is that as plan_phase goes through the regions, it calls get_region_mark_list obtain the mark list for each region.

How get_region_mark_list works is different for WKS and SVR flavors of the GC:

 - for WKS, we have a single sorted mark list. Finding the mark list section corresponding to a region is done via binary search in the mark list.

 - for SVR, each GC thread, after sorting the mark list, determines where the sections corresponding to all the regions start and end. This is stored in tables mark_list_piece_start and mark_list_piece_end which are now indexed by region number. Later, get_region_mark_list merges the pieces for a region from all heaps. This is very similar to what merge_mark_lists did before.

3 years agoAdd new Task-based UDP socket methods and reimplement existing ones using SocketAsync...
Anton Firszov [Wed, 27 Jan 2021 15:25:59 +0000 (16:25 +0100)]
Add new Task-based UDP socket methods and reimplement existing ones using SocketAsyncEventArgs (#47229)

Closes #41502, but does not change the existing APM methods

3 years ago[master] Update dependencies from mono/linker (#47495)
dotnet-maestro[bot] [Wed, 27 Jan 2021 09:03:24 +0000 (10:03 +0100)]
[master] Update dependencies from mono/linker (#47495)

Microsoft.NET.ILLink.Tasks
 From Version 6.0.0-alpha.1.21075.2 -> To Version 6.0.0-alpha.1.21076.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
3 years agoSupport Async DNS lookup on older Windows from impersonificated context (#47435)
Tomas Weinfurt [Wed, 27 Jan 2021 04:58:05 +0000 (20:58 -0800)]
Support Async DNS lookup on older Windows from impersonificated context (#47435)

* test WindowsIdentityImpersonatedTests runs

* fix win8

* add test variant

* final cleanup

3 years agoPgo phase2 (#47055)
David Wrighton [Wed, 27 Jan 2021 03:48:37 +0000 (19:48 -0800)]
Pgo phase2 (#47055)

Funnel PGO instrumentation data from runtime to crossgen2

- Representation of instrumentation data within crossgen2 and dotnet-pgo
- New uncompressed mibc format for easier debugging/faster processing
- Storage of instrumentation data in mibc file
- Parser for instrumentation data to load from mibc file
- Translation of crossgen2 in memory representation of instrumentation data from managed form to jit

Future PGO work will include
- Instrumentation data storage and extraction from R2R files
- Move Pgo type handle histogram processing into JIT (which will make type guessing work in crossgen2 as well as in the runtime)
- Triggers for controlling Pgo data extraction
- Size control for pgo instrumentation data

3 years agoClean up crossgen2.csproj file (#47502)
Anton Lapounov [Wed, 27 Jan 2021 03:30:34 +0000 (19:30 -0800)]
Clean up crossgen2.csproj file (#47502)

• Avoid double-writing of crossgen2\clrjit_win_x64_x64.dll file.
• Avoid extra slashes in paths.

3 years agoJIT: run instrumentation phase just after importing (#47476)
Andy Ayers [Wed, 27 Jan 2021 01:41:45 +0000 (17:41 -0800)]
JIT: run instrumentation phase just after importing (#47476)

As a prerequisite to enabling efficient instrumentation, add instrumentation
immediately after importing, so the flow graph more closely reflects the IL
level view.

3 years agoTake SuppressGCTransition into account in IL stub caching (#47320)
Elinor Fung [Wed, 27 Jan 2021 01:35:14 +0000 (17:35 -0800)]
Take SuppressGCTransition into account in IL stub caching (#47320)

* Use SHash instead of CClosedHash for ILStubCache
* Use updated stub flags (taking into account SuppressGCTransition) when caching
* Add tests

3 years ago[mono] LLVM on arm64 bugfixes. (#47391)
imhameed [Wed, 27 Jan 2021 01:23:08 +0000 (17:23 -0800)]
[mono] LLVM on arm64 bugfixes. (#47391)

Adds a case for `DW_CFA_offset_extended` to `mono_print_unwind_info`,
which avoids a crash when running the runtime with high verbosity.

Initializes the LLVM JIT with LLVM-detected host CPU features.
Unconditionally enables all detected features, instead of using only the
subset supported in `mono_llvm_get_cpu_features`.

3 years agoImplement Activity.GetTagItem (#47443)
Tarek Mahmoud Sayed [Wed, 27 Jan 2021 01:14:50 +0000 (17:14 -0800)]
Implement Activity.GetTagItem (#47443)

* Implement Activity.GetTagItem

* Address the feedback

3 years agoDisable DisableAiaOptionWorks on macOS (#47497)
Juan Hoyos [Wed, 27 Jan 2021 00:57:53 +0000 (16:57 -0800)]
Disable DisableAiaOptionWorks on macOS (#47497)

3 years agoUpdate to dotnet/runtime version 6.0.0-preview.2.21076.5 (#47489)
Eric StJohn [Tue, 26 Jan 2021 23:37:54 +0000 (15:37 -0800)]
Update to dotnet/runtime version 6.0.0-preview.2.21076.5 (#47489)

Build ID 20210126.5

3 years agoResolve ILLink warnings in System.Security.Cryptography.Csp (#47439)
Eric Erhardt [Tue, 26 Jan 2021 22:43:59 +0000 (16:43 -0600)]
Resolve ILLink warnings in System.Security.Cryptography.Csp (#47439)

Contributes to #45623

3 years agoDelete fallback to load mscorrc.dll from current directory (#47464)
Jan Kotas [Tue, 26 Jan 2021 22:41:39 +0000 (14:41 -0800)]
Delete fallback to load mscorrc.dll from current directory (#47464)

3 years agoFix m_isSuspendedForGarbageCollection (#47494)
Steve MacLean [Tue, 26 Jan 2021 22:27:29 +0000 (17:27 -0500)]
Fix m_isSuspendedForGarbageCollection (#47494)

3 years agoDelete dead code (#47452)
Jan Kotas [Tue, 26 Jan 2021 22:11:51 +0000 (14:11 -0800)]
Delete dead code (#47452)

3 years agoDisable VerifyFloatToUInt and VerifyFloatToNullableUInt tests (#47380)
Egor Bogatov [Tue, 26 Jan 2021 21:00:14 +0000 (00:00 +0300)]
Disable VerifyFloatToUInt and VerifyFloatToNullableUInt tests (#47380)

3 years agoRemove lots of boxing from EnvironmentVariablesConfigurationProvider.Load (#47453)
Stephen Toub [Tue, 26 Jan 2021 20:35:37 +0000 (15:35 -0500)]
Remove lots of boxing from EnvironmentVariablesConfigurationProvider.Load (#47453)

3 years ago[mono][debugger] First PR to implement iCorDebug on mono (#47135)
Thays Grazia [Tue, 26 Jan 2021 20:22:55 +0000 (17:22 -0300)]
[mono][debugger] First PR to implement iCorDebug on mono (#47135)

The goal of this PR is change the current files to support the implementation of iCorDebug on mono:

- Split debugger-agent into debugger-protocol and debugger-agent, debugger-protocol will be used in the next PR in mscordbi implementation.
- Fix strings with the meaning of the commands, there were missing strings and then the PRINT_DEBUG_MSG was printing wrong information.
- On debugger-engine pass the offset of the IL when stop in a breakpoint.
- Created a new protocol major version to support the changes that we need to implement mscordbi.
- When mono debugger is started with server=n will waint until the timeout for a server to connect, this is necessary because depending on how we will launch the process with iCorDebug implementation, maybe mono will start before the debugger server(mscordbi).

3 years agoCalculate loopSize based on post align adjusted size (#47350)
Kunal Pathak [Tue, 26 Jan 2021 20:08:05 +0000 (12:08 -0800)]
Calculate loopSize based on post align adjusted size (#47350)

* Calculate loopSize based on post align adjusted size

* Review comments

Remove `paddingNeeded` as we can get that value from `idCodeSie()`.

3 years ago[Arm64] Use SIMD register to zero init frame (#46609)
Egor Chesakov [Tue, 26 Jan 2021 19:51:01 +0000 (11:51 -0800)]
[Arm64] Use SIMD register to zero init frame (#46609)

* Inline "stp q-reg, q-reg, addr-reg" for frames >= 32 bytes

* Use a pair of "stp q-reg, q-reg, addr-reg" in a loop that clears 64 bytes per iteration for frames >= 192 bytes

* Use dc zva instruction when the instruction is permitted and its block size is set to 64 bytes for frames >= 256 bytes

3 years agoAdd test coverage for SzArray constructors (#47400)
Michal Strehovský [Tue, 26 Jan 2021 18:43:35 +0000 (19:43 +0100)]
Add test coverage for SzArray constructors (#47400)

I couldn't find a single occurence of `[]::` in the test tree, so I assume we don't have any coverage for this.

Arrays are normally allocated with the dedicated `newarr` IL instruction. The ECMA-335 specification says "All zero-based, one-dimensional arrays are created using newarr, not newobj.". Nevertheless, they do have a constructor and apparently code out there uses it.

Also adding coverage for the constructor that creates a jagged array.

Regression test for https://github.com/dotnet/runtimelab/issues/578.

3 years agoFix building libraries with Ninja. (#47344)
Jeremy Koritzinsky [Tue, 26 Jan 2021 17:31:16 +0000 (09:31 -0800)]
Fix building libraries with Ninja. (#47344)

3 years agoHandle X509 policy constraints on macOS.
Kevin Jones [Tue, 26 Jan 2021 16:50:39 +0000 (11:50 -0500)]
Handle X509 policy constraints on macOS.

3 years agoPublic sign ilasm output by default (#47448)
Jan Kotas [Tue, 26 Jan 2021 16:44:34 +0000 (08:44 -0800)]
Public sign ilasm output by default (#47448)

Fixes #47426

3 years agoUse a separate thread for tiered compilation background work (#45901)
Koundinya Veluri [Tue, 26 Jan 2021 15:51:37 +0000 (07:51 -0800)]
Use a separate thread for tiered compilation background work (#45901)

Use a separate thread for tiered compilation background work

- Makes it easier to manage how much time is spend for performing background work like rejitting and allows yielding more frequently with just Sleep without incurring thread pool overhead, which is useful in CPU-limited cases
- A min/max range is determined for how long background work will be done before yielding the thread. The max is the same as before, 50 ms. For now the min is `processor count` ms (capped to the max), such that in CPU-limited cases the thread would yield more frequently in order to not monopolize too much of the limited CPU resources for background work, and in cases with a larger number of processors where the background work is typically less intrusive to foreground work it would yield less frequently.
- At the same time, progress should be made on background work such that steady-state perf would be reached in reasonable time. Yielding too frequently can slow down the background work too much. The sleep duration is measured to identify oversubscribed situations to yield less frequently and make faster progress on the background work.
- Due to less time spent rejitting in some CPU-limited cases, steady-state performance may be reached a bit later in favor of fewer spikes along the way
- When the portable thread pool is enabled, a side effect of using a managed worker thread for tiering background work was that several GC-heavy microbenchmarks regressed. Tiering was the only thing using the thread pool in those tests and stack-walking the managed thread was slower due to the presence of GC refs. It's not too concerning, the benchmarks are just measuring something different from before, but in any case this change also resolves that issue. Fixes https://github.com/dotnet/runtime/issues/44211.

3 years ago[master] Update dependencies from mono/linker (#47411)
dotnet-maestro[bot] [Tue, 26 Jan 2021 15:14:31 +0000 (16:14 +0100)]
[master] Update dependencies from mono/linker (#47411)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
3 years agoSystem.Random performance tuning. (#47390)
Colin Green [Tue, 26 Jan 2021 14:50:55 +0000 (14:50 +0000)]
System.Random performance tuning. (#47390)

* Performance tuning Xoshiro pseudo random number generators. Move PRNG state from the heap onto the stack before performong PRNG generation and mxing operations.

* Declare PRNG state method variables on single line (code review feedback nit).

3 years ago[wasm] Handle Top-Level style entry point mangling too (#47405)
Larry Ewing [Tue, 26 Jan 2021 14:22:44 +0000 (08:22 -0600)]
[wasm] Handle Top-Level style entry point mangling too (#47405)

* [wasm] Handle Top-Level style entry point mangling too

This adds a check for '<Main>$' in addition to 'Main' when
looking for the async entry point.

Fixes #47404

3 years agoSearch libgdiplus in macports install location (#47373)
Adeel Mujahid [Tue, 26 Jan 2021 13:18:12 +0000 (15:18 +0200)]
Search libgdiplus in macports install location (#47373)

When `libgdiplus` is installed via macports, `System.TypeInitializationException` exception is thrown.
This is because macports installs the library in `/opt/local/lib`.

```sh
$ port install libgdiplus
$ port contents libgdiplus
Port libgdiplus contains:
  /opt/local/lib/libgdiplus.0.dylib
  /opt/local/lib/libgdiplus.a
  /opt/local/lib/libgdiplus.dylib
  /opt/local/lib/pkgconfig/libgdiplus.pc
  /opt/local/share/doc/libgdiplus/AUTHORS
  /opt/local/share/doc/libgdiplus/COPYING
  /opt/local/share/doc/libgdiplus/ChangeLog
  /opt/local/share/doc/libgdiplus/LICENSE
  /opt/local/share/doc/libgdiplus/NEWS
  /opt/local/share/doc/libgdiplus/README.md
  /opt/local/share/doc/libgdiplus/TODO
```

PR adds `/opt/local/lib/libgdiplus.dylib` as a well-known probing path.

3 years ago[wasm] Emit some wrappers with linkonce linkage. (#47384)
monojenkins [Tue, 26 Jan 2021 09:41:40 +0000 (04:41 -0500)]
[wasm] Emit some wrappers with linkonce linkage. (#47384)

<!--
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: vargaz <vargaz@users.noreply.github.com>
3 years agoadded the exports (#47451)
Vladimir Sadov [Tue, 26 Jan 2021 06:06:11 +0000 (22:06 -0800)]
added the exports (#47451)

3 years agoFix for 46529 - Unexpected behaviour of ulong -> int cast (#47418)
Brian Sullivan [Tue, 26 Jan 2021 05:15:03 +0000 (21:15 -0800)]
Fix for 46529  - Unexpected behaviour of ulong -> int cast (#47418)

* Fix for issue 46529
Move check for side-effect and don't push the cast for shifts of 32 to 63
Added test Runtime_46239.cs

* clang format

3 years agoFix #46123 - make the subProtocol nullable for HttpListenerContext::AcceptWebSocketAs...
Euan [Tue, 26 Jan 2021 03:30:39 +0000 (03:30 +0000)]
Fix #46123 - make the subProtocol nullable for HttpListenerContext::AcceptWebSocketAsync  (#47402)

* Fix #46123 - make `subProtocol` nullable when dealing with WebSockets in HttpListener.

* Update ref for System.Net.HttpListener

3 years agoJIT: split up some parts of flowgraph.cpp (#47072)
Andy Ayers [Tue, 26 Jan 2021 02:37:11 +0000 (18:37 -0800)]
JIT: split up some parts of flowgraph.cpp (#47072)

Create a number of smaller files with cohesive sets of methods.

3 years agoDebugging Crossgen2 documentation (#47363)
David Wrighton [Tue, 26 Jan 2021 02:21:48 +0000 (18:21 -0800)]
Debugging Crossgen2 documentation (#47363)

* Debugging Crossgen2 documentation and such
- Also new --print-repro-instructions command line switch to crossgen2 as requested by the JIT team

3 years agoHTTP Compression - Improve/fix support for user-specified Accept-Encoding encodings...
Eaton [Tue, 26 Jan 2021 00:33:46 +0000 (19:33 -0500)]
HTTP Compression - Improve/fix support for user-specified Accept-Encoding encodings (#47000)

Improve support for user-specified Accept-Encoding encodings

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
3 years agoGet rid of StreamWriter usage in HTTP loopback server and fix HTTP/1.1 loopback imple...
Geoff Kizer [Tue, 26 Jan 2021 00:30:29 +0000 (16:30 -0800)]
Get rid of StreamWriter usage in HTTP loopback server and fix HTTP/1.1 loopback implementation of SendResponseBodyAsync (#47364)

Get rid of StreamWriter usage in HTTP loopback server and fix HTTP/1.1 loopback implementation of SendResponseBodyAsync

Co-authored-by: Geoffrey Kizer <geoffrek@windows.microsoft.com>
3 years agoResolve ILLink warnings in System.Security.Cryptography.X509Certificates (#47345)
Eric Erhardt [Tue, 26 Jan 2021 00:04:12 +0000 (18:04 -0600)]
Resolve ILLink warnings in System.Security.Cryptography.X509Certificates (#47345)

* Resolve ILLink warnings in System.Security.Cryptography.X509Certificates

Contributes to #45623

* Use ConstructorInfo to create HttpRequestMessage instances.

3 years agoupdate branding to preview22 (#47429)
Anirudh Agnihotry [Mon, 25 Jan 2021 22:54:24 +0000 (14:54 -0800)]
update branding to preview22 (#47429)

3 years ago[wasm] WasmApp.targets: Separate `obj`, and `bin` parts of the build process (#47253)
Ankit Jain [Mon, 25 Jan 2021 22:53:51 +0000 (17:53 -0500)]
[wasm] WasmApp.targets: Separate `obj`, and `bin` parts of the build process (#47253)

We want to use a separate directory for intermediate build outputs, that aren't needed
in the app bundle, and reduce unclear internal dependencies during a build.

# TL;DR

## Changes:
1. `$(WasmBuildDir)` removed
2. Reasonable defaults set for most properties
3. To generate a wasm app for a project, the minimum you need to set:
    a. `$(WasmMainJS)`,
    b. and `@(WasmAssembliesToBundle)`

# Details:

Though it is a bit tricky, because the current targets assume:

- that they are being run after `Publish`
- that the publish directory has:
  - some required files copied over from the runtime pack (eg. `libmono*`),
  - and includes the assemblies
- that the targets emit all the intermediate output files like `driver.o`, or the bitcode files, into the same
   directory

- And there are assumptions about where to pick which files from (eg. whether to take `dotnet.wasm`
  from the runtime pack, or from the publish dir), based on unclear rules.

## What does this PR change?

- All the assets meant to be from the runtime pack (like `libmono*`, `icudt.dat`) are always taken
  only from the runtime pack
  - and this logic is moved out of the tasks, to the targets
- `$(WasmBuildDir)` is removed completely. Instead, we use an intermediate path based on `$(IntermediateOutputPath)`
  - and emit all the intermediate bits there, like the bitcode files
- Add reasonable defaults for various properties, like `$(WasmAppDir)`

Effectively:

1. To generate a wasm app for a project, the minimum you need to set:
    a. `$(WasmMainJS)`,
    b. and `@(WasmAssembliesToBundle)`

2. The targets don't depend on publish dir at all
    (in a future PR, we could remove triggering based on `Publish` target also)
* [wasm] WasmAppBuilder - move the list of native assets, and logic out

.. to the targets.

- New property: `NativeAssets`, populated by `@(WasmNativeAsset)`
- Remove property `MicrosoftNetCoreAppRuntimePackRidDir`
- Also, add the `icudt.dat` file from the targets

* [wasm] Simplify handling of dotnet.{js,wasm}

WasmAppBuilder has (non-obvious) logic to:

1. if AOT'ing, then use the *generated* dotnet.{js,wasm};
2. else use the one from the runtime pack

This depends on Publish having copied those files from the runtime pack
to the publish directory, and then comparing paths in the builder to
decide which one to use.

Instead, make this the intention obvious, and clear.

----
Commits:
* [wasm] Always get the native libs from the runtime pack (eg.libmono*)

We were getting these from the publish directory, instead we can get
them directly from the runtime pack.

This includes icudt.dt, and dotnet.timezones.blat .

* [wasm] MonoAOTCompiler: add `OutputDir` property

.. where we can emit the generated native files. Since these files are
meant only for generating the final `dotnet.wasm`, we don't want them to
put them in the bin directory.

* [wasm] Use existing list of assemblies - @(_WasmAssemblies)

.. instead of trying to find them in the build dir. This build directory
will become a directory for intermediate build output in upcoming
commits.

* [wasm] Replace $(WasmMainAssemblyPath) with $(WasmMainAssemblyFileName)

- Instead of having a special $(WasmMainAssemblyPath), and then adding
  it to the wasm assemblies ourselves
  - let the user project add all the relevant assemblies to
    `@(WasmAssembliesToBundle)`, which is usually as simple as
    `$(OutDir)\*.dll`.

- This helps to simplify lot of things.
- And we just need the main assembly filename for generating the
  run-v8.sh script.

* [wasm] Rename WasmBuildDir -> _WasmIntermediateOutputPath

Based on the changes in previous commits, we can now remove
`$(WasmBuildDir)`, and replace that with an internal
`$(_WasmIntermediateOutputPath)`. This path will have all the build
artifacts generated that aren't required in the app bundle.

Earlier, we were using the publish directory for that, which resulted in
it being littered with unncessary files, and files getting copied to the
app bundle from unclear sources, and for non-obvious reasons.

* [wasm] add default value for $(WasmAppDir)

* [wasm] WasmApp.targets - misc cleanup

* [wasm] WasmAppBuilder: validate Assemblies property

* [wasm] WasmTestRunner - rename TestAssembly->TestAssemblyFileName, to correctly reflect the value

* [wasm] Fix make clean, for samples

* [wasm] WasmApp.targets: Add new $(MonoAotCrossCompilerPath)

* [wasm] update comments/docs

* Address review feedback from @mdh1418

3 years agoAdded C# implementation of System.Math.ScaleB and System.MathF.ScaleB… (#42476)
Alex Covington [Mon, 25 Jan 2021 22:11:45 +0000 (14:11 -0800)]
Added C# implementation of System.Math.ScaleB and System.MathF.ScaleB… (#42476)

* Added C# implementation of System.Math.ScaleB and System.MathF.ScaleB, removed old bindings, added test cases.

* Moved tests into System.Runtime.Extensions tests.

* Removed unmanaged scalbn and scalbnf from pal and mono

* Update src/libraries/System.Private.CoreLib/src/System/Math.cs

Co-authored-by: Adeel Mujahid <adeelbm@outlook.com>
* Styling changes.

* Conditionally include ScaleB for Mono.

* Update src/mono/mono/metadata/sysmath.c

Tabs, not spaces.

Co-authored-by: Adeel Mujahid <adeelbm@outlook.com>
* Removing more scalb from PAL

* Completely removed ScaleB from Mono

* Cleaning up more scalbn

* Added comments for ScaleB, updated licenses for musl and Sun

* Fixed whitespace.

* Removing old references, fixing double ScaleB definition that merge didn't resolve

Co-authored-by: Adeel Mujahid <adeelbm@outlook.com>
3 years agoComWrappers cleanup (#47312)
Aaron Robinson [Mon, 25 Jan 2021 21:23:35 +0000 (13:23 -0800)]
ComWrappers cleanup (#47312)

* Clean up interop shared data types with the DAC.

* Feedback from preview CR.

* Create specific CRST for the managed object wrapper map.

3 years agoUse correct CoreLib configuration for shared framework linker trimming (#45821)
Layomi Akinrinade [Mon, 25 Jan 2021 21:09:26 +0000 (13:09 -0800)]
Use correct CoreLib configuration for shared framework linker trimming (#45821)

* Use correct CoreLib configuration for shared framework linker trimming

* Add IL subdir to CoreLib path unconditionally

* Go back to using GetTargetPath, but flow rc to it

* Update CoreLibProject properties only when necessary

* Add link to CoreLib bin-placing issue and update RuntimeConfiguration in comment

3 years agoReturn accurate size of addressing mode dsp/dsp+cnst instr descriptor (#47284)
Kunal Pathak [Mon, 25 Jan 2021 20:25:03 +0000 (12:25 -0800)]
Return accurate size of addressing mode dsp/dsp+cnst instr descriptor (#47284)

* return accurate size for amd dsp and amd dsp+cnst

* fix the condition

3 years agoUpdate Environment.ProcessorCount on Windows to take into account the processor affin...
Koundinya Veluri [Mon, 25 Jan 2021 20:21:48 +0000 (12:21 -0800)]
Update Environment.ProcessorCount on Windows to take into account the processor affinity mask (#45943)

- Similarly to cases on Unixes where sched_getaffinity is available
- If `GCCpuGroup` and `Thread_UseAllCpuGroups` are both enabled, I'm not sure if the `CPUGroupInfo` count of active processors takes affinity into account as the docs are not clear, for now I'm not modifying that path until I can verify it
- Otherwise, a process that is started with a specific processor affinity mask still shows full CPU count
- This is one of the differences in the portable managed thread pool implementation, which relies on Environment.ProcessorCount, as opposed to the native thread pool, which uses the affinity mask
- After this change, in affinitized cases on Windows the behavior is consistent perf-wise with Linux in similar situations:
  - The portable thread pool uses the same worker thread count as the native thread pool
  - `Environment.ProcessorCount` returns the number of processors the the process is affinitized to, which may be less than it would have returned before

3 years agobandaid for #44072 (#47285)
John Salem [Mon, 25 Jan 2021 18:44:40 +0000 (10:44 -0800)]
bandaid for #44072 (#47285)

* real fix needs to happen in TraceEvent

3 years agoEnable COMPlus_JitDisasmWithGC with SuperPMI asm diffs (#46966)
Bruce Forstall [Mon, 25 Jan 2021 18:17:37 +0000 (08:17 -1000)]
Enable COMPlus_JitDisasmWithGC with SuperPMI asm diffs (#46966)

All SPMI asm diffs (generated using superpmi.py) will
display interleaved GC info.

Note that you can also pass the `--gcinfo` option
to get traditional end-of-code asm dump, but that also
requires adding per-instruction offset output, which can lead
to excessive textual diffs.

3 years agoFix cancellation race condition in Parallel.ForEachAsync (#47396)
Stephen Toub [Mon, 25 Jan 2021 17:00:57 +0000 (12:00 -0500)]
Fix cancellation race condition in Parallel.ForEachAsync (#47396)

If cancellation is requested at just the "wrong" time, we may end up canceling the operation but reporting it as a successful completion, due to our relying on _registration.Token being the caller-provided token, but that not being the case if cancellation was requested prior to UnsafeRegister being called, in which case it'll return a default registration.

3 years agoupdate ownership (#47414)
Jeff Schwartz [Mon, 25 Jan 2021 16:56:15 +0000 (08:56 -0800)]
update ownership (#47414)

3 years agoAdd support for Arm intrinsics Sha256 (#47337)
Fan Yang [Mon, 25 Jan 2021 16:34:17 +0000 (11:34 -0500)]
Add support for Arm intrinsics Sha256 (#47337)

* Initial change for sha256

* Handles intrinsics with 3 parameters

* Fix condition

* Revert test change to HelloWorld sample

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

Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
* Fixed format

Co-authored-by: Ryan Lucia <ryan@luciaonline.net>
3 years agoRemove -Wc++-compat option when building Mono as C++ (#47370)
monojenkins [Mon, 25 Jan 2021 14:29:57 +0000 (09:29 -0500)]
Remove -Wc++-compat option when building Mono as C++ (#47370)

It causes a build warning on some newer compilers:

```
cc1plus: warning: command line option '-Wc++-compat' is valid for C/ObjC but not for C++
```

Co-authored-by: akoeplinger <akoeplinger@users.noreply.github.com>
3 years agoAdded Span overloads for Socket.SendFile (#47230)
Günther Foidl [Mon, 25 Jan 2021 09:52:51 +0000 (10:52 +0100)]
Added Span overloads for Socket.SendFile (#47230)

* Added Span overloads for Socket.SendFile

* Updated ref

* Fixed doc comments

* Tests

* Remove test for non-blocking

Cf. https://github.com/dotnet/runtime/pull/47230#discussion_r561983960

3 years agoVectorize HexConverter.EncodeToUtf16 using SSSE3 (#44111)
Egor Bogatov [Sun, 24 Jan 2021 19:30:51 +0000 (22:30 +0300)]
Vectorize HexConverter.EncodeToUtf16 using SSSE3 (#44111)

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>