platform/upstream/dotnet/runtime.git
2 years ago- reimplementation of BrowserWebSocket (#58199)
Pavel Savara [Sat, 18 Sep 2021 15:40:21 +0000 (17:40 +0200)]
- reimplementation of BrowserWebSocket (#58199)

- CC0 notice for JavaScript queue
- feedback

2 years agoCleanup defines in DirectoryServices.AccountManager (#59265)
Andrii Kurdiumov [Sat, 18 Sep 2021 14:00:07 +0000 (20:00 +0600)]
Cleanup defines in DirectoryServices.AccountManager (#59265)

Related to #39174
All defines does not used anywhere else and did not changed values.
From what I can find, they are from initial code dump

2 years agoMake GCMemoryInfoData blittable (#58738)
Michal Strehovský [Sat, 18 Sep 2021 05:47:04 +0000 (14:47 +0900)]
Make GCMemoryInfoData blittable (#58738)

The runtime side makes assumptions about the layout of this class, but since the class is not blittable, the runtime is free to reorder the fields however it sees fit (`StructLayout(LayoutKind.Sequential)` only affects the *managed* layout of blittable classes - it's not documented to do anything to the managed layout of non-blittable classes).

This prevents improvements to managed layout such as #51416.

Co-authored-by: Jan Kotas <jkotas@microsoft.com>
2 years agoJIT: update debug dumping for loop hoisting (#59287)
Andy Ayers [Sat, 18 Sep 2021 01:42:06 +0000 (18:42 -0700)]
JIT: update debug dumping for loop hoisting (#59287)

I kept adding stuff like this whenever I wanted to understand why hosting was
doing what it was doing, so figured it likely had lasting value.

2 years agoUse AVX2 in codegen for GT_STORE_BLK (#55604)
Alex Covington [Sat, 18 Sep 2021 01:12:03 +0000 (18:12 -0700)]
Use AVX2 in codegen for GT_STORE_BLK (#55604)

* Saving current state, current state does not currently pass tests

* Getting available vector register size from compiler instance instead, resolves failing tests.

* Emit vzeroupper if there is potentially an AVX-SSE transition

* Copy remainder using same tempReg allocated during SIMD moves instead of allocating a GPR

* Better guard for maximum SIMD register size

* Fix typo

* Remove commented out lines

* Insert vzeroupper if using AVX2

* Add another vzeroupper

* Remove vzeroupper, inserting the instruction hurts performance

* Adding vzeroupper again for testing

* Remove debug lines

* Add assert before copying remaining bytes, change regSize condition to depend on AVX, remove vzeroupper inserts.

* Fix typo

* Added check to ensure size is not 0 to prevent allocating register for structs of size 0.

* Using YMM registers during init block if block is large enough

* Add some comments

* Formatting

* Rename remainder variable to shiftBack, better describes the logic for the block.

* Use shift-back technique for init block as well.

* Add assert for init block

* Use xmm register to move remainder if it fits, shift-back for GPR for remainder instead of step-down

* Use xmm in init block for remainder if it is an appropriate size, shift-back for GPR in init instead of step-down register size

* Avoid allocating GPR during LSRA for BlkOpKindUnroll

* Remove shift-back of GPR for remainder, added back the step-down to resolve test failures on x86

* Shift-back GPR when handling remainder for AMD64 only

2 years agoFix a minor assert issue in long decomposition (#57326)
SingleAccretion [Sat, 18 Sep 2021 00:26:04 +0000 (03:26 +0300)]
Fix a minor assert issue in long decomposition (#57326)

* Add test

* Fix the issue

Rotation decomposition was risking hitting an
assert in LIR::Use::ReplaceWithLclVar when it
was removing the gtLong node from the linear
order too early.

* Revert "Add test"

No point testing what is not a correctness issue.

* Fix the same issue in shift decomposition as well

2 years agoFix x86 linux tests build and run (#57244)
t-mustafin [Sat, 18 Sep 2021 00:21:31 +0000 (03:21 +0300)]
Fix x86 linux tests build and run (#57244)

[unix x86] Fix tests build
[unix x86] Add register map for crossgen2
            Fixes readytorun/coreroot_determinism/coreroot_determinism/coreroot_determinism.sh on x86 linux
[unix x86] Fix tail calls tests
[unix x86] Fix unmanaged callconv
[unix x86] Fix passing implicit args via stack
[unix x86] Pop hidden retbuff arg on cdecl callconv
[unix x86] Fix WriteBarrier call

[x86] Add calling convention name print to dump
[x86] Use ebx to pass VASigCookie to GenericPInvokeCalliHelper
            It fixes stack alignment in GenericPInvokeCalliHelper on unix x86

Fix storageType overflow assertion in TinyArray

2 years agoExpose nint/nuint overloads for BitOperations (#58733)
Robin Lindner [Fri, 17 Sep 2021 23:31:07 +0000 (01:31 +0200)]
Expose nint/nuint overloads for BitOperations (#58733)

* Change access modifier of BitOperations.IsPow2

* Add CLSCompliant(false) attribute to BitOperations.IsPow2

* Add BitOperations.RoundUpToPowerOf2 method for nuint

* Add BitOperations.LeadingZeroCount method for nuint

* Add BitOperations.Log2 method for nuint

* Add BitOperations.PopCount method for nuint

* Add BitOperations.TrailingZeroCount for nint and nuint

* Add BitOperations.RotateLeft and BitOperations.RotateRight for nuint

* Replace Environment.Is64BitProcess check with preprocessor variable TARGET_64BIT and reimplement accidentally removed comment

* Fix formatting

* Remove last Environment.Is64BitProcess check

* Add tests

* Remove [CLSCompliant(false)] Attribute from BitOperations which use nint (not nuint)

* Add refs

* Add refs

* Fix RotateLeft and RotateRight test

* Add IgnoreOnArchitectureTheoryAttribute and remove checks for not existing preprocessor variable

* Replace custom TheoryAttribute with ConditionalTheory

* Add unchecked syntax due CS8778

* Fix parameter type in BitOperationsTests.BitOps_RoundUpToPow2_nuint_64

* Fix Test values

* Fix expectation parameter

* Fix 32-bit expectation

* Fix 32-bit test

2 years agoGet rid of ModuleDesc.GetTypeResolutionFailure (#59249)
Michal Strehovský [Fri, 17 Sep 2021 23:27:29 +0000 (08:27 +0900)]
Get rid of ModuleDesc.GetTypeResolutionFailure (#59249)

`ModuleDesc.GetTypeResolutionFailure` is bug prone (see #50845). It feels easier to just have `ModuleDesc.GetType` return `object`.

Most consumer will want to just call a helper that returns `MetadataType` and takes a `bool` though.

2 years agoWork around for forbidden "Roslyn4.0" in test name on Android (#59263)
Jo Shields [Fri, 17 Sep 2021 20:52:43 +0000 (16:52 -0400)]
Work around for forbidden "Roslyn4.0" in test name on Android (#59263)

Android apk names must be valid Java class names, and It is forbidden in Java for a class name component to have a leading numeric digit. So whilst "net.dot.foo3_1" is legal, "net.dot.foo3.1" is illegal. Use a Regex to detect and rewrite all cases of this in AndroidAppBuilder

2 years agoAllow folding of `LONG` nodes with field sequences (#57605)
SingleAccretion [Fri, 17 Sep 2021 20:19:18 +0000 (23:19 +0300)]
Allow folding of `LONG` nodes with field sequences (#57605)

* Allow folding of LONG nodes with field sequences

Apparently, such folding was disallowed, for unclear reasons
likely pertaining to the fact that "gtFoldExprConst" is very old.

* Drop the special case from fgMorphCommutative

2 years agoOnly set path in x64 mac installer when installing on x64 (#59210)
Eric StJohn [Fri, 17 Sep 2021 19:39:10 +0000 (12:39 -0700)]
Only set path in x64 mac installer when installing on x64 (#59210)

* Only set path in x64 mac installer when installing on x64

In other words don't set the path for x64 installer on ARM64

* Remove postinstall script from hostfxr

There should be no need for both the host and hostfxr to set the path to dotnet.

Since the host installs dotnet, it should be the only package responsible for this.

* Make postinstall set install_location on mac

Also refactor script to use a template so that we don't need to fork the script.

* fix some syntax errors in script

* Update src/installer/pkg/sfx/installers/dotnet-host.proj

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
* Refine uname regular expressions

Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
2 years ago[mono] Remove some of the restrictions on constrained calls from (#59182)
Zoltan Varga [Fri, 17 Sep 2021 19:29:02 +0000 (21:29 +0200)]
[mono] Remove some of the restrictions on constrained calls from (#59182)

* [mono] Remove some of the restrictions on constrained calls from
gsharedvt methods.

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

* Reenable tests.

2 years agoRefactor symmetric one-shots for improved performance
Kevin Jones [Fri, 17 Sep 2021 17:02:16 +0000 (13:02 -0400)]
Refactor symmetric one-shots for improved performance

This refactors the symmetric one shots to do less work. This removes the
calls to Reset for the one shots since the cipher will not be reused,
and in the Unix cases, removes keeping a copy of the IV around.

2 years ago[interp] Add wide data item index static load and stores (#59220)
Aleksey Kliger (λgeek) [Fri, 17 Sep 2021 16:35:48 +0000 (12:35 -0400)]
[interp] Add wide data item index static load and stores (#59220)

Add `ldsdfld.w` and `stsfld.w` opcodes to the interpreter.  These are needed for some machine-generated methods in Android projects that use AndroidX, MAUI, SkiaSharp or other toolkits.  The app's `Resource::UpdateIdValues` can grow to exceed 64k interpreter data items, which means that 16-bit data item indices will roll over.

A typical snippet from the method body:

```
    IL_8413:  ldc.i4     0x7f0f02fc
    IL_8418:  stsfld     int32 [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Style::Widget_MaterialComponents_Toolbar_Surface
    IL_841d:  ldc.i4     0x7f0f02fd
    IL_8422:  stsfld     int32 [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Style::Widget_MaterialComponents_Tooltip
    IL_8427:  ldc.i4     0x7f0f02fe
    IL_842c:  stsfld     int32 [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Style::Widget_Support_CoordinatorLayout
    IL_8431:  ldsfld     int32[] TestApp.Resource/Styleable::ActionBar
    IL_8436:  stsfld     int32[] [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Styleable::ActionBar
    IL_843b:  ldsfld     int32[] TestApp.Resource/Styleable::ActionBarLayout
    IL_8440:  stsfld     int32[] [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Styleable::ActionBarLayout
    IL_8445:  ldc.i4.0
    IL_8446:  stsfld     int32 [Microsoft.Maui.Controls.Compatibility]Microsoft.Maui.Controls.Compatibility.Resource/Styleable::ActionBarLayout_android_layout_gravity
```

The "wide" opcodes use 32-bit data item indices.

Resolves https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1398069

* [interp] Add stsfld.w interpreter opcode

   For methods that require more than 64k data items, add a variant stsfld instruction that stores data item indices as 32-bit integers instead of 16-bit.

   To solve this problem in general, we need wide variants of more opcodes, but for specific (machine generated) methods, a wide stsfld instruction is sufficient.

* Add ldsfld.w opcode

* [mono] Log debug message when running .cctors

* Address review feedback

   Use stackval_from_data and stackval_to_data instead of memcpy.

   Don't duplicate code get_data_item_wide_index.

   Only use the wide opcodes if any of the data item indices of a given instruction need it, not just when the method total number of indices overflows.

* Fix wide index boundary conditions

2 years agoRemove mostly unused SafeFileHandleHelper.Unix class (#59254)
Tom Deseyn [Fri, 17 Sep 2021 15:46:12 +0000 (17:46 +0200)]
Remove mostly unused SafeFileHandleHelper.Unix class (#59254)

2 years agoupdate crossfs for FreeBSD 12.2 (#59240)
Tomas Weinfurt [Fri, 17 Sep 2021 15:10:19 +0000 (08:10 -0700)]
update crossfs for FreeBSD 12.2 (#59240)

2 years ago[interp] Disable optimization if the var index is greater than G_MAXUINT16 (#59225)
Vlad Brezae [Fri, 17 Sep 2021 14:07:09 +0000 (17:07 +0300)]
[interp] Disable optimization if the var index is greater than G_MAXUINT16 (#59225)

We store the var index in the guint16 slots of the instruction

2 years ago[docs] Add instructions for debugging native runtime code on Android (#59183)
Aleksey Kliger (λgeek) [Fri, 17 Sep 2021 13:01:13 +0000 (09:01 -0400)]
[docs] Add instructions for debugging native runtime code on Android (#59183)

2 years agoFile.Unix: save a syscall on the File.{Write*,Append*} methods. (#59247)
Tom Deseyn [Fri, 17 Sep 2021 10:44:18 +0000 (12:44 +0200)]
File.Unix: save a syscall on the File.{Write*,Append*} methods. (#59247)

FileOptions.SequentialScan tunes the kernel read ahead. Since we're writing
the whole file it doesn't bring anything, and it costs us a syscall on Unix.

2 years agoRefactor XmlWriter{Async} (#58105)
kronic [Fri, 17 Sep 2021 10:25:11 +0000 (13:25 +0300)]
Refactor XmlWriter{Async} (#58105)

* Refactor XmlWriter

* Refactor XmlWriterAsync

* -

* review feedback

Co-authored-by: kronic <kronic@softland.ru>
2 years agoFix ro segments with regions (#58811)
Peter Sollich [Fri, 17 Sep 2021 06:49:42 +0000 (08:49 +0200)]
Fix ro segments with regions (#58811)

There were a couple places in the mark and relocation phases where the regions logic couldn't cope with objects outside of the memory range reserved for the GC heap. These objects may occur in read-only segments (but only if FEATURE_BASICFREEZE is enabled).

The check for objects within the address range reserved for the GC is centralized in helper is_in_heap_range. If FEATURE_BASICFREEZE is enabled, this helper checks that the object is actually in the address range for the heap, otherwise a simple check for non-null is sufficient. There are asserts to make sure that objects are either null, in range, or in a read-only segment if FEATURE_BASICFREEZE is enabled.

2 years ago[main] Update dependencies from 8 repositories (#59195)
dotnet-maestro[bot] [Fri, 17 Sep 2021 06:32:41 +0000 (06:32 +0000)]
[main] Update dependencies from 8 repositories (#59195)

[main] Update dependencies from 8 repositories

2 years agoFix corner-case handling of cancellation exception in ForEachAsync (#59065)
Stephen Toub [Fri, 17 Sep 2021 05:17:35 +0000 (01:17 -0400)]
Fix corner-case handling of cancellation exception in ForEachAsync (#59065)

* Fix corner-case handling of cancellation exception in ForEachAsync

If code in Parallel.ForEachAsync throws OperationCanceledExceptions containing the CancellationToken passed to the iteration and that token has _not_ had cancellation requested (so why are they throwing with it) and there are no other exceptions, the ForEachAsync will effectively hang after failing to complete the task returned from it.

The issue stems from how we treat cancellation.  If the user-supplied token hasn't been canceled but we have OperationCanceledExceptions for the token passed into the iteration (the "internal" token), it can only have been canceled because an exception occurred.  We filter out these cancellation exceptions, leaving just the exceptions that are deemed to have caused the failure in the first place.  But the code doesn't currently account for the possibility that the developer is (arguably erroneously) throwing such an OperationCanceledException with the internal cancellation token as that root failure. The fix is to only filter out these OCEs if there are other exceptions besides them.

* Stop filtering out cancellation exceptions in Parallel.ForEachAsync

2 years agoUpdate source-gen APIs according to review (#59042)
Layomi Akinrinade [Fri, 17 Sep 2021 04:18:23 +0000 (21:18 -0700)]
Update source-gen APIs according to review (#59042)

* Update source-gen APIs according to review

* Rename fast-path func name and add src-gen/JsonNode interop support

* Address review feedback

* Disable src-gen tests in browser target OS

2 years agoFreeBSD fix for AF_UNIX IPC socket permission (#58688)
Jason Pugsley [Fri, 17 Sep 2021 01:21:57 +0000 (11:21 +1000)]
FreeBSD fix for AF_UNIX IPC socket permission (#58688)

FreeBSD does not support changing AF_UNIX socket permissions with
chmod()/fchmod() so use the same umask() method as __APPLE__ builds.

2 years agoImprove morphing of comparisons (#54204)
SingleAccretion [Thu, 16 Sep 2021 23:46:52 +0000 (02:46 +0300)]
Improve morphing of comparisons (#54204)

* Add SetIntegralValue helper to GenTreeIntCommon

* Fix a potential CSE issue

* Enable comparisons against GT_CNS_LNG

* Optimize unsigned compares with int/long.MaxValue

Replace LE_UN/GT_UN(OP, int/long.MaxValue) with GE/LT(OP, 0)
as that generates smaller code on all targets.

* Relocate fgOptimizeRelationalComparisonWithConst

So that it is next to fgOptimizeEqualityComparisonWithConst.

Purely cosmetic change.

* Use the fgUpdateConstTreeValueNumber helper

* Fix formatting...

2 years ago[wasm] Add support for native relinking after Build, and… (#59153)
Ankit Jain [Thu, 16 Sep 2021 23:38:26 +0000 (23:38 +0000)]
[wasm] Add support for native relinking after Build, and… (#59153)

… AOT after publish (#58913)

Forward port #58913

(cherry picked from commit f38d58f)

2 years agoFix link (#59200)
Andrii Kurdiumov [Thu, 16 Sep 2021 22:54:55 +0000 (04:54 +0600)]
Fix link (#59200)

2 years agoRemove usused rd.xml files (#59201)
Andrii Kurdiumov [Thu, 16 Sep 2021 22:53:54 +0000 (04:53 +0600)]
Remove usused rd.xml files (#59201)

Closes #51112

2 years agoDisable the clrinterpreter pipeline schedule (#59229)
Bruce Forstall [Thu, 16 Sep 2021 22:28:44 +0000 (15:28 -0700)]
Disable the clrinterpreter pipeline schedule (#59229)

2 years agoFailing test for DI's site call factory cache (#59164)
Allan Targino [Thu, 16 Sep 2021 22:27:53 +0000 (19:27 -0300)]
Failing test for DI's site call factory cache (#59164)

* adding failing test for issue #57333

* using public api for di callsite test

* Update src/libraries/Microsoft.Extensions.DependencyInjection/tests/DI.Tests/CallSiteTests.cs

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
2 years agosupport FEATURE_INTERPRETER on linux-x64 (#59137)
xiabin [Thu, 16 Sep 2021 20:54:22 +0000 (04:54 +0800)]
support FEATURE_INTERPRETER on linux-x64 (#59137)

* Fix compile issue with interpreter.cpp

* implement FEATURE_INTERPRETER under linux-x64

2 years agoBump intellisense version to RC1 (main) (#59115)
Carlos Sanchez [Thu, 16 Sep 2021 20:11:04 +0000 (13:11 -0700)]
Bump intellisense version to RC1 (main) (#59115)

* Bump intellisense version to RC1

* Use package pushed to correct feed (dotnet6-transport)

Co-authored-by: carlossanlop <carlossanlop@users.noreply.github.com>
2 years agoImplement UriCreationOptions (#59173)
Miha Zupan [Thu, 16 Sep 2021 19:11:08 +0000 (12:11 -0700)]
Implement UriCreationOptions (#59173)

* Add UriCreationOptions

Includes DangerousDisablePathAndQueryCanonicalization

* Add /// comments

2 years agoUpdate gcc CI to use gcc-11 container (#59202)
Adeel Mujahid [Thu, 16 Sep 2021 18:35:27 +0000 (21:35 +0300)]
Update gcc CI to use gcc-11 container (#59202)

2 years agoUse getpwuid(3) in corehost for the $HOME-less user (#59036)
Adeel Mujahid [Thu, 16 Sep 2021 17:40:24 +0000 (20:40 +0300)]
Use getpwuid(3) in corehost for the $HOME-less user (#59036)

In other parts of dotnet/runtime repo <sup>[[1](https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/Native/Unix/System.Native/pal_networking.c#L3038-L3056)] [[2](https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/System.Private.CoreLib/src/System/IO/PersistedFiles.Unix.cs#L125-L137)] [[3](https://github.com/dotnet/runtime/blob/57bfe474518ab5b7cfe6bf7424a79ce3af9d6657/src/libraries/Native/Unix/System.Native/pal_uid.c#L65-L68)]</sup>, we attempt to retrieve user home directory from `getpwuid_r` when the environment variable `HOME` is not set. Use the same fallback in corehost.

2 years agoUse unsigned casts for array/Span indexers (#57970)
Pent Ploompuu [Thu, 16 Sep 2021 16:59:34 +0000 (19:59 +0300)]
Use unsigned casts for array/Span indexers (#57970)

* Improve TP for Span_get_Item

* Use unsigned casts for array length/index

* Use unsigned cast for Span_get_Item

2 years agoDo not use copy-on-write on windows (#59033)
Vladimir Sadov [Thu, 16 Sep 2021 16:53:04 +0000 (09:53 -0700)]
Do not use copy-on-write on windows (#59033)

2 years agoShare init-compiler with arcade (#59018)
Adeel Mujahid [Thu, 16 Sep 2021 16:29:00 +0000 (19:29 +0300)]
Share init-compiler with arcade (#59018)

* Share init-compiler with arcade

* Fixup merge conflict

* typo

2 years ago[iOS] Make sure IPGlobalProperties and NetworkInterface.GetIsNetworkAvailable methods...
Steve Pfister [Thu, 16 Sep 2021 16:14:14 +0000 (12:14 -0400)]
[iOS] Make sure IPGlobalProperties and NetworkInterface.GetIsNetworkAvailable methods return the correct info (#57096)

This change makes sure some of the IPGlobalProperties stop throwing exceptions and return the correct values.

GetIPv4GlobalStatistics, GetIcmpV4Statistics, GetTcpIPv4Statistics, GetUdpIPv4Statistics no longer throw NetworkInformationException.

GetActiveTcpConnections no longer returns TcpConnectionInformation instances only with the State of Unknown.

GetActiveTcpListeners return the correct IPEndPoint details for the IPV6 loopback.

NetworkInterface.GetIsNetworkAvailable no longer returns false for every call.

The reason these methods were behaving incorrectly on iOS is due to Apple not including the public headers for icmp_var.h, ip_var.h, tcp_fsm.h, if_media.h, and udp_var.h in the iOS SDK. This would lead to, for example, pal_tcpstate.c always returning TcpState_Unknown even if the underlying native value was TCPS_ESTABLISHED. This change includes the missing public headers in our build.

Fixes #36890

2 years ago[wasm] Unify BuildWasmRuntimes target and use cmake (#58878)
Radek Doulik [Thu, 16 Sep 2021 11:48:11 +0000 (13:48 +0200)]
[wasm] Unify BuildWasmRuntimes target and use cmake (#58878)

Add new cmake file to build native parts of `BuildWasmRuntimes` target. That unifies the build on windows and mac/linux.

Implements https://github.com/dotnet/runtime/issues/51553

* [wasm] Add cmake file for runtime native build

* Use the new cmake file

* Set the emcc configuration flags

The ninja generator is not multi-configuration cmake generator, so we
have to pass them from msbuild

* Update Makefile

* Fix few build issues

* Copy ICU files to native bin dir

* Copy source files to native bin dir

* Copy required header file

* Make all settings target specific

2 years agoUndo breaking change compat in GetMethodNativeMap (#59114)
Juan Hoyos [Thu, 16 Sep 2021 11:35:56 +0000 (04:35 -0700)]
Undo breaking change compat in GetMethodNativeMap (#59114)

* Undo breaking change compat when adding tiered aware behaviors to obtaining IL -> native maps.

2 years agoFix ordinal imports on Windows. (#54808)
monojenkins [Thu, 16 Sep 2021 07:14:56 +0000 (03:14 -0400)]
Fix ordinal imports on Windows. (#54808)

Co-authored-by: madewokherd <madewokherd@users.noreply.github.com>
2 years agoRemove legacy light-up code from `System.Reflection.Metadata` et.al. (#56587)
Theodore Tsirpanis [Thu, 16 Sep 2021 06:48:06 +0000 (09:48 +0300)]
Remove legacy light-up code from `System.Reflection.Metadata` et.al. (#56587)

* Remove legacy light-up code for the pointer-based Encoding.GetString.

* Remove legacy light-up code for the memory-mapped file block code.

* Remove FileStreamLightUp.IsFileStream and the need for it.

* Address PR feedback.

* Use hardware-accelerated population count where available.

* Remove a try/finally with an empty try where CERs are not supported.

* Use named arguments when constructing a memory-mapped file.

2 years agoMove Android SDK logic to /eng (#58700)
Michal Strehovský [Thu, 16 Sep 2021 06:35:58 +0000 (15:35 +0900)]
Move Android SDK logic to /eng (#58700)

2 years agoRemove a volatile access from TaskScheduler.Id (#58991)
WizardBrony [Thu, 16 Sep 2021 06:33:48 +0000 (01:33 -0500)]
Remove a volatile access from TaskScheduler.Id (#58991)

2 years agoUpdate area-owners.md (#59131)
Dan Moseley [Thu, 16 Sep 2021 06:29:44 +0000 (00:29 -0600)]
Update area-owners.md (#59131)

2 years ago[MonoVM] Reduce P/Invoke GC transition asserts in release builds (#59029)
Filip Navara [Thu, 16 Sep 2021 06:28:25 +0000 (08:28 +0200)]
[MonoVM] Reduce P/Invoke GC transition asserts in release builds (#59029)

2 years ago[main] WasmAppBuilder: Use $(CopyLocalLockFileAssemblies) instead of … (#59181)
Ankit Jain [Thu, 16 Sep 2021 01:20:58 +0000 (01:20 +0000)]
[main] WasmAppBuilder: Use $(CopyLocalLockFileAssemblies) instead of  … (#59181)

2 years agoFix BinSkim warnings in System.IO.Compression.Native.dll (#59188)
Michal Strehovský [Thu, 16 Sep 2021 01:18:28 +0000 (10:18 +0900)]
Fix BinSkim warnings in System.IO.Compression.Native.dll (#59188)

2 years agoHarden native gate thread against affinity mask growth (#59129)
Koundinya Veluri [Wed, 15 Sep 2021 23:18:48 +0000 (16:18 -0700)]
Harden native gate thread against affinity mask growth (#59129)

Hardened ThreadpoolMgr::GateThreadStart against the possibility that the observed group-local affinity mask contains set bits at positions higher than the total group-local CPU count that was captured during earlier initialization.

This fixes customer-reported crashes which have occurred on multi-group machines with heterogenous CPU counts across groups (but the same crash can probably also occur on single-group VMs if CPUs are hot-added and are then manually added to the process affinity mask).

2 years agoSet the publishing infra version to 3 (#59165)
Matt Mitchell [Wed, 15 Sep 2021 22:36:05 +0000 (15:36 -0700)]
Set the publishing infra version to 3 (#59165)

Before this was not important because runtime was calling its own publishing tasks with the property explicitly set, but since the introduction of arcade powered source build this property is needed to avoid ArPow from defaulting to v2.

2 years agoFix race condition with cancellation tokens in Read/Flush operations (#59090)
David Fowler [Wed, 15 Sep 2021 22:33:48 +0000 (15:33 -0700)]
Fix race condition with cancellation tokens in Read/Flush operations (#59090)

* Fix race condition with cancellation tokens in Read/Write operations
- There's a tight race where UnsafeRegister can fire inline and then ReadAsync never completes. This is because the cancellation token property has not been assigned yet so the callback noops. This change checks the result of the UnsafeRegister operation to see if ran synchronously and throws if it did. We also move any state transitions to after these checks to make sure the PipeAwaitable state doesn't change before throwing.

* Add a debug assert to make sure there's no state change.

* Add if debug

* More if DEBUG

2 years agoChange channel passed to ci_setup to track runtime branch (#59070)
Drew Scoggins [Wed, 15 Sep 2021 22:07:26 +0000 (15:07 -0700)]
Change channel passed to ci_setup to track runtime branch (#59070)

With this change we move to specifing the channel that is passed to ci_setup,
instead of it always being main. The allows us to have the runtime branch
help decide the correct version of the sdk that we should pull down with
dotnet-install. This means that going forward, we will need to have channels
that match the names of all branches that we plan to run from the runtime
side. If we do not, the sdk installation step will fail during ci_setup.

2 years agoFix env var syntax (#59169)
Fan Yang [Wed, 15 Sep 2021 22:07:03 +0000 (18:07 -0400)]
Fix env var syntax (#59169)

2 years agoFix StackOverflowException in Crossgen2 when assemblies has circular … (#58268)
Mikhail Filippov [Wed, 15 Sep 2021 21:14:06 +0000 (00:14 +0300)]
Fix StackOverflowException in Crossgen2 when assemblies has circular … (#58268)

* Fix StackOverflowException in Crossgen2 when assemblies has circular dependencies in exported types.

* Update EcmaModule.cs

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
2 years agoJIT: simple VN budget stress mode (#59051)
Andy Ayers [Wed, 15 Sep 2021 21:11:03 +0000 (14:11 -0700)]
JIT: simple VN budget stress mode (#59051)

Under jit stress, randomly set the VN memory disambiguation budget to a
smaller value, to try better and expose issues like #58877.

2 years agoRuntime changes for DetectPreviewFeaturesAnalyzer (#59062)
Prashanth Govindarajan [Wed, 15 Sep 2021 18:54:05 +0000 (11:54 -0700)]
Runtime changes for DetectPreviewFeaturesAnalyzer (#59062)

* Turn on DetectPreviewFeaturesAnalyzer and runtime changes

* Missed decimal

* Add comments and update S.Runtime.csproj

* sq

* sq

2 years agoRemove exception messages from resource strings (#59104)
Eirik Tsarpalis [Wed, 15 Sep 2021 18:20:07 +0000 (19:20 +0100)]
Remove exception messages from resource strings (#59104)

* remove exception messages from resource strings

* fix alphabetical ordering

2 years agoCreate and publish missing symbols (#58866)
Jo Shields [Wed, 15 Sep 2021 16:59:00 +0000 (12:59 -0400)]
Create and publish missing symbols (#58866)

* Fix symbols for Microsoft.MonoTargets.Sdk
* Build and include .pdb file on Windows builds of mono-aot-cross
* Output directly "mono-aot-cross.exe", don't rename "mono-sgen.exe"

2 years agoRequire UTF8 encoding in GetX509NameInfo.
Kevin Jones [Wed, 15 Sep 2021 16:33:45 +0000 (12:33 -0400)]
Require UTF8 encoding in GetX509NameInfo.

2 years agoAdd dependency graph viewer tool (#55304)
David Wrighton [Wed, 15 Sep 2021 15:34:08 +0000 (08:34 -0700)]
Add dependency graph viewer tool (#55304)

* Add dependency graph viewer tool
- This is a minimally functional tool used to view the dependency graphs produced by crossgen2
- This was previously present in the CoreRT repo, but did not make the transition to this repo when the type system was moved

* Code review comments

2 years agoArm64: Fix perfscore and display logic for LARGELDC (#59134)
Kunal Pathak [Wed, 15 Sep 2021 14:23:52 +0000 (07:23 -0700)]
Arm64: Fix perfscore and display logic for LARGELDC (#59134)

2 years agodisable tests unstable on Windows 11 (#59135)
Tomas Weinfurt [Wed, 15 Sep 2021 13:13:48 +0000 (06:13 -0700)]
disable tests unstable on Windows 11 (#59135)

2 years agoAdd SetLastError to GdiPlus methods (#59096)
Eric StJohn [Wed, 15 Sep 2021 12:55:16 +0000 (05:55 -0700)]
Add SetLastError to GdiPlus methods (#59096)

System.Drawing uses the last Win32 error in CheckErrorStatus to try to
guess at why a GdiPlus draw method failed and ignore some failures.

This was broken in .NETCore when SetLastError was removed from PINvokes.

Bring back SetLastError for all PInvokes that use CheckErrorStatus.

2 years ago[mono] Remove duplicates from the AOT data blob. (#58982)
Zoltan Varga [Wed, 15 Sep 2021 06:51:59 +0000 (08:51 +0200)]
[mono] Remove duplicates from the AOT data blob. (#58982)

2 years agoRelax assert to check for simd8 or return type (#58966)
Kunal Pathak [Wed, 15 Sep 2021 05:10:14 +0000 (22:10 -0700)]
Relax assert to check for simd8 or return type (#58966)

2 years agoInitialize compCurBB during fgInsertGCPoll (#57334)
Kunal Pathak [Wed, 15 Sep 2021 04:19:48 +0000 (21:19 -0700)]
Initialize compCurBB during fgInsertGCPoll (#57334)

* Initialize compCurBB during InsertGCPoll

* Update src/coreclr/jit/flowgraph.cpp

Co-authored-by: Egor Bogatov <egorbo@gmail.com>
* minor fix

* fix inifinite loop

* return 100

Co-authored-by: Egor Bogatov <egorbo@gmail.com>
2 years ago fix SendAsync from inpersonificated context with default credentials (#58922)
Tomas Weinfurt [Wed, 15 Sep 2021 03:12:23 +0000 (20:12 -0700)]
 fix SendAsync from inpersonificated context with default credentials (#58922)

* fix SendAsync from inpersonificated context and default credentials

* add missing file

* remove dead code

* feedback from review

* name cleanup

2 years agoChange back to net6.0 (#59130)
Kunal Pathak [Wed, 15 Sep 2021 01:16:27 +0000 (18:16 -0700)]
Change back to net6.0 (#59130)

2 years ago[mono] Use SROA-friendly struct type declarations (#59007)
imhameed [Tue, 14 Sep 2021 21:14:08 +0000 (17:14 -0400)]
[mono] Use SROA-friendly struct type declarations (#59007)

LLVM's SROA can decompose loads and stores of aggregate type into a
sequence of aggregate-element-typed loads and stores. Before this
change, Mono translated .NET-level value types into LLVM IR-level
structs containing nothing but `i8` elements.

When a value type field has reference type, and a value of this value
type is copied using a `memcpy` intrinsic or an LLVM IR load followed by
a store, LLVM will emit code that loads managed references in multiple
byte-sized fragments before reconstructing the original pointer using a
sequence of ALU ops. This causes sgen to fail to pin the referent.

This change works around this by translating value types to LLVM IR
structs with pointer-sized fields. Packed value types with non-standard
alignment will be translated into LLVM IR structs containing
alignment-sized fields.

Note that this does not completely guarantee that the code we generate
will respect sgen's requirements. No specific guarantees are provided
about the translation of non-atomic LLVM IR loads and stores to machine
code. And we'll need some alternative means (perhaps a special
`gc_copy_unaligned` runtime call or similar) to copy packed or
misaligned value types that contain managed references. For stronger
LLVM IR-level guarantees, we'll want to make use of unordered atomic
loads and stores and unordered atomic memcpy, but that work is out of
scope for this change.

Fixes #58062, but see the previous paragraph for caveats.

See:
- https://github.com/dotnet/llvm-project/blob/release/11.x/llvm/lib/Transforms/Scalar/SROA.cpp#L3371-L3388
- https://github.com/dotnet/llvm-project/blob/release/11.x/llvm/lib/Transforms/Scalar/SROA.cpp#L3327-L3340

2 years agoEliminate PROJECTK_BUILD from RF (#59057)
Andrew Au [Tue, 14 Sep 2021 21:04:16 +0000 (14:04 -0700)]
Eliminate PROJECTK_BUILD from RF (#59057)

2 years ago[mono] Update attribute name used for controlling frame pointer elimination (#59069)
imhameed [Tue, 14 Sep 2021 20:40:48 +0000 (16:40 -0400)]
[mono] Update attribute name used for controlling frame pointer elimination (#59069)

LLVM 8 introduced `"frame-pointer"="all"` as a substitute for
`"no-frame-pointer-elim"="true"`. LLVM 10 outright removed
`"no-frame-pointer-elim"`.

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

2 years agoUse arcade power source build infra (#58651)
Anirudh Agnihotry [Tue, 14 Sep 2021 20:25:09 +0000 (13:25 -0700)]
Use arcade power source build infra  (#58651)

* add yml files

* add file version and condition package reference on source build

* to avoid copying the file from the cache

2 years agoChange macOS activatin injection failure handling (#59045)
Jan Vorlicek [Tue, 14 Sep 2021 19:59:55 +0000 (21:59 +0200)]
Change macOS activatin injection failure handling (#59045)

The pthread_kill can fail with ENOTSUP on macOS when the target thread
is a dispatch queue thread. Instead of aborting the process, it is
better to fail to inject the activation and rely on return address
hijacking and other means of syncing with GC.

2 years agoElide SocketFlags in Socket API (#57634)
Bar Arnon [Tue, 14 Sep 2021 19:32:22 +0000 (22:32 +0300)]
Elide SocketFlags in Socket API (#57634)

* Elide SocketFlags in Socket API

Fix #43934

* Fix SocketAsyncEventArgs tests

* Cosmetics

* Elide SocketFlags in tests

* Comments

2 years ago[WASM] Enabled strict mode on all JS files (#54011)
Daniel Genkin [Tue, 14 Sep 2021 18:31:21 +0000 (14:31 -0400)]
[WASM] Enabled strict mode on all JS files (#54011)

"use strict" for all wasm JavaScript

Co-authored-by: Daniel Genkin <t-dgenkin@microsoft.com>
Co-authored-by: Pavel Savara <pavelsavara@microsoft.com>
2 years agoExtend MemoryCacheOptions with TrackLinkedCacheEntries (#57648)
Adam Sitnik [Tue, 14 Sep 2021 15:27:44 +0000 (17:27 +0200)]
Extend MemoryCacheOptions with TrackLinkedCacheEntries (#57648)

* add the property to reference assembly

* update tests

* implementation

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Apply suggestions from code review

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* update comment

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
2 years agoFix broken API proposal template link (#59083)
Eirik Tsarpalis [Tue, 14 Sep 2021 14:40:21 +0000 (15:40 +0100)]
Fix broken API proposal template link (#59083)

2 years agoAdd missing docs to System.Text.Json (#59053)
Eirik Tsarpalis [Tue, 14 Sep 2021 14:23:52 +0000 (15:23 +0100)]
Add missing docs to System.Text.Json (#59053)

2 years agoAdd missing System.Linq API docs (#59038)
Eirik Tsarpalis [Tue, 14 Sep 2021 14:22:41 +0000 (15:22 +0100)]
Add missing System.Linq API docs (#59038)

2 years agoUse caching ConsoleStream for both iOS and Android (#58967)
Steve Pfister [Tue, 14 Sep 2021 13:49:54 +0000 (09:49 -0400)]
Use caching ConsoleStream for both iOS and Android (#58967)

Expands on #56713 by moving the caching implementation to a separate internal class leaving only the interop calls in ConsolePal.iOS and ConsolePal.Android

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

2 years agoUpdateJson and CompilerServices.Unsafe versions (#59067)
Eric Erhardt [Tue, 14 Sep 2021 12:12:45 +0000 (06:12 -0600)]
UpdateJson and CompilerServices.Unsafe versions (#59067)

This unblocks the SDK ingestion now that we are targeting net7.0. Microsoft.NET.HostModel needs to update 7.0 versions of these libraries.

2 years agoAlign preallocationSize behavior (#58726)
Adam Sitnik [Tue, 14 Sep 2021 11:30:39 +0000 (13:30 +0200)]
Align preallocationSize behavior (#58726)

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoMulti-target Json and Logger Source Generators between Roslyn v3.11 and v4.0 (#58446)
Eric Erhardt [Tue, 14 Sep 2021 03:05:45 +0000 (21:05 -0600)]
Multi-target Json and Logger Source Generators between Roslyn v3.11 and v4.0 (#58446)

* Multi-target LoggerMessageGenerator between Roslyn v3.11 and v4.0

* Include a .targets file in NuGet packages which will select the correct analyzer assembly depending on which Roslyn version will be used to compile.

* Multi-target JsonSourceGenerator between Roslyn v3.11 and v4.0

* Fix restore

* Update NuGet package MSBuild logic to detect when SupportsRoslynComponentVersioning is not available, and use the lowest analyzer available.

* Handle non-SDK projects by running after ResolveNuGetPackageAssets

* Respond to PR feedback

- Name .cs and .csproj files with Roslyn in the name
- Upgrade to Roslyn 3.11 so IsExplicitlyNamedTupleElement API is available
- Fix some references to the test projects
- Fix incremental pack of the analyzer targets

2 years agoRemove SupportedOSPlatforms windows on Hosting WindowsServices (#59039)
Eric Erhardt [Mon, 13 Sep 2021 20:54:30 +0000 (14:54 -0600)]
Remove SupportedOSPlatforms windows on Hosting WindowsServices (#59039)

Fix #59037

2 years ago[wasm] browser-bench improvements (#59028)
Radek Doulik [Mon, 13 Sep 2021 20:13:34 +0000 (22:13 +0200)]
[wasm] browser-bench improvements (#59028)

Do not supress all linker warnings. Use UnconditionalSuppressMessage
attribute to supress these we know are ok.

Add new WebSocketTask to the default tasks array.

Enable disabled exception measurements as they don't crash anymore.

Improve summary output.

Example output:

| measurement | time |
|-:|-:|
|        Exceptions, NoExceptionHandling |     0.2288us |
|                   Exceptions, TryCatch |     0.2480us |
|              Exceptions, TryCatchThrow |     0.0083ms |
|             Exceptions, TryCatchFilter |     0.1917us |
|       Exceptions, TryCatchFilterInline |     0.0486us |
|        Exceptions, TryCatchFilterThrow |     0.0096ms |
| Exceptions, TryCatchFilterThrowApplies |     0.0092ms |
|         Json, non-ASCII text serialize |     0.6500ms |
|       Json, non-ASCII text deserialize |     2.1381ms |
|                  Json, small serialize |     0.1419ms |
|                Json, small deserialize |     0.2167ms |
|                  Json, large serialize |    36.9640ms |
|                Json, large deserialize |    59.0562ms |
|              WebSocket, PartialSend 1B |     0.0022ms |
|            WebSocket, PartialSend 64KB |     0.0690ms |
|             WebSocket, PartialSend 1MB |     1.1455ms |
|           WebSocket, PartialReceive 1B |     0.0060ms |
|         WebSocket, PartialReceive 10KB |     0.0080ms |
|        WebSocket, PartialReceive 100KB |     0.0000us |

2 years agoFix EventPipe sample profiler resolution on Windows. (#58997)
Johan Lorensson [Mon, 13 Sep 2021 20:11:43 +0000 (22:11 +0200)]
Fix EventPipe sample profiler resolution on Windows. (#58997)

2 years agoReplace constant strings with SyntaxKind (#57898)
Gérald Barré [Mon, 13 Sep 2021 20:09:38 +0000 (16:09 -0400)]
Replace constant strings with SyntaxKind (#57898)

2 years agoMake bashing to constants nicer (#58171)
SingleAccretion [Mon, 13 Sep 2021 19:11:25 +0000 (22:11 +0300)]
Make bashing to constants nicer (#58171)

* Replace ChangeOperConst with BashToConst

The nature of bashing to a constant is that
the code doing it practically always wants to
set the constant value and the type so it makes
sense to do all three at once - it also enables
some more stringent asserts.

But mostly this method is for convenience.

* Fix a minor issue found by the new assert

It is a minor "bug" in lowering where zero-extension was used for
a TYP_INT constant instead of sign extension.

2 years ago[wasm] Fix circular dependency in WasmAppBuilder (#58904)
Ankit Jain [Mon, 13 Sep 2021 18:34:34 +0000 (18:34 +0000)]
[wasm] Fix circular dependency in WasmAppBuilder (#58904)

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

2 years agoRemove benign assert (#58980)
Jakob Botsch Nielsen [Mon, 13 Sep 2021 17:15:26 +0000 (19:15 +0200)]
Remove benign assert (#58980)

It is perfectly possible for us to replace a promoted struct by its only
field where that field is marked do-not-enregister. Since this path does
handle the proper retyping when normalization is required this assertion
is benign.

Fix #58972

2 years agoAdd JitStress=1/2 runs to jitstress-isas-x86 pipeline (#58822)
Bruce Forstall [Mon, 13 Sep 2021 16:57:42 +0000 (09:57 -0700)]
Add JitStress=1/2 runs to jitstress-isas-x86 pipeline (#58822)

* Add JitStress=1/2 runs to jitstress-isas-x86 pipeline

* Up timeout for jitstress-isas-x86 overall to 16 hours

At 8.5 hours, it timed out before running all the stress jobs.

2 years agoRemove too-short a timeout for a GCStress test (#57245)
Koundinya Veluri [Mon, 13 Sep 2021 16:24:55 +0000 (09:24 -0700)]
Remove too-short a timeout for a GCStress test (#57245)

- Also enabled the test for GCStress to try it again. The test seems to take a decent amount of time on my machine, and with the machine busy it could take longer but it should finish in reasonable time.
- Closes https://github.com/dotnet/runtime/issues/13453

2 years ago[tvOS] Be less eager in creating the non-existent special folders (#58788)
Filip Navara [Mon, 13 Sep 2021 15:23:48 +0000 (17:23 +0200)]
[tvOS] Be less eager in creating the non-existent special folders (#58788)

Fixes #58787

2 years agoAdd `JitEnregStats` complus. (#58776)
Sergey Andreenko [Mon, 13 Sep 2021 15:13:03 +0000 (08:13 -0700)]
Add `JitEnregStats` complus. (#58776)

* Add `JitEnregStats` complus.

* review response.

* response review 2.

* add a space

* fix printing/sorting

* fix merge conflicts

* format

Co-authored-by: Sergey <seandree@microsoft.com>
2 years agoImprove error messages expanding single-file (#58557)
Vitek Karas [Mon, 13 Sep 2021 15:00:28 +0000 (08:00 -0700)]
Improve error messages expanding single-file (#58557)

2 years agoTurn on the XHarness telemetry for Helix mobile devices (#58864)
Přemek Vysoký [Mon, 13 Sep 2021 14:35:56 +0000 (16:35 +0200)]
Turn on the XHarness telemetry for Helix mobile devices (#58864)

2 years agoRemove GTF_NO_CSE on the first FIELD_LIST arg (#57411)
SingleAccretion [Mon, 13 Sep 2021 14:12:14 +0000 (17:12 +0300)]
Remove GTF_NO_CSE on the first FIELD_LIST arg (#57411)

The code constructing the list reuses the original
local node for the first field. Such a node is likely
to have come from an OBJ(ADDR(LCL_VAR)) tree, thus
having GTF_NO_CSE set on it, pessimizing handling of
the promoted struct field, in particular, blocking
global constant propagation.

Fix this by calling SetOperResetFlags instead of
ChangeOper. This may lose some flags, but the other
fields in the list did not have them set in any case.