SingleAccretion [Thu, 7 Jul 2022 19:51:52 +0000 (22:51 +0300)]
Handle some rare scenarios in local morph (#71536)
Namely, cases where we cannot transform local indirections into local nodes:
1. Unused indirections - we simply remove them.
2. Volatile FIELDs - we mark the underlying local address-exposed.
3. Large offsets - likewise.
Overall this (as well as most other ADDR-related changes) works towards enabling the invariant that after local morph, every local access is either address-exposed, or transformed into LCL_VAR/LCL_FLD.
Tanner Gooding [Thu, 7 Jul 2022 19:47:15 +0000 (12:47 -0700)]
Updating a few BitConverter APIs to be intrinsic (#71567)
* Updating a few BitConverter APIs to be intrinsic
* Reacting to PR feedback
* Update src/coreclr/jit/valuenum.cpp
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
* Update src/coreclr/jit/gentree.h
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
* Apply formatting patch
* Ensure DoubleToInt64Bits and Int64BitsToDouble intrinsics only pop when appropriate
* Fix VNForBitCast to not handle exception set logic since its always a normal value now
* Applying formatting patch
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
SingleAccretion [Thu, 7 Jul 2022 19:46:02 +0000 (22:46 +0300)]
Preparatory changes for enabling direct decomposition of promoted locals into `FIELD_LIST`s on ARM (#71726)
* Unify the "3-byte struct" ARM case with other targets
The only case when "structSize != passingSize" could be true is when we "upcast"
a "mis-sized" struct to a primitive.
For ARM, we never did that -- the relevant "#ifdef"s didn't include it, thus
"OperIs(GT_OBJ) && (structSize != passingSize)" was dead code. Instead, there
was bespoke handling for such structs: "if (structSize < TARGET_POINTER_SIZE)".
Delete the bespoke handling and the "#ifdef", unifying the handling.
* Update a comment
* Fix PUTARG_SPLIT codegen
We must use the "field type" for stores.
Example "struct { int a; byte b; byte c; }" is split between one register and
one stack slot, and both "b" and "c" become propagated constants, typed INT.
* Enable OBJ spilling for ARM
* Fold the last ARM-specific condition
* Do not convert large split args into FIELD_LISTs
We do not check the register requirements on the fields or their sizes (extents).
* Restructure support for "mis-sized" structs
Add a comment, simplify the code.
David Cantú [Thu, 7 Jul 2022 19:40:01 +0000 (14:40 -0500)]
S.S.C.Cose: Add new MultiSign APIs and address API review feedback on existing ones (#71390)
* Make full assembly unsupported on browser
* Add new MultiSign APIs and address API review feedback on existing ones
* Add SignaturePadding tests and address #70189
* Address feedback (typos and leftover code)
* Add tests for CoseHeaderValue and wrap CborReader/Writer errors
* nits and line chopping
* Move alg. validations to CoseSigner and add remaining AddSignatureFor* APIs
Carlos Sanchez [Thu, 7 Jul 2022 19:39:34 +0000 (12:39 -0700)]
Bump Intellisense package version to Preview5 (#71772)
Carlos Sanchez [Thu, 7 Jul 2022 19:39:10 +0000 (12:39 -0700)]
Bump PreReleaseVersion to Preview7 (#71770)
Eric Erhardt [Thu, 7 Jul 2022 19:27:35 +0000 (13:27 -0600)]
Better error handling in SubtleCrypto workers (#71693)
* Better error handling in SubtleCrypto workers
Handle exceptions from SubtleCrypto by catching and logging exceptions coming from the crypto stack.
Reset web worker when a request fails.
Also, fix race conditions where the web worker can read its own response as part of the next request.
Contributes to #69740
CyrusNajmabadi [Thu, 7 Jul 2022 19:02:29 +0000 (12:02 -0700)]
Polyfill the incremental generator ForAttributeWithMetadataName from roslyn (for LoggingGenerator). (#71651)
* Polyfill the incremental generator ForAttributeWithMetadataName from roslyn (for LoggingGenerator).
* Simplify
* Fix project file
* Remove
* revert
Koundinya Veluri [Thu, 7 Jul 2022 18:54:01 +0000 (11:54 -0700)]
Fix long latencies in `ReaderWriterLockSlim` lock operations due to `Sleep(1)` (#70165)
* Fix long latencies in `ReaderWriterLockSlim` lock operations due to `Sleep(1)`
- Removed usage of `Sleep(1)`
- Modified the spin-waiting scheme beyond the `Sleep(0)` threshold to avoid potentially long sequences of ineffective `Sleep(0)`s
- Retuned the threshold to reprioritize deprioritized spin-lock requests
Fixes https://github.com/dotnet/runtime/issues/69206
Jan Kotas [Thu, 7 Jul 2022 18:53:25 +0000 (11:53 -0700)]
Add note about Array.Initialize to ECMA-335 augments (#71766)
Fixes #71733
David Wrighton [Thu, 7 Jul 2022 18:48:06 +0000 (11:48 -0700)]
Close PGO data file when done with it reliably (#71744)
Fan Yang [Thu, 7 Jul 2022 18:27:18 +0000 (14:27 -0400)]
[Mono] Fix all remaining C4018 warnings and enable the check during build (#71269)
* 3rd round of fixing 4018 warnings
* Fix warnings on x86
* Fix remaining c4018 warnings and enable it for build
* Fix print format
* Fix type
* Fix warnings for LLVM
* Fix for wasm
* Fix for arm64
* Fix x86
* Iterator could be negative
* Fix a warning in decompose.c
* Fix warning for arm
* Fix warning for wasm only llvm code
* Correct a few iterator types
* Fix another incorrect iterator type
* Update src/mono/mono/mini/interp/transform.c
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
* Update src/mono/mono/mini/mini-generic-sharing.c
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
* Update src/mono/mono/mini/mini-generic-sharing.c
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
* Update src/mono/mono/mini/mini-generic-sharing.c
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
* Address review feedback
* Remove other fixed warning.
* Use more accurate types when possible
Co-authored-by: Aleksey Kliger (λgeek) <akliger@gmail.com>
Pavel Savara [Thu, 7 Jul 2022 18:12:48 +0000 (20:12 +0200)]
[wasm] JSImport, JSExport and related API types for JavaScript interop (#71500)
- approved API
- xmldoc
Co-authored-by: Marek Fišera <mara@neptuo.com>
Co-authored-by: Katelyn Gadd <kg@luminance.org>
Kunal Pathak [Thu, 7 Jul 2022 17:14:43 +0000 (10:14 -0700)]
Unix arm64 atomics (#71512)
* Define_InterlockMethod macro
* compiler failure
* fix build errors
* Set g_arm64_atomics_present at common place
* Fix the missing declaration
* Change TARGET_ARM64 => HOST_ARM64
* Use LSE for InterlockedCompareExchange
* Attempt to fix osx-arm64 build issue
* Introduce LSE_INSTRUCTIONS_ENABLED_BY_DEFAULT
* Make sure that compiler knows that M1 has lse
Bruce Forstall [Thu, 7 Jul 2022 16:14:07 +0000 (09:14 -0700)]
Fix incoming arg struct splitting (#71701)
This change only affects Windows/arm64 with varargs.
For incoming structs split between register and stack, handle the splitting
correctly.
Fixes #57606
Elinor Fung [Thu, 7 Jul 2022 15:28:17 +0000 (08:28 -0700)]
Move ICustomTypeMarshallingStrategy implementations into separate files (#71747)
* Move ICustomTypeMarshallingStrategy implementations into separate files
* Remove constructor args from V2 marshalling strategy
MSDN.WhiteKnight [Thu, 7 Jul 2022 14:16:02 +0000 (19:16 +0500)]
Add markdown readme for System.Collections.Immutable (#71247)
* Update System.Collections.Immutable.csproj
* Add README.md
* Add README.md
* Delete README.md
* Update PackageDescription
Meri Khamoyan [Thu, 7 Jul 2022 13:45:20 +0000 (17:45 +0400)]
#37093 disable Reciprocal test only for Android x86 (#71541)
* #37093 disable Reciprocal test only for Android x86
Stephen Toub [Thu, 7 Jul 2022 12:54:58 +0000 (08:54 -0400)]
Use ObjectDisposedException.ThrowIf in more places (#71546)
* Use ObjectDisposedException.ThrowIf in more places
* Update TarWriter.cs
Stephen Toub [Thu, 7 Jul 2022 11:56:00 +0000 (07:56 -0400)]
Use scoped more in dotnet/runtime (#71589)
* Use scoped more in dotnet/runtime
This PR addresses a few issues:
- Exposes the new {ReadOnly}Span constructors that accept a ref.
- Uses those new constructors outside of corelib (they were previously internal and used only inside of corelib).
- Makes several members of Utf8JsonReader readonly in order to enable stackalloc'd spans to be used in ValueTextEquals calls.
- Makes several span arguments to SequenceReader scoped in order to enable stackalloc'd spans to be used with those calls.
- Removes all stackalloc T[0], replacing it with scoped locals.
- Removes some use of stackalloc'ing into a pointer and then manually wrapping into a span, instead directly stackalloc'ing into a span. This is possible now in more cases due to the new language validation rules.
- Replaced some use of MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(...)) with Unsafe.AsRef.
* Address PR feedback
Zoltan Varga [Thu, 7 Jul 2022 11:55:42 +0000 (07:55 -0400)]
[mono] Avoid calling mono_metadata_type_hash () on the container class in mono_generic_class_hash (). (#71734)
If a class inherits from a generic instance instantiated with itself, then its possible
for mono_generic_class_hash () to be called while the container class is not fully
initialized yet, i.e. byval_arg.type is 0. This would cause the generic class to change
its hash.
Fixes https://github.com/dotnet/runtime/issues/71424.
Stephen Toub [Thu, 7 Jul 2022 11:33:15 +0000 (07:33 -0400)]
Reduce allocation overhead of Enumerable.Order{Descending} (#71564)
Enumerable.OrderBy{Descending} buffers the input into an array. It then allocates a TKey[] from that input to store the keys, and allocates an int[] that's what's actually sorted based on those keys. The enumerator uses that sorted int[] then to decide what element from the buffered input to yield next. In the case of the new Order and OrderDescending methods, though, that TKey[] isn't required; it's just a copy of the buffered input, so we can avoid it.
Michal Strehovský [Thu, 7 Jul 2022 08:07:51 +0000 (17:07 +0900)]
Make things work for arrays of function pointers (#71749)
* Don't try to obtain type handles for fields of types of function pointer arrays
* Add function pointer support to name mangler. We still don't make EETypes for these, but debug info generation also needs mangled names. We currently generate debug info for function pointers as debug info for `void*`, but arrays of function pointers only partially go through that handling and still end up needing a mangled name for the function pointer.
David Mason [Thu, 7 Jul 2022 07:32:38 +0000 (00:32 -0700)]
Update ILToNativeMap event to include IL version (#71479)
* Update eventtrace.cpp
* Add native code ID and IL code ID
Adeel Mujahid [Thu, 7 Jul 2022 06:46:26 +0000 (09:46 +0300)]
Improve objcopy detection (#71742)
Tanner Gooding [Thu, 7 Jul 2022 01:55:17 +0000 (18:55 -0700)]
Fixing public field order for System.Numerics types (#71728)
Tanner Gooding [Thu, 7 Jul 2022 01:52:58 +0000 (18:52 -0700)]
Ensure side effects get spilled for the various hwintrinsic and simdashwintrinsic nodes (#70054)
* Adding a regression test for #54956
* Ensure side effects get spilled for the various hwintrinsic and simdashwintrinsic nodes
* Applying formatting patch
* Don't mark Compiler::impSpillSideEffect as `inline` so clang can resolve it correctly
* Adding more tests for Runtime_54956
Elinor Fung [Thu, 7 Jul 2022 01:51:50 +0000 (18:51 -0700)]
Handle stateless collection marshalling with non-blittable elements (#71724)
Will Smith [Thu, 7 Jul 2022 01:00:04 +0000 (18:00 -0700)]
Using /unicode when running ildasm.exe roundtrip tests (#71163)
* Using /unicode when running ildasm.exe roundtrip tests
* Added /unicode flag
* Update issues.targets
David Wrighton [Wed, 6 Jul 2022 23:47:25 +0000 (16:47 -0700)]
TypedByReference should be treated as a normal valuetype for calling convention purposes (#71675)
TypedByReference should be treated as a normal valuetype for calling convention purposes
Add regression test for #42732
Jan Kotas [Wed, 6 Jul 2022 23:45:26 +0000 (16:45 -0700)]
Add note about partition IV and V to ECMA-335 augments (#71737)
Fixes #71733
Aaron Robinson [Wed, 6 Jul 2022 23:20:29 +0000 (16:20 -0700)]
Leverage compiler attributes for snippets identification (#71729)
* Leverage compiler attributes for snippets identification
Elinor Fung [Wed, 6 Jul 2022 23:05:17 +0000 (16:05 -0700)]
Check for V2 shapes on string marshallers (#71730)
Michael Simons [Wed, 6 Jul 2022 22:18:20 +0000 (17:18 -0500)]
Exclude AssemblyStripper from source-build (#71691)
Krzysztof Wicher [Wed, 6 Jul 2022 21:44:27 +0000 (23:44 +0200)]
Tests for creating recursive types (#71721)
David Wrighton [Wed, 6 Jul 2022 21:08:22 +0000 (14:08 -0700)]
On 64 bit platforms, "stelem.ref" and "ldelema" ignore the high bits of a native int index (#71571)
Add support for native int indices in stelem.ref and ldelema helper functions. This required changing the abi of these functions, which required bumping the major R2R version number. As we have already done that for .NET 7, this is a minor cost. Note that this is still broken on Mono, and that bug is #71656
Fixes #52817
Egor Bogatov [Wed, 6 Jul 2022 20:39:58 +0000 (22:39 +0200)]
Adjust weights of blocks with profile inside loops in non-profiled methods (#71659)
Thays Grazia [Wed, 6 Jul 2022 20:26:11 +0000 (17:26 -0300)]
Fix debugging on Mac and iOS (#71436)
We need to set this:
`mini_get_debug_options ()->mdb_optimizations = TRUE;`
before initialize the interpreter, otherwise the interpreter optimizations will be turned on and we will not be able to see the correct variable values.
https://github.com/dotnet/runtime/blob/
4adb1172658f74e6a513bece426005d7f2ba7a04/src/mono/mono/mini/interp/interp.c#L8123
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558698
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1513227
Jan Kotas [Wed, 6 Jul 2022 19:54:30 +0000 (12:54 -0700)]
Mark ILVerify as AnyCPU (#71695)
Fixes #70508
ws77.cho [Wed, 6 Jul 2022 19:38:48 +0000 (04:38 +0900)]
Re-create profile data on profile-use-only mode (#71420)
Activate multicorejit recorder to re-create the profile data
when the multicorejit player cannot be executed due to BADIMAGEFORMAT error on profile-use-only mode
Michael Simons [Wed, 6 Jul 2022 19:30:24 +0000 (14:30 -0500)]
Enable host.pkg subset in source-build (#60069) (#71690)
Will Sugarman [Wed, 6 Jul 2022 19:22:01 +0000 (12:22 -0700)]
Allow UTF-8 BOM in BinaryData When Deserializing (#71457)
* Use ReadOnlyMemoryStream in ToObjectFromJson
* Slice the span instead
Mitchell Hwang [Wed, 6 Jul 2022 19:05:00 +0000 (15:05 -0400)]
Integrate mibc mono config extension (#71657)
* [mono] Modify MonoImageLoadOptions field type for clarity
* [mono] Add mibc config check when adding methods from mibc
* [coreclr] Extend RuntimeSku with Mono runtime
* Address feedback
CyrusNajmabadi [Wed, 6 Jul 2022 18:47:37 +0000 (11:47 -0700)]
Polyfill the incremental generator ForAttributeWithMetadataName from roslyn (for JsonGenerator). (#71653)
* Polyfill the incremental generator ForAttributeWithMetadataName from roslyn (for JsonGenerator).
* Move common code to shared location
* Update projects
* Add back
* Update src/libraries/System.Text.Json/gen/System.Text.Json.SourceGeneration.Roslyn4.0.csproj
Carlos Sanchez [Wed, 6 Jul 2022 18:09:13 +0000 (11:09 -0700)]
Fix S.R.InteropServices remarks (#71683)
Moved the triple slash seealso items outside of the remarks section, to prevent porting them to dotnet-api-docs, because they would show weird in MS Docs.
Kevin Jones [Wed, 6 Jul 2022 17:45:59 +0000 (13:45 -0400)]
Use OS-provided RSA OAEP implementation for Android
Instead of using the managed OAEP implementatation, allow the OS to handle OAEP with SHA2 algorithms.
Android also supports algorithm identifiers like "RSA/ECB/OAEPwithSHA-256andMGF1Padding" which would make the code simpler, but it makes the hash algorithm used in MGF1 ambiguous. Since the MGF1 algorithm is always the same as the OAEP algorithm, we explicitly use the `OEAPParameterSpec` so that we can control both the MGF1 digest algorithm and the OAEP digest algorithm.
Ankit Jain [Wed, 6 Jul 2022 17:19:04 +0000 (13:19 -0400)]
[wasm] WBT: Enable playwright based tests (#71602)
Buyaa Namnan [Wed, 6 Jul 2022 16:45:24 +0000 (09:45 -0700)]
DefaultBinder named parameter support skipping default parameters (#71013)
Jeremy Koritzinsky [Wed, 6 Jul 2022 16:35:51 +0000 (09:35 -0700)]
Update design and expose new attributes for the CustomTypeMarshaller support (#71682)
dotnet-maestro[bot] [Wed, 6 Jul 2022 15:30:25 +0000 (15:30 +0000)]
Update dependencies from https://dev.azure.com/dnceng/internal/_git/dotnet-optimization build
20220705.3 (#71710)
[main] Update dependencies from dnceng/internal/dotnet-optimization
Eirik Tsarpalis [Wed, 6 Jul 2022 14:59:32 +0000 (15:59 +0100)]
Simplify JsonPropertyInfo list implementation and expose IsExtensionData properties (#71650)
* Simplify JsonPropertyInfo list implementation.
* Replace PropertyTypeCanBeNull uses with default(T)
* Take properties with ExtensionDataProperty into account
* Update src/libraries/System.Text.Json/src/Resources/Strings.resx
* Update src/libraries/System.Text.Json/src/Resources/Strings.resx
* revert accidental change
* Fix race condition when initializing Property list
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonTypeInfo.cs
Beau Gosse [Wed, 6 Jul 2022 12:32:56 +0000 (07:32 -0500)]
NativeAOT Re-enable Linux System.Reflection tests after fix (#71664)
Ulrich Weigand [Wed, 6 Jul 2022 11:58:32 +0000 (13:58 +0200)]
Use in-tree ilasm to run test suite natively on s390x (#71326)
* There are no linux-s390x packages on nuget.org, so use in-tree
built ilasm when running the test suite natively on s390x
Jakob Botsch Nielsen [Wed, 6 Jul 2022 10:15:52 +0000 (12:15 +0200)]
JIT: Fix generating unrepresentable nullchecks on ARM64 (#71687)
The logic in lowering could in some struct and primitive type cases
generate an unrepresentable NULLCHECK node for ARM64/LA64 when there
was a contained address mode. We now transform unused indirections and
create address modes in the opposite order on non-xarch to avoid these
unrepresentable nullchecks.
Fix #71684
Egor Bogatov [Wed, 6 Jul 2022 08:41:56 +0000 (10:41 +0200)]
Don't set CORINFO_FLG_CUSTOMLAYOUT for auto-layout structs (#71673)
Jan Kotas [Wed, 6 Jul 2022 03:55:24 +0000 (20:55 -0700)]
Simplify CEEInfo::getTypeForPrimitiveValueClass (#71686)
Jakob Botsch Nielsen [Wed, 6 Jul 2022 01:39:15 +0000 (03:39 +0200)]
JIT: Avoid reordering operands in fgMorphModToSubMulDiv (#71615)
* JIT: Avoid reordering operands in fgMorphModToSubMulDiv
fgMorphModToSubMulDiv tries to check if it is ok to "clone" locals
instead of spilling them by checking for address exposure. This was
necessary because GTF_GLOB_REF is not up-to-date in preorder during
morph, which is when this runs. However, address exposure is not valid
for implicit byrefs at this point, so the check is not enough.
The logic is trying to figure out which of the operands need to be
spilled and which of them can be cloned. However, the logic was also
wrong in the face of potential embedded assignments. Thus, rework it to
be a bit more conservative but correct.
As part of this, remove fgIsSafeToClone and make fgMakeMultiUse less
conservative by avoiding checking for address exposure. This was
probably an attempt at some limited interference checks, but from what I
could see other uses do not need this.
Fix #65118
* Add a test
* Revert unnecessary change
* Switch to gtCloneExpr
Jakob Botsch Nielsen [Wed, 6 Jul 2022 00:55:46 +0000 (02:55 +0200)]
Disable a test for ilasm roundtripping (#71634)
Eric Erhardt [Wed, 6 Jul 2022 00:46:09 +0000 (18:46 -0600)]
Use crypto.subtle for AES on Browser WASM (#71501)
* Use crypto.subtle for AES on Browser WASM
Implement the browser "native" portion for AES on Browser WASM.
There are two issues to solve .NET's Aes API on crypto.subtle:
1. The .NET API supports streaming while crypto.subtle only supports "one shot" APIs.
2. The .NET API supports multiple padding modes while crypto.subtle only supports PKCS7.
To solve these issues, we use the following approach:
1. We only invoke crypto.subtle with complete AES "blocks" of data. This allows us to make assumptions about the padding behavior.
2. To implement streaming, remember the last block of the previous cipher text to use as the IV for the next stream of data.
3. When encrypting, since we have a complete block of data and crypto.subtle uses PKCS7 padding, strip off the last block of cipher text which will always be a full block of padding.
4. When decrypting do the inverse of encrypting - append an encrypted block of padding to the cipher text so crypto.subtle will return the full message as plain text.
Other changes:
- Make a few refactoring / simplifications where necessary.
- SubtleCrypto doesn't support 192 bit AES keys, so no longer support AES-192 on Browser.
Contributes to #40074
* Use an empty array to create encrypted padding block.
Juan Hoyos [Wed, 6 Jul 2022 00:42:04 +0000 (17:42 -0700)]
Hold stop-go lock when requesting CCW (#71660)
Elinor Fung [Tue, 5 Jul 2022 23:42:30 +0000 (16:42 -0700)]
Call stateless free for linear collection marshallers (#71669)
SingleAccretion [Tue, 5 Jul 2022 22:32:06 +0000 (01:32 +0300)]
Do not spill "mis-sized" struct args passed on stack (#71399)
* Enable a test on Unix x64
* Handle mis-sized structs in LA PUTARG_STK codegen
* Handle mis-sized structs in LA PUTARG_SPLIT codegen
* MisSizedStructs_ArmSplit -> MisSizedStructs_ArmArch
* Add tests
* Do not spill mis-sized stack args
All backends support them.
Michał Petryka [Tue, 5 Jul 2022 22:07:22 +0000 (00:07 +0200)]
Make getTypeForPrimitiveValueClass treat different signs as different types (#71633)
* Make getTypeForPrimitiveValueClass treat different sizes as different types
* Handle missing types
* Update jitinterface.cpp
* Test removing pointers
dotnet-maestro[bot] [Tue, 5 Jul 2022 21:58:20 +0000 (21:58 +0000)]
[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet/emsdk (#71533)
[main] Update dependencies from dotnet/runtime dotnet/icu dotnet/xharness dotnet/emsdk
Buyaa Namnan [Tue, 5 Jul 2022 21:04:22 +0000 (14:04 -0700)]
Fix: using default value for nullable enum parameter throws ArgumentException (#71388)
Bruce Forstall [Tue, 5 Jul 2022 20:49:26 +0000 (13:49 -0700)]
Optimize multi-dimensional array access (#70271)
Currently, multi-dimensional (MD) array access operations are treated as opaque to most of
the JIT; they pass through the optimization pipeline untouched. Lowering expands the `GT_ARR_ELEM`
node (representing a `a[i,j]` operation, for example) to `GT_ARR_OFFSET` and `GT_ARR_INDEX` trees,
to expand the register requirements of the operation. These are then directly used to generate code.
This change moves the expansion of `GT_ARR_ELEM` to a new pass that follows loop optimization but precedes
Value Numbering, CSE, and the rest of the optimizer. This placement allows for future improvement to
loop cloning to support cloning loops with MD references, but allows the optimizer to kick in on the new
expansion. One nice feature of this change: there is no machine-dependent code required; all the nodes
get lowered to machine-independent nodes before code generation.
The MDBenchI and MDBenchF micro-benchmarks (very targeted to this work) improve about 10% to 60%, but there is
one significant CQ regression in MDMulMatrix of over 20%. Future loop cloning, CSE, and/or LSRA work will be needed to get that back.
In this change, `GT_ARR_ELEM` nodes are morphed to appropriate trees. Note that an MD array `Get`, `Set`, or `Address`
operation is imported as a call, and, if all required conditions are satisfied, is treated as an intrinsic
and replaced by IR nodes, especially `GT_ARR_ELEM` nodes, in `impArrayAccessIntrinsic()`.
For example, a simple 2-dimensional array access like `a[i,j]` looks like:
```
\--* ARR_ELEM[,] byref
+--* LCL_VAR ref V00 arg0
+--* LCL_VAR int V01 arg1
\--* LCL_VAR int V02 arg2
```
This is replaced by:
```
&a + offset + elemSize * ((i - a.GetLowerBound(0)) * a.GetLength(1) + (j - a.GetLowerBound(1)))
```
plus the appropriate `i` and `j` bounds checks.
In IR, this is:
```
* ADD byref
+--* ADD long
| +--* MUL long
| | +--* CAST long <- uint
| | | \--* ADD int
| | | +--* MUL int
| | | | +--* COMMA int
| | | | | +--* ASG int
| | | | | | +--* LCL_VAR int V04 tmp1
| | | | | | \--* SUB int
| | | | | | +--* LCL_VAR int V01 arg1
| | | | | | \--* MDARR_LOWER_BOUND int (0)
| | | | | | \--* LCL_VAR ref V00 arg0
| | | | | \--* COMMA int
| | | | | +--* BOUNDS_CHECK_Rng void
| | | | | | +--* LCL_VAR int V04 tmp1
| | | | | | \--* MDARR_LENGTH int (0)
| | | | | | \--* LCL_VAR ref V00 arg0
| | | | | \--* LCL_VAR int V04 tmp1
| | | | \--* MDARR_LENGTH int (1)
| | | | \--* LCL_VAR ref V00 arg0
| | | \--* COMMA int
| | | +--* ASG int
| | | | +--* LCL_VAR int V05 tmp2
| | | | \--* SUB int
| | | | +--* LCL_VAR int V02 arg2
| | | | \--* MDARR_LOWER_BOUND int (1)
| | | | \--* LCL_VAR ref V00 arg0
| | | \--* COMMA int
| | | +--* BOUNDS_CHECK_Rng void
| | | | +--* LCL_VAR int V05 tmp2
| | | | \--* MDARR_LENGTH int (1)
| | | | \--* LCL_VAR ref V00 arg0
| | | \--* LCL_VAR int V05 tmp2
| | \--* CNS_INT long 4
| \--* CNS_INT long 32
\--* LCL_VAR ref V00 arg0
```
before being morphed by the usual morph transformations.
Some things to consider:
1. MD arrays have both a lower bound and length for each dimension (even if very few MD arrays actually have a
non-zero lower bound)
2. The new `GT_MDARR_LOWER_BOUND(dim)` node represents the lower-bound value for a particular array dimension. The "effective index" for a dimension is the index minus the lower bound.
3. The new `GT_MDARR_LENGTH(dim)` node represents the length value (number of elements in a dimension) for a particular array dimension.
4. The effective index is bounds checked against the dimension length.
5. The lower bound and length values are 32-bit signed integers (`TYP_INT`).
6. After constructing a "linearized index", the index is scaled by the array element size, and the offset from
the array object to the beginning of the array data is added.
7. Much of the complexity above is simply to assign temps to the various values that are used subsequently.
8. The index expressions are used exactly once. However, if have side effects, they need to be copied, early,
to preserve exception ordering.
9. Only the top-level operation adds the array object to the scaled, linearized index, to create the final
address `byref`. As usual, we need to be careful to not create an illegal byref by adding any partial index.
calculation.
10. To avoid doing unnecessary work, the importer sets the global `OMF_HAS_MDARRAYREF` flag if there are any
MD array expressions to expand. Also, the block flag `BBF_HAS_MDARRAYREF` is set on blocks where these exist,
so only those blocks are processed.
Remaining work:
1. Implement `optEarlyProp` support for MD arrays.
2. Implement loop cloning support for MD arrays.
3. (optionally) Remove old `GT_ARR_OFFSET` and `GT_ARR_INDEX` nodes and related code, as well as `GT_ARR_ELEM`
code used after the new expansion.
4. Implement improvements in CSE and LSRA to improve codegen for the MDMulMatrix benchmark.
The new early expansion is enabled by default. It can be disabled (even in Release, currently), by setting
`COMPlus_JitEarlyExpandMDArrays=0`. If disabled, it can be selectively enabled using
`COMPlus_JitEarlyExpandMDArraysFilter=<method_set>` (e.g., as specified for `JitDump`).
Fixes https://github.com/dotnet/runtime/issues/60785.
Tanner Gooding [Tue, 5 Jul 2022 19:51:46 +0000 (12:51 -0700)]
Exposing static bool IsSupported { get; } on Vector<T> and Vector64/128/256<T> (#71240)
* Exposing static bool IsSupported { get; } on Vector<T> and Vector64/128/256<T>
* Adding tests covering the new IsSupported API on Vector<T> and Vector64/128/256<T>
* Fix Mono JIT
* Fix warning on windows
* Let Vector64/128/256 IsSupported be handled by the fallback software implementation.
Co-authored-by: Fan Yang <yangfan@microsoft.com>
Zoltan Varga [Tue, 5 Jul 2022 19:01:28 +0000 (15:01 -0400)]
[mono][wasm] Add a minimal version of gsharedvt for llvmonly, enabled… (#70867)
* [mono][wasm] Add a minimal version of gsharedvt for llvmonly, enabled by default.
In this version, variable length arguments/locals are not supported. This means
that these compiled methods don't have the overhead of gsharedvt, i.e. wrappers,
dynamically allocated/copied locals, etc. They have similar performance to normal
generic sharing.
This can handle methods like List<T>.get_Item (), System.GC:AllocateArray<T>, etc.
* Fix gsharedvt returns on wasm.
* Allow byref gsharedvt types in gsharedvt in/out wrappers.
* Avoid setting both ctx->values and ctx->addresses for arguments of type LLVMArgGsharedvtFixedVtype.
* Fix support for gsharedvt+deopt.
* Disable UNBOX_ANY in gsharedvt_min mode.
* Fix llvmonly support for static methods with bound NULL first argument.
Some code paths can end up calling the general delegate invoke wrapper, which used
target!=NULL to decide whenever the call is bound, but the bound argument can be NULL.
So add a 'bound' field to Delegate and check it in the wrapper.
Some code paths might not set 'bound' so retain the target!=NULL check as well.
Zoltan Varga [Tue, 5 Jul 2022 18:17:33 +0000 (14:17 -0400)]
[mono][aot] Avoid inflating methods with instantiations with a wrong argument count when using profiled AOT. (#70926)
Fixes https://github.com/dotnet/runtime/issues/70773.
Tanay Parikh [Tue, 5 Jul 2022 18:08:06 +0000 (11:08 -0700)]
Blazor Hybrid iOS & Mac Catalyst Performance Profiling (#68685)
* [MAUI][Blazor][PERF] Add APK file usage for Android Maui Blazor SOD
* Update android_scenarios.proj
* Call ReportFullyDrawn
* Add --use-fully-drawn-time --fully-drawn-extra-delay
* Add System.Console.WriteLine for non-android platforms
* Add 6 second delay
* Missing `;`
* Add back Directory.Build.{props, targets}
(cherry picked from commit
28d9ef3ab4ac53b947dd435e6494428238b4dea5)
* Fixes based on CI 1729796
https://dev.azure.com/dnceng/internal/_build/results?buildId=1729796&view=logs&j=
4d93e3ae-0b8e-5532-bed2-
af5c8a7c58d3&t=
b13dec14-3eb2-5f1a-4501-
8a9fdadb0e3a
(cherry picked from commit
d470655576d3abe6a6fec478c221c4d9de698ba9)
* [REVERT THIS] Temporarily skip other jobs
(cherry picked from commit
df51582df9e7bb9d1ca82759d664823c76823c29)
* [MAUI][Blazor][PERF] Add IPA file usage for iOS/MacCatalyst Maui Blazor SOD
(cherry picked from commit
b1aaaf222e302c19ad6760eaa7cdb1f0e7ed364d)
* Remove / restore nuget.config
* Escape quotes
* Fix typo
* Replicate changes from https://github.com/dotnet/runtime/pull/67670
* use-fully-drawn-time
* Use akoeplinger/performance
* Fix misplaced quote character
* Revert "Use akoeplinger/performance"
This reverts commit
12358b6f024bd1727aee8bf5ad71576d69623734.
The change was merged to dotnet/performance.
* Add ` --startup-iterations 7`
* Revert "[REVERT THIS] Temporarily skip other jobs"
This reverts commit
54fa30d876e2be0fef82883033d8fb027de2a150.
* Remove SOD Startup Iterations
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
Jan Kotas [Tue, 5 Jul 2022 18:04:43 +0000 (11:04 -0700)]
Release global lock before throwing exceptions from the Unix WaitSystem (#71626)
The exception throwing and handling can enter wait system recursively that will lead to deadlock.
Fixes #70010
Tanner Gooding [Tue, 5 Jul 2022 17:42:38 +0000 (10:42 -0700)]
Refactoring IShiftOperators to take a `TOther` (#71405)
* Refactoring IShiftOperators to take a `TOther`
* Break IShiftOperators typeloading cycle
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Alan Hayward [Tue, 5 Jul 2022 17:42:26 +0000 (18:42 +0100)]
Add Conditional nodes and Arm64 code generation (#71616)
Thays Grazia [Tue, 5 Jul 2022 17:14:18 +0000 (14:14 -0300)]
[wasm][debugger]Fix debugging when it's using a external library without debug information (#71560)
* Fix debugging when it's using a external library without debug information.
* [wasm] Rationalize TypeInfo construction
* separating dynamic assemblies
* lazy-debugger-test-embedded should only be available to the tests on disk, but *not* the test app
* debugger-test.csproj: cleanup
* Fix metadata name for not only building project references
* Fixing not getting codeview information from assemblies that don't have this information.
* Adressing @radical comments.
Co-authored-by: Ankit Jain <radical@gmail.com>
CyrusNajmabadi [Tue, 5 Jul 2022 16:49:44 +0000 (09:49 -0700)]
Polyfill the incremental generator ForAttributeWithMetadataName from roslyn. (#70911)
* Add the initial roslyn files
* IN progress
* Builds
* Use api
* ifdef
* Move using outside namespace
* Move to debug assert
* Optimize common cases
* Explain if'defed regions
* Explain if'defed regions
* Update System.Text.RegularExpressions.Generator.csproj
* Port latest changes over
* Renames
* Update src/libraries/Common/src/Roslyn/CSharpSyntaxHelper.cs
* Simplify
* Dispose builders
* Dispose builders
* Simplify by removing support for nested attributes
* Simplify
Huo Yaoyuan [Tue, 5 Jul 2022 15:17:18 +0000 (23:17 +0800)]
Set utf-8 for mono on msvc (#70994)
Jo Shields [Tue, 5 Jul 2022 15:08:49 +0000 (11:08 -0400)]
Add a build lane for FreeBSD Mono. (#69715)
* Add a build lane for FreeBSD Mono.
No test build/run, as there's no Helix queue for it.
Steve Pfister [Tue, 5 Jul 2022 14:47:26 +0000 (10:47 -0400)]
Update area-owners.md (#71639)
Add owner for area-Diagnostics-mono
Eirik Tsarpalis [Tue, 5 Jul 2022 13:19:49 +0000 (14:19 +0100)]
Ensure JsonTypeInfo.Configure() is called once even when exceptions are thrown (#71630)
* Ensure JsonTypeInfo.Configure() is called once even when exceptions are thrown
* Add cached exception check in critical section
Eirik Tsarpalis [Tue, 5 Jul 2022 12:55:56 +0000 (13:55 +0100)]
Ensure JsonPropertyInfo<T> matches property type and not the converter type (#71612)
Qiao Pengcheng [Tue, 5 Jul 2022 10:15:28 +0000 (18:15 +0800)]
[LoongArch64] Fixed the assert error "!tree->gtOp1->isContained()" (#71577)
within the "CodeGen::genCodeForNullCheck()"
SingleAccretion [Tue, 5 Jul 2022 08:13:41 +0000 (11:13 +0300)]
Handle out-of-bounds access to locals in block morphing (#71617)
Michal Strehovský [Tue, 5 Jul 2022 07:31:17 +0000 (16:31 +0900)]
Get S.C.Immutable.Tests running with NativeAOT (#71527)
* The debugger type proxy tests use MakeGeneric to create the right proxy kind. We've been conditionally disabling all those tests. They don't make sense in NativeAOT currently.
* A couple test methods are generic and xUnit needs to MakeGeneric them. Supply RD.XML.
James Newton-King [Tue, 5 Jul 2022 00:13:13 +0000 (08:13 +0800)]
Throw protocol error returned by GoAway on HTTP/2 connection negotation (#71572)
Stefan Schulze Frielinghaus [Mon, 4 Jul 2022 18:56:50 +0000 (20:56 +0200)]
[mono][eventpipe] Write primitive types and UTF-16 strings in little endian order (#68648)
* [mono][eventpipe] Add big-endian support.
Johan Lorensson [Mon, 4 Jul 2022 18:52:31 +0000 (20:52 +0200)]
Fix EventPipe profiler recursion in class_loading under full AOT. (#71610)
Happens in full AOT mode where methods have been compiled as direct calls
(happens within an assembly). In that case, the method is not known by
the runtime (not present in the JIT info table). When a new class is
loading, the class_loading profiler callback is called. The EventPipe
implementation of that callback will take a stackwalk
(inline with CoreCLR behavior), but taking a stackwalk will look
up each managed function on the callstack against the JIT info table,
if its not there it will load it, that in turn could case additional
recursive class_loading event to fire, that will again take the same
callstack, ending up in an infinite recursion.
The issue is even a little more problematic, since it turns out you
cannot do anything inside the class_loading callback that might end up
triggering a class load, since that might lead up to recursively loading
the same type, that in turn will assert when outer class_loading call
returns and tries to add it into the loaded class cache.
Fix will harden the stackwalking logic inside EventPipe to detect
recursive stackwalks (doing a stackwalk triggering another stackwalk)
and if that is the case, the stackwalk will be done using the
async_context stackwalking capabilities since that won't trigger
any additional profiler events, breaking recursion.
Fix also adds logic to the class_loading profiler callback in EventPipe
to prevent recursion making sure it won't trigger any additional profiler
events, leading up to potential issues loading the same class twice, that
will cause an assert inside the class loader logic.
For 1:1 mapping of old Mono profiler events issued into EventPipe,
they have been aligned with old Mono log profiler events callstack
behaviours, meaning it will only emit callstacks on a few limited
profiler events, mitigating the issues seen in the runtime profiler
provider.
Omair Majid [Mon, 4 Jul 2022 18:29:12 +0000 (14:29 -0400)]
Add Ubuntu 22.04 to libraries CI run (#67345)
This is to help catch OpenSSL 3.0 issues.
Eirik Tsarpalis [Mon, 4 Jul 2022 11:42:45 +0000 (12:42 +0100)]
Refactor JsonPropertyInfo initialization infrastructure and implement JsonPropertyInfo.AttributeProvider (#71514)
* Implement JsonPropertyInfo.AttributeProvider and refactor initialization infrastructure
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
* Update src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Metadata/JsonPropertyInfo.cs
* _shouldSerializeIsExplicitlySet set to false when setting IgnoreCondition
* Reinstante _converterIsExternalAndPolymorphic
* Move unique attribute resolution logic to reflection extensions
* address feedback
Michal Strehovský [Mon, 4 Jul 2022 06:59:29 +0000 (15:59 +0900)]
Implement type loader support for thread statics (#71524)
We do threadstatics differently from .NET Native and this wasn't implemented.
Fixes #70878 that was reaching a failfast because we couldn't build the target of GVM dispatch at runtime due to unhandled dictionary cell.
I've homed the threadstatic bases under the type manager of the template type. We could potentially make a new type manager, but they currently use this one.
Deleted some more .NET Native leftovers.
Had to update the DynamicGeneric test RD.XML because the test was assuming .NET Native behavior where the ctors are always kept on types that escape the dataflow analysis.
Qiao Pengcheng [Sun, 3 Jul 2022 04:26:07 +0000 (12:26 +0800)]
[LoongArch64] Fixed the assert error "(regRecord->assignedInterval == nullptr)" (#71576)
Adeel Mujahid [Sun, 3 Jul 2022 03:44:27 +0000 (06:44 +0300)]
Defer objcopy selection after alt. compiler check (#71554)
In the environment where `gcc` is auto-detected (during
`SetupOSSpecificProps` target execution), we should be selecting
binutils' `objcopy`, rather than `llvm-objcopy`.
Andrew Au [Sat, 2 Jul 2022 22:25:38 +0000 (15:25 -0700)]
We should return the error when there is one (#71585)
Aaron Robinson [Sat, 2 Jul 2022 21:07:27 +0000 (14:07 -0700)]
Consume Roslyn with `ref` fields support (#71498)
* Use C# ref field support
Update public APIs
* Create new ByReference to be used in Reflection and tailcall slow paths
* Limit net6.0 TFM in DiagnosticsSource to C# 10.
* Remove temporary LifetimeAnnotationAttribute
This is supplied by Roslyn.
* Update to Roslyn compiler with ref field support.
* Update comments with those approved in official docs.
* Handle byref field in interpreter
* Fix build break when DEBUG_INTERP defined.
SingleAccretion [Sat, 2 Jul 2022 19:35:06 +0000 (22:35 +0300)]
Enable `TYP_STRUCT` `LCL_VAR/LCL_FLD` call args on LA (#71327)
* Support "PUTARG_STK/SPLIT(STRUCT LCL_VAR/LCL_FLD)" on LA
* LA: [local] morph
* Delete now-not-needed "OBJ(ADDR(LCL_VAR))" wrapping
Egor Bogatov [Sat, 2 Jul 2022 10:13:03 +0000 (12:13 +0200)]
JIT: Run optRedundantBranches twice and try to compute more accurate doms (#70907)
Co-authored-by: Andy Ayers <andya@microsoft.com>
Mukund Raghav Sharma (Moko) [Sat, 2 Jul 2022 07:23:59 +0000 (00:23 -0700)]
Added a new method to the GC API to Get the GC Configurations (#70514)
Reviewed by: @cshung @jkotas @AaronRobinsonMSFT @Maoni0
Co-authored-by: Aaron Robinson <arobins@microsoft.com>
Vitek Karas [Sat, 2 Jul 2022 03:52:19 +0000 (20:52 -0700)]
Add `RequiresAssemblyFiles` onto `Marshal.GetHINSTANCE`. (#71531)
* Add `RequiresAssemblyFiles` onto `Marshal.GetHINSTANCE`.
The `GetHINSTANCE` only works on modules/assemblies which are loaded from a file on disk (must be loaded via `LoadLibrary` really), in single-file like scenarios lot of assemblies are loaded directly from memory. For such assemblies the API returns -1 which is not a valid handle.
* Add the attribute to ref assembly
* Add it on the non-implemented version
Carlos Sanchez [Sat, 2 Jul 2022 03:19:52 +0000 (20:19 -0700)]
Implement Tar async APIs (#70574)
* ref: TarEntry.ExtractToFileAsync
* src: Implement TarEntry.ExtractToFileAsync
* ref: Add TarReader.GetNextEntryAsync
* src: Implement TarReader.GetNextEntryAsync
* ref: Add TarWriter.WriteEntryAsync
* src: Implement TarWriter.WriteEntryAsync
* ref: Add TarFile.CreateFromDirectoryAsync
* src: Implement TarFile.CreateFromDirectoryAsync
* ref: Add TarFile.ExtractToDirectoryAsync
* src: Implement TarFile.ExtractToDirectoryAsync
* ref: Add TarWriter.DisposeAsync
* src: Implement TarWriter.DisposeAsync
* ref: Add TarReader.DisposeAsync
* src: Implement TarReader.DisposeAsync
* tests: Async tests, analogous to the sync ones.
Kevin Jones [Sat, 2 Jul 2022 01:26:27 +0000 (21:26 -0400)]
Various cryptographic allocation improvements
Juan Hoyos [Sat, 2 Jul 2022 00:56:54 +0000 (17:56 -0700)]
Add arm64 macOS cross-compilation instructions. (#71568)