platform/upstream/dotnet/runtime.git
2 years agoEnsure several helper intrinsics are correctly imported and handled (#63972)
Tanner Gooding [Fri, 21 Jan 2022 19:46:21 +0000 (11:46 -0800)]
Ensure several helper intrinsics are correctly imported and handled (#63972)

* Ensure several helper intrinsics are correctly imported and handled

* Ensure that Sum for TYP_INT/UINT on Arm64 is correctly handled

* Respond to PR feedback and ensure ExtractMostSignificantBits for Vector64<int/uint> on Arm64 also uses AddPairwise

* Applying formatting patch

* Ensure the clsHnd is correct

* Fix the remaining musl failures

* Ensure that we aren't sign-extending TYP_BYTE (System.SByte) for ExtractMostSignificantBits

* Ensure an assert is correct on x64

* Ensure Vector64<int/uint>.Dot on Arm64 uses AddPairwise, not AddAcross

* Apply formatting patch

2 years agoFixed IsFloatPositiveZero from returning 'true' on non-constant double operands ...
Will Smith [Fri, 21 Jan 2022 19:44:37 +0000 (11:44 -0800)]
Fixed IsFloatPositiveZero from returning 'true' on non-constant double operands (#64083)

* Fixed IsFloatPositiveZero from returning 'true' on non-constant double operands

* Update src/coreclr/jit/gentree.h

Co-authored-by: Egor Bogatov <egorbo@gmail.com>
Co-authored-by: Egor Bogatov <egorbo@gmail.com>
2 years ago[wasm][debugger] Apply changes on wasm using sdb protocol. (#63705)
Thays Grazia [Fri, 21 Jan 2022 18:10:04 +0000 (15:10 -0300)]
[wasm][debugger] Apply changes on wasm using sdb protocol. (#63705)

* Apply changes on wasm using sdb protocol.

* conflict

* Merge conflict.

* Fix merge

* Fix compilation error.

2 years agoAvoid additional local created for delegate invocations (#63796)
Jakob Botsch Nielsen [Fri, 21 Jan 2022 17:25:32 +0000 (18:25 +0100)]
Avoid additional local created for delegate invocations (#63796)

Very often 'this' is already a local and we can avoid creating another
local.

2 years agoILVerify: Handle readonly references in ldfld (#64077)
Jan Kotas [Fri, 21 Jan 2022 16:22:51 +0000 (08:22 -0800)]
ILVerify: Handle readonly references in ldfld (#64077)

* ILVerify: Handle readonly references in ldfld

Fixes #63953

* Fix test name

Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
2 years agoFix crash when VS4Mac is debugging VS4Mac arm64 (#64085)
Mike McLaughlin [Fri, 21 Jan 2022 14:09:07 +0000 (06:09 -0800)]
Fix crash when VS4Mac is debugging VS4Mac arm64 (#64085)

Fix crash when VS4Mac is debugging VS4Mac arm64

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

2 years ago[main] Update dependencies from 5 repositories (#64002)
dotnet-maestro[bot] [Fri, 21 Jan 2022 13:44:23 +0000 (14:44 +0100)]
[main] Update dependencies from 5 repositories (#64002)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Přemek Vysoký <premek.vysoky@microsoft.com>
2 years agoAdd StringSyntaxAttribute.Json (#64081)
Stephen Toub [Fri, 21 Jan 2022 12:44:36 +0000 (07:44 -0500)]
Add StringSyntaxAttribute.Json (#64081)

2 years agoInitial WASI support prototype (#63890)
Steve Sanderson [Fri, 21 Jan 2022 09:41:24 +0000 (09:41 +0000)]
Initial WASI support prototype (#63890)

2 years agoFix broken callstacks in interpreter on MonoVM. (#60338)
Johan Lorensson [Fri, 21 Jan 2022 09:31:08 +0000 (10:31 +0100)]
Fix broken callstacks in interpreter on MonoVM. (#60338)

* Fix some broken callstacks in interpreter.

* Fix build error.

2 years agoMake ILLink validation steps in libs incrementally buildable (#64041)
Viktor Hofer [Fri, 21 Jan 2022 09:09:24 +0000 (10:09 +0100)]
Make ILLink validation steps in libs incrementally buildable (#64041)

* Make ILLink validation steps in libs incrementally buildable

Both the illink-oob and the illink-sharedframework targets don't define Inputs and Outputs which makes them run during no-op incremental builds. This change defines Inputs and Outputs based on what's used during the target's execution so that if the input assemblies or the illink assembly itself haven't changed, the step will be skipped.

Also renaming properties and items to make them more readable and consistent. As these target files are "extensions" of the src.proj file and aren't shared anywhere, they can be treated like logic inside a project file and hence prefixing properties and items with an underscore "_" isn't necessary.

2 years agoImplement System.Runtime.CompilerServices.DisabledRuntimeMarshallingAttribute on...
Jeremy Koritzinsky [Fri, 21 Jan 2022 08:10:01 +0000 (00:10 -0800)]
Implement System.Runtime.CompilerServices.DisabledRuntimeMarshallingAttribute on CoreCLR-family of runtimes/type systems (#63320)

* Add the DisableRuntimeMarshallingAttribute to the build.

* Add initial test suite

* Implement support in IL stubs for the "disabled runtime marshalling" feature.

* Add testing for inlining IL stubs.

* Block SetLastError and LCID support when DisableRuntimeMarshallingAttribute is applied.

* Bump NativeAOT-only R2R version header (missed previously)

* Implement support in crossgen2 and NativeAOT

* Clean up the test tree and update the tests to fail more reliably when bugs are present.

Fix a bug that was uncovered when the tests were refactored.

* Fix NativeAOT and clean up crossgen2

* Add a test for NoPreserveSig with DisableRuntimeMarshalling

* Assign hr in SUCCEEDED macro.

* PR feedback.

* Block varargs in disabled marshalling mode.

* Fix typo

* Block types that have a field that is auto-layout somewhere in their layout.

* Fix typo

* Revert the AutoLayoutOrHasAutoLayoutFIeld check in the "marshalling enabled" case

* Only set scope when it isn't null (it's null for some cases).

* Fix narrowing conversion failure.

* First pass simple implementation in Mono

* Fix assert to still work for the built-in marshalling system

* S_FALSE is a thing

* Fix type load failures caused by eager type handle loading.

* Get MethodILScope from the calling method when available (this covers all cases where we need it)

* Add const modifier.

* Try 2 to fix const modifiers

* Fix compilation of NativeAOT jitinterface

* Fix type lookup in Mono

* Use try_get model for getting the attribute type in the case of failure. Fix mono implementation for looking up the attribute.

* Handle void and generic instantiations

* Update auto-layout check to check recursively in layout.

* Enhance test suite with more tests for UnmanagedCallersOnly, generics, and the like. Fix AutoLayout test.

* Fix IL and a few typos

* Set a value in the padding for easier debugging.

* Create sig->marshalling_disabled to track when marshalling is disabled, which is separate from the concept of "is this signature a P/Invoke"

* Fix running test suite on Mono + Mini JIT

* Fix recursive type load failure by only checking the "has auto-layout or field with auto-layout" for value types.

* Fix mono windows build.

* Feedback from Michal.

* Fix bug in EcmaAssembly.HasAssemblyCustomAttribute

* Make the runtime flavor check in the wrapper generator case-invariant

* Use helper method since various different platforms/configurations throw different exceptions for these scenarios.

* Fix AutoLayout test refactor and use a dummy value for the padding field in both enabled and disabled scenarios.

* Add an explicit test for using enums as they're a little weird and needed some special-casing.

* Fix build-time test filtering in xunit wrapper generator.

* Fix some x86-specific issues

* Add a nice big comment block.

* Fix x86

* Refactor tests so we can skip one on Mono since Char->char lossy conversion is not supported.

* Disable test in issues.targets until an alternative solution is reached.

* Add another SkipOnMono attribute in the "Enabled" test suite.

* Apply UnmangedFunctionPointerAttribute to help hint to the Mono LLVM AOT compiler to compile the managed->native thunks at aot-time

* Unify on "runtime marshalling" terminology

* Clean up unused usings.

* Address Jan's feedback except for applying the attribute to CoreLib.

* PR feedback.

* Mono throws an InvalidProgramException for varargs

* Fix copy-paste issue.

* Make sure we use the P/Invoke's Module and not the caller's module when deciding if runtime marshalling is enabled for a varargs P/Invoke call.

* Handle how LLVM AOT reports the failure to handle varargs (EEE)

2 years agodon't Flush readonly MemoryMappedViewAccessor on disposal (#63794)
Adam Sitnik [Fri, 21 Jan 2022 08:08:03 +0000 (09:08 +0100)]
don't Flush readonly MemoryMappedViewAccessor on disposal (#63794)

* don't Flush if it's impossible to write

* address code review feedback: apply same optimization to MemoryMappedViewStream

2 years agoIntroduce RandomAccess.SetLength (#63992)
Adam Sitnik [Fri, 21 Jan 2022 08:06:46 +0000 (09:06 +0100)]
Introduce RandomAccess.SetLength (#63992)

2 years agoUpdate the macOS CoreCLR building documentation. (#63932)
Kevin Jones [Fri, 21 Jan 2022 07:26:05 +0000 (02:26 -0500)]
Update the macOS CoreCLR building documentation. (#63932)

This updates the documentation to refer to the up-to-date location of
requirements and prerequisites.

2 years agoAdd pmi_path argument to superpmi.py script and use it in the superpmi-collect pipeli...
Egor Chesakov [Fri, 21 Jan 2022 03:23:21 +0000 (19:23 -0800)]
Add pmi_path argument to superpmi.py script and use it in the superpmi-collect pipeline. (#63983)

* Add -pmi_path argument to superpmi.py collect command and use it to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py

* Set pmi_path to $(SuperPMIDirectory)\crossgen2

* Print a warning if -pmi_path or -pmi_location is specified while --pmi is not in src/coreclr/scripts/superpmi.py

* Move setting of PMIPATH environment variable under `if self.coreclr_args.pmi is True:` in src/coreclr/scripts/superpmi.py

* Move pmi argument validation to setup_args() in src/coreclr/scripts/superpmi.py

* Clone root_env if we are going to set PMIPATH environment variable in src/coreclr/scripts/superpmi.py

2 years agoRemove commented code (#63869)
Wrzucher [Fri, 21 Jan 2022 01:44:30 +0000 (07:44 +0600)]
Remove commented code (#63869)

2 years agoAllow CreateScalarUnsafe to be directly contained by hwintrinsics that support scalar...
Tanner Gooding [Fri, 21 Jan 2022 01:23:24 +0000 (17:23 -0800)]
Allow CreateScalarUnsafe to be directly contained by hwintrinsics that support scalar loads (#62407)

* Ensure that floating-point constants can be contained by hardware intrinsics

* Allow CreateScalarUnsafe to be directly contained by hwintrinsics that support scalar loads

* Rename IsContainableHWIntrinsicOp to TryGetContainableHWIntrinsicOp and improve handling

* Ensure that NI_AVX2_BroadcastScalarToVector128/256 are properly tracked as MaybeMemoryLoad

* Applying formatting patch

* Ensure a few other "maybe memory" and special memory operand size cases are handled

* Applying formatting patch

2 years agoEnable some browser legs on the extra-platforms pipeline (#64065)
Santiago Fernandez Madero [Fri, 21 Jan 2022 00:47:27 +0000 (16:47 -0800)]
Enable some browser legs on the extra-platforms pipeline (#64065)

* Enable some browser legs on the extra-platforms pipeline

* Flow platform parameter from helix queues templates

* Fix another condition

2 years agoLog message of unexpected exception in ThrowsAny (#64064)
Dan Moseley [Fri, 21 Jan 2022 00:14:54 +0000 (17:14 -0700)]
Log message of unexpected exception in ThrowsAny (#64064)

* Log message of unexpected exception in ThrowsAny

* Update AssertExtensions.cs

2 years agoRead the System.GC.CpuGroup settings in runtimeconfig.json (#64067)
Andrew Au [Thu, 20 Jan 2022 22:23:19 +0000 (14:23 -0800)]
Read the System.GC.CpuGroup settings in runtimeconfig.json (#64067)

2 years agoSync shared code from aspnetcore (#64059)
github-actions[bot] [Thu, 20 Jan 2022 22:17:24 +0000 (11:17 +1300)]
Sync shared code from aspnetcore (#64059)

Co-authored-by: JamesNK <JamesNK@users.noreply.github.com>
2 years agoAdd StringSyntax attribute to Regex.pattern field (#64063)
Stephen Toub [Thu, 20 Jan 2022 21:28:17 +0000 (16:28 -0500)]
Add StringSyntax attribute to Regex.pattern field (#64063)

I missed adding this one in my initial audit.  It'll be exceedingly rare for a developer to manually write code that assigns a string to this protected field, but every source-generated regex does so, and thus any colorization VS provides will benefit looking at the source-generated code.

2 years agoFix exception propagation over HW exception frame on macOS arm64 (#63596)
Jan Vorlicek [Thu, 20 Jan 2022 21:15:03 +0000 (22:15 +0100)]
Fix exception propagation over HW exception frame on macOS arm64 (#63596)

* Fix exception propagation over HW exception frame on macOS arm64

There is a problem unwinding over the PAL_DispatchExceptionWrapper
to the actual hardware exception location. The unwinder is unable
to get distinct LR and PC in that frame and sets both of them to
the same value. This is caused by the fact that the
PAL_DispatchExceptionWrapper is just an injected fake frame and
there was no real call. Calls always return with LR and PC set
to the same value.

The fix unifies the hardware exception frame unwinding with Linux
where we had problems unwinding over signal handler trampoline, so
PAL_VirtualUnwind skips the trampoline and now also the
PAL_DispatchExceptionWrapper frame by copying the context of
the exception as the unwound context.

* Reenable DllImportGenerator.Unit.Tests

2 years agoPerformance: Fix Browser Wasm job not being found for dependent jobs (#64058)
Parker Bibus [Thu, 20 Jan 2022 21:07:08 +0000 (15:07 -0600)]
Performance: Fix Browser Wasm job not being found for dependent jobs (#64058)

* Figure out the name that browser wasm now uses.

*  linux to the Browser wasm depends on name.

Update the browser wasm dependson name to match the new one found in the pipeline.

2 years agoRevert "Temporarily disable coredumps during library testing on macOS (#63742)" ...
Jan Kotas [Thu, 20 Jan 2022 20:51:28 +0000 (12:51 -0800)]
Revert "Temporarily disable coredumps during library testing on macOS (#63742)" (#64057)

This reverts commit 2c28e63f9360280011a3b03c1ca6dc0edce1fae4.

Fixes #63761

2 years agoPreserve OBJ/BLK on the RHS of ASG (#63268)
SingleAccretion [Thu, 20 Jan 2022 20:46:24 +0000 (23:46 +0300)]
Preserve OBJ/BLK on the RHS of ASG (#63268)

One of my upcoming changes will need this information to
accurately detect type mismatch in "fgValueNumberBlockAssignment".

2 years agoUpdate XUnit to 2.4.2-pre.22 (#63948)
Eric StJohn [Thu, 20 Jan 2022 18:35:50 +0000 (10:35 -0800)]
Update XUnit to 2.4.2-pre.22 (#63948)

* Update to Xunit build 2.4.2-pre.13

Also pick up latest pre-release of analyzers

* Disambiguate calls to Assert.Equals(double,double,int)

Xunit added a new Assert overload that caused a lot of ambiguous calls.
https://github.com/xunit/xunit/issues/2393

Workaround by casting to double.

* Fix new instances of xUnit2000 diagnostic

* Workaround xUnit2002 issue with implicit cast

Works around https://github.com/xunit/xunit/issues/2395

* Disable xUnit2014 diagnostic

This diagnostic forces the use of Assert.ThrowsAsync for any async method,
however in our case we may want to test that a method will throw
synchronously to avoid regressing that behavior by moving to the async
portion of the method.

* Use AssertExtensions to test for null ArgumentException.ParamName

Workaround https://github.com/xunit/xunit/issues/2396

* Update to Xunit 2.4.2-pre.22

* Fix another ArugmentException.ParamName == null assert

2 years agoChange test to check for store block operators (#60878)
yowl [Thu, 20 Jan 2022 18:04:58 +0000 (13:04 -0500)]
Change test to check for store block operators (#60878)

2 years agoException sets: debug checker & fixes (#63539)
SingleAccretion [Thu, 20 Jan 2022 18:01:33 +0000 (21:01 +0300)]
Exception sets: debug checker & fixes (#63539)

* Add a simple exception sets checker

* Add asserts to catch missing nodes

* Fix normal VN printing

* Fix JTRUE VNs

* Fix PHI VNs

* Update VNs for "this" ARGPLACE node

* Tolerate missing VNs on PHI_ARGs

We do not update them after numbering the loops.

(Though perhaps we should)

* Tolerate unreachable blocks

* Fix exception sets for VNF_PtrTo VNFuncs

* Add VNUniqueWithExc

* Add VNPUniqueWithExc

* Fix arrays

* Consistently give location nodes VNForVoid

And always add exception sets for them.
This will simplify the exception set
propagation code for assignments.

* Fix CSE

* Fix GT_RETURN

* Fix LCLHEAP

* Fix GT_ARR_ELEM

* Fix unique HWI

* Fix unique SIMD

* Fix GT_SWITCH

* Fix CKFINITE

* Fix HWI loads

* Fix fgValueNumberAddExceptionSetForIndirection

The method does not need to add the exception set for
the base address. Additionally, the way it did add the
sets, by unioning with normal value numbers, lost all
exceptions not coming from the base address.

This was fine for the unary loads, but broke the HWI loads
that could have exceptions coming from not just the address.

* Fix GT_RETFILT

* Fix INIT_VAL

* Fix DYN_BLK

* Fix FIELD_LIST

* De-pessimize CkFinite

* Add a test for HWIs

* Add a test for LCLHEAP

2 years agoAdd ns2.0 support to System.Formats.Cbor (#62872)
David Cantú [Thu, 20 Jan 2022 17:49:27 +0000 (09:49 -0800)]
Add ns2.0 support to System.Formats.Cbor (#62872)

* Add ns2.0 support to System.Formats.Cbor

* Add NetFrameworkMinimum to tfms

* Add ReadHalf and WriteHalf to compatibility suppressions

* Remove unwanted comment

2 years agoRemove Type.MakeGenericType dependency from source generation (#64004)
Eirik Tsarpalis [Thu, 20 Jan 2022 17:00:41 +0000 (17:00 +0000)]
Remove Type.MakeGenericType dependency from source generation (#64004)

* Remove Type.MakeGenericType dependency from srcgen

* address feedback

* add trimmer warning suppression

* address feedback

2 years agoAdd test coverage for frozen objects and GC interaction (#64030)
Michal Strehovský [Thu, 20 Jan 2022 16:50:37 +0000 (01:50 +0900)]
Add test coverage for frozen objects and GC interaction (#64030)

* Test coverage for frozen objects and GC interaction

* Update Preinitialization.cs

2 years agoDisable DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException (#64044)
Stephen Toub [Thu, 20 Jan 2022 16:24:09 +0000 (11:24 -0500)]
Disable DirectoryLongerThanMaxLongPathWithExtendedSyntax_ThrowsException (#64044)

2 years agoReduce the memory footprint of HttpHeaders (#62981)
Miha Zupan [Thu, 20 Jan 2022 16:22:20 +0000 (08:22 -0800)]
Reduce the memory footprint of HttpHeaders (#62981)

* Change HttpHeaders backing store to an array

* Reduce the size of HeaderDescriptor to 1 object

* Update UnitTests, fix GetOrCreateHeaderInfo

* Switch to a dictionary after ArrayThreshold headers

* Add unit tests

* Use storeValueRef naming consistently

* Workaround field layout regression (#63005)

* Mark _descriptor on HeaderDescriptor as nullable

* Remove HeaderDescriptor.Descriptor and add HasValue, IsKnownHeader, Equals

* Simplify HttpHeaderParser.Separator logic

* Add comments on HasValue checks

* Lazily group headers by name

* Add a header ordering+grouping test

* Make use of the _count field

* Revert all HeaderDescriptor changes from PR

* Switch back to always grouping by name

* Assert that the collection is not empty in GetEnumeratorCore

* Optimize AddHeaders for empty collections

* Reference the Roslyn bug issue

* Assert that multiValues are never empty

* Don't preserve a Dictionary across Clear

* Add comment about why a custom HeaderEntry type is used

2 years ago[API Implementation]: System.Diagnostics.CodeAnalysis.StringSyntaxAttribute (#62995)
Robin Lindner [Thu, 20 Jan 2022 14:21:44 +0000 (15:21 +0100)]
[API Implementation]: System.Diagnostics.CodeAnalysis.StringSyntaxAttribute (#62995)

* Add StringSyntaxAttribute

* Fix attribute declaration and add usage

* Address PR feedback

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2 years agoFix dependency in runtime-official.yml (#64040)
Alexander Köplinger [Thu, 20 Jan 2022 13:36:09 +0000 (14:36 +0100)]
Fix dependency in runtime-official.yml (#64040)

After https://github.com/dotnet/runtime/pull/62564 the `hostedOs` value is included in the job name.

2 years ago[wasm] WebSocket tests on NodeJS (#63441)
Marek Fišera [Thu, 20 Jan 2022 12:58:49 +0000 (13:58 +0100)]
[wasm] WebSocket tests on NodeJS (#63441)

- NPM package with WS.
- Restore npm during build.
- Load npm modules in test-main.js.

Co-authored-by: Pavel Savara <pavel.savara@gmail.com>
2 years agoPolish the PR build doc (#64036)
Maxim Lipnin [Thu, 20 Jan 2022 12:29:18 +0000 (15:29 +0300)]
Polish the PR build doc (#64036)

2 years ago[wasm][debugger] Added support for stepper boundary attribute (#63991)
Ilona Tomkowicz [Thu, 20 Jan 2022 10:03:02 +0000 (11:03 +0100)]
[wasm][debugger] Added support for stepper boundary attribute (#63991)

* Hidden methods and step through methods behave the same way.

* Perpared flow for setting JustMyCode in the future.

* Tests for JustMyCode setting before debug launch.

* Transformed into dynamic JustMyCode change flow.

* JustMyCode disabled, first 3 cases solved.

* Finished behavior for JMC disabled (with 1 difference).

* JMC enabled: stepIn np bp + stepIn bp + resume bp.

* Functional version (with minor deviations from expected behavior).

* Refactoring.

* All tests for NonUserCode work.

* Fix line number after adding code above.

* Stepper boundary with tests.

* Save information about multiple decorators.

* Fix error in merge.

2 years ago[debugger][wasm] Added support for non user code attribute (#63876)
Ilona Tomkowicz [Thu, 20 Jan 2022 09:26:06 +0000 (10:26 +0100)]
[debugger][wasm] Added support for non user code attribute (#63876)

* Hidden methods and step through methods behave the same way.

* Perpared flow for setting JustMyCode in the future.

* Tests for JustMyCode setting before debug launch.

* Transformed into dynamic JustMyCode change flow.

* JustMyCode disabled, first 3 cases solved.

* Finished behavior for JMC disabled (with 1 difference).

* JMC enabled: stepIn np bp + stepIn bp + resume bp.

* Functional version (with minor deviations from expected behavior).

* Refactoring.

* All tests for NonUserCode work.

* Fix line number after adding code above.

* Fix error in merge.

* Removing duplicated tests.

2 years agoFix issues with verify_regions, clear_batch_mark_array_bits. (#63798)
Peter Sollich [Thu, 20 Jan 2022 09:06:45 +0000 (10:06 +0100)]
Fix issues with verify_regions, clear_batch_mark_array_bits. (#63798)

Details:
- we cannot verify the tail of the region list from background GC, as it may be updated by threads allocating.
- fix case in clear_batch_mark_array_bits where end is equal to the very end of a segment and we write into uncommitted memory in the mark_array.
-  bgc_clear_batch_mark_array_bits did some checks and then called clear_batch_mark_array_bits which repeated the exact same checks. Renamed clear_batch_mark_array_bits to bgc_batch_mark_array_bits and removed the old copy, removed the declaration for clear_batch_mark_array_bits.

2 years agoFix OpenSSL version check in GetAlpnSupport
Jeremy Barton [Thu, 20 Jan 2022 08:06:28 +0000 (00:06 -0800)]
Fix OpenSSL version check in GetAlpnSupport

The previous check failed 3.0.0 because the Minor was 0 and Build was 0.

It could probably be rewritten to be `>= new Version(1, 0, 2)`, but that'd require more thinking.

2 years agoFix gc_heap::remove_ro_segment (#63473)
Andrew Au [Thu, 20 Jan 2022 04:57:41 +0000 (20:57 -0800)]
Fix gc_heap::remove_ro_segment (#63473)

2 years agoAdd ProcessLinkerXmlBase to NativeAOT (#63666)
Tlakaelel Axayakatl Ceja [Thu, 20 Jan 2022 03:46:45 +0000 (19:46 -0800)]
Add ProcessLinkerXmlBase to NativeAOT (#63666)

Add Xml Parsing linker files as a reference source to NativeAOT
Rename NativeAOT ProcessLinkerXmlBase version to ProcessXmlBase (uses XmlReader)
Add ProcessLinkerXmlBase from linker and fix it so it can be used in NativeAOT (uses XPath)

2 years ago[Arm64] Keep unrolling InitBlock and CopyBlock up to 128 bytes (#63422)
Egor Chesakov [Thu, 20 Jan 2022 03:43:26 +0000 (19:43 -0800)]
[Arm64] Keep unrolling InitBlock and CopyBlock up to 128 bytes (#63422)

* Add INITBLK_LCL_UNROLL_LIMIT and CPBLK_LCL_UNROLL_LIMIT of 128 bytes in src/coreclr/jit/targetarm64.h

* Keep unrolling InitBlock up to INITBLK_LCL_UNROLL_LIMIT bytes when dstAddr points to the stack in src/coreclr/jit/lowerarmarch.cpp

* Keep unrolling CopyBlock up to CPBLK_LCL_UNROLL_LIMIT bytes when both srcAddr and dstAddr point to the stack in src/coreclr/jit/lowerarmarch.cpp

2 years ago'cmeq' and 'fcmeq' Vector64<T>.Zero/Vector128<T>.Zero ARM64 containment optimizations...
Will Smith [Thu, 20 Jan 2022 02:44:19 +0000 (18:44 -0800)]
'cmeq' and 'fcmeq' Vector64<T>.Zero/Vector128<T>.Zero ARM64 containment optimizations (#62933)

* Initial work

* Added a comma to display

* Cleanup

* Fixing build

* More cleanup

* Update comment

* Update comment

* Added CompareEqual Vector64/128 with Zero tests

* Do not contain op1 for now

* Wrong intrinsic id used

* Removing generated tests

* Removing generated tests

* Added CompareEqual tests

* Supporting containment for first operand

* Fix test build

* Passing correct register

* Check IsVectorZero before not allocing a register

* Update comment

* Fixing test

* Minor format change

* Fixed formatting

* Renamed test

* Adding AdvSimd_Arm64 tests:

* Adding support for rest of 'cmeq' and 'fcmeq' instructions

* Removing github csproj

* Minor test fix

* Fixed tests

* Fix print

* Minor format change

* Fixing test

* Added some emitter tests

* Feedback

* Update emitarm64.cpp

* Feedback

2 years agoCheck if the child object is in the heap range before object_gennum (#63970)
Andrew Au [Thu, 20 Jan 2022 01:59:07 +0000 (17:59 -0800)]
Check if the child object is in the heap range before object_gennum (#63970)

2 years agoCheck if the child object is in the heap range before get_region_plan_gen_num (#63828)
Andrew Au [Thu, 20 Jan 2022 01:58:39 +0000 (17:58 -0800)]
Check if the child object is in the heap range before get_region_plan_gen_num (#63828)

2 years agoFix invalid threading of nodes in rationalization (#64012)
SingleAccretion [Thu, 20 Jan 2022 01:23:50 +0000 (04:23 +0300)]
Fix invalid threading of nodes in rationalization (#64012)

The code in question assumes that the ASG will be
reversed and thus threads "simdTree" before "location"
in the linear order. That dependency, while valid,
because "gtSetEvalOrder" will always reverse ASGs
with locals on the LHS, is unnecessary and incorrect
from the IR validity point of view.

Fix this by using "InsertAfter" instead of manual
node threading.

2 years agoFix Crossgen2 bug #61104 and add regression test (#63956)
Tomáš Rylek [Thu, 20 Jan 2022 00:52:15 +0000 (01:52 +0100)]
Fix Crossgen2 bug #61104 and add regression test (#63956)

The issue tracks the runtime regression failure where
Crossgen2-compiled app is unable to locate a type with non-ASCII
characters in its name. The failure was caused by the fact that
Crossgen2 was incorrectly zero-extending the individual UTF8 characters
when calculating the hash whereas runtime is sign-extending them.

Thanks

Tomas

2 years agoUpdate StructMarshalling design now that DisableRuntimeMarshallingAttribute is approv...
Jeremy Koritzinsky [Thu, 20 Jan 2022 00:46:00 +0000 (16:46 -0800)]
Update StructMarshalling design now that DisableRuntimeMarshallingAttribute is approved (#63765)

Co-authored-by: Elinor Fung <elfung@microsoft.com>
2 years agoJIT: fix up switch map for out-of-loop predecessor (#64014)
Andy Ayers [Thu, 20 Jan 2022 00:01:16 +0000 (16:01 -0800)]
JIT: fix up switch map for out-of-loop predecessor (#64014)

If we have a loop where some of the non-loop predecessors are switchs, and
we add pre-header to the loop, we need to update the switch map for those
predecessors.

Fixes #63982.

2 years ago[arm64] JIT: Redundant zero/sign extensions after ldrX/ldrsX (#62630)
Egor Bogatov [Wed, 19 Jan 2022 23:08:10 +0000 (02:08 +0300)]
[arm64] JIT: Redundant zero/sign extensions after ldrX/ldrsX (#62630)

2 years agoRetries for flaky WMI test (#64008)
Dan Moseley [Wed, 19 Jan 2022 23:07:53 +0000 (16:07 -0700)]
Retries for flaky WMI test (#64008)

2 years agoMake ILStubGenerated event log ModuleID corresponding to that on other events (#63974)
Elinor Fung [Wed, 19 Jan 2022 22:23:48 +0000 (14:23 -0800)]
Make ILStubGenerated event log ModuleID corresponding to that on other events (#63974)

2 years agoAdd runtime-extra-platforms pipeline to have matching runtime PR and Rolling builds...
Santiago Fernandez Madero [Wed, 19 Jan 2022 22:18:21 +0000 (14:18 -0800)]
Add runtime-extra-platforms pipeline to have matching runtime PR and Rolling builds (#62564)

* Add runtime-extended-platforms pipeline to have matching runtime PR and Rolling builds

* Fix evaluate changed paths condition for the extra pipeline

* PR Feedback and fix condition

* Move MacCatalyst back to staging, disable tvOS tests

* Disable browser wasm windows legs

2 years agoBump Explicit-layout value types with no fields to at minimum 1 byte size. (#63975)
Jeremy Koritzinsky [Wed, 19 Jan 2022 22:08:07 +0000 (14:08 -0800)]
Bump Explicit-layout value types with no fields to at minimum 1 byte size. (#63975)

2 years agoDisable hot reload tests for AOT configurations (#64006)
Ankit Jain [Wed, 19 Jan 2022 21:41:04 +0000 (16:41 -0500)]
Disable hot reload tests for AOT configurations (#64006)

2 years ago[Arm64] Don't use D-copies in CopyBlock (#63588)
Egor Chesakov [Wed, 19 Jan 2022 20:59:49 +0000 (12:59 -0800)]
[Arm64] Don't use D-copies in CopyBlock (#63588)

* Increase the maximum number of internal registers allowd per node in src/coreclr/jit/lsra.h

* Based on discussion in https://github.com/dotnet/runtime/issues/63453 don't allocate a SIMD register pair if the JIT won't be able to use Q-copies in src/coreclr/jit/lsraarmarch.cpp

* Update CodeGen to reflect that Q-copies should be used only when size >= 2 * FP_REGSIZE_BYTES and using of them makes the instruction sequence shorter in src/coreclr/jit/codegenarmarch.cpp

* Update comment - we don't use D-copies after that change in src/coreclr/jit/codegenarmarch.cpp

2 years ago- mono_wasm_new_external_root for roots on stack (#63997)
Pavel Savara [Wed, 19 Jan 2022 19:59:01 +0000 (20:59 +0100)]
- mono_wasm_new_external_root for roots on stack (#63997)

- temp_malloc helper via linear buffer in js
- small refactorings
Co-authored-by: Katelyn Gadd <kg@luminance.org>
2 years agoAdd IsKnownConstant jit helper and optimize 'str == ""' with str.StartsWith('c')...
Egor Bogatov [Wed, 19 Jan 2022 19:23:45 +0000 (22:23 +0300)]
Add IsKnownConstant jit helper and optimize 'str == ""' with str.StartsWith('c') (#63734)

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
2 years agoDon't reuse registers in Debug mode (#63698)
Egor Bogatov [Wed, 19 Jan 2022 19:22:49 +0000 (22:22 +0300)]
Don't reuse registers in Debug mode (#63698)

Co-authored-by: Bruce Forstall <brucefo@microsoft.com>
2 years ago[RateLimiting] Dequeue items when queuing with NewestFirst (#63377)
Brennan [Wed, 19 Jan 2022 19:01:24 +0000 (11:01 -0800)]
[RateLimiting] Dequeue items when queuing with NewestFirst (#63377)

2 years agoFix for Werror=use-after-free in PAL (#63954)
Adeel Mujahid [Wed, 19 Jan 2022 18:42:27 +0000 (20:42 +0200)]
Fix for Werror=use-after-free in PAL (#63954)

* Fix for Werror=use-after-free in PAL

* Delete Local{Alloc,Free}

* Delete LMEM_* macros

* Delete PAL_dladdr

2 years agoUse IndexOf in StringBuilder.Replace(char, char) (#63913)
Stephen Toub [Wed, 19 Jan 2022 17:27:25 +0000 (12:27 -0500)]
Use IndexOf in StringBuilder.Replace(char, char) (#63913)

2 years agoDisable 2 SMTP tests on checked runtime (#63947)
Dan Moseley [Wed, 19 Jan 2022 16:26:30 +0000 (09:26 -0700)]
Disable 2 SMTP tests on checked runtime (#63947)

2 years ago[Group 5] Enable nullable annotations for `Microsoft.Extensions.Configuration.Json...
Maksym Koshovyi [Wed, 19 Jan 2022 15:49:39 +0000 (17:49 +0200)]
[Group 5] Enable nullable annotations for `Microsoft.Extensions.Configuration.Json` (#63694)

* Nullable enable

2 years agoUpdate runtime.json with manjaro information (#63338)
TobiasLaving [Wed, 19 Jan 2022 15:04:02 +0000 (16:04 +0100)]
Update runtime.json with manjaro information (#63338)

Without specifying runtime on manjaro we cannot run the projects.
FYI: Manjaro has a "ID_LIKE" param in os_release that has arch as input. Perhaps that would be another way forward.

2 years agoImprove auto-atomicity for conditionals (#63299)
Stephen Toub [Wed, 19 Jan 2022 14:57:04 +0000 (09:57 -0500)]
Improve auto-atomicity for conditionals (#63299)

- Allow for automatically making loops that end conditional branches be atomic
- Allow for using a following expression conditional to make a prior loop atomic
- Allow conditionals to influence the computed minimum length

2 years agoTake MacCatalyst into account in EnvironmentTests.WorkingSet_Valid test (#63995)
Maxim Lipnin [Wed, 19 Jan 2022 13:55:40 +0000 (16:55 +0300)]
Take MacCatalyst into account in EnvironmentTests.WorkingSet_Valid test (#63995)

Follow-up on https://github.com/dotnet/runtime/pull/63934

2 years agoAvoid allocating byte array when setting ALPN list on Linux (#63674)
Radek Zikmund [Wed, 19 Jan 2022 13:15:57 +0000 (14:15 +0100)]
Avoid allocating byte array when setting ALPN list on Linux (#63674)

* Avoid allocating byte array when setting ALPN list

* Code review feedback

* Apply suggestions from code review

Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Slice the stackalloc'd buffer to correct length

Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
* Code review fixes

Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
2 years agoEnable System.Text.Json tests on netfx (#63803)
Krzysztof Wicher [Wed, 19 Jan 2022 12:45:01 +0000 (13:45 +0100)]
Enable System.Text.Json tests on netfx (#63803)

* Enable System.Text.Json tests on netfx

* use NETFRAMEWORK define

* disable another two test cases after rebase

* disable last test case which repros only on CI for me

* add p2p only on netfx

2 years agoReplace "needs more info" label with "needs-author-action" (#63899)
Eirik Tsarpalis [Wed, 19 Jan 2022 11:59:34 +0000 (11:59 +0000)]
Replace "needs more info" label with "needs-author-action" (#63899)

2 years agoFix profiling objectsallocatedbyclass (#63814)
Olivier Giniaux [Wed, 19 Jan 2022 11:56:54 +0000 (12:56 +0100)]
Fix profiling objectsallocatedbyclass (#63814)

* Add test for ObjectsAllocatedByClass profiler callbacks

* Fix ObjectsAllocatedByClass profiler callbacks based on wrong flag

* Fix wrong args in test log

Co-authored-by: Olivier Giniaux <oginiaux@smartadserver.com>
2 years agoImprove reductions for Regex empty / nothing nodes (#63695)
Stephen Toub [Wed, 19 Jan 2022 11:53:36 +0000 (06:53 -0500)]
Improve reductions for Regex empty / nothing nodes (#63695)

2 years agoExtend regex switch alternation optimization to IgnoreCase (#63756)
Stephen Toub [Wed, 19 Jan 2022 11:53:24 +0000 (06:53 -0500)]
Extend regex switch alternation optimization to IgnoreCase (#63756)

IgnoreCase now results in producing sets (e.g. an 'a' becomes '[Aa]') but the source generator's optimization that produces a switch statements for alternations with non-overlapping branches doesn't yet understand such sets.  This augments that logic to fix that.

2 years agoImprove auto-atomicity for Regex loops (#63986)
Stephen Toub [Wed, 19 Jan 2022 11:52:15 +0000 (06:52 -0500)]
Improve auto-atomicity for Regex loops (#63986)

- As part of recognizing loops that could be made atomic, we currently only look at the node guaranteed to come immediately after it, e.g. in a+b+c+, when analyzing a+ we only look at the b+.  That's fine in many cases, but if our expression was instead e.g. a*b*c*, we couldn't make a* atomic because we wouldn't be guaranteed it'd be followed by a b, and we wouldn't look at the subsequent nodes to determine what else might follow.  When that situation occurs, we can now walk the tree to find the next node, and repeatedly do so as much as is needed in order to find the next node, enabling us to make all of those loops atomic.
- We currently perform the auto-atomicity reduction for single-char loops as part of reducing concatenations.  But this means we're performing that transformation at a time when the tree isn't fully formed, which means we can't necessarily reach out of a concatenation to what comes after it and use that to influence the atomicity.  It also means we might repeat the analysis unnecessarily multiple times, because it's done as part of parenting a node.  We can instead do that optimization as part of the final optimization phase, after the tree is already created.
- When we find a lazy loop at the end of an expression, we can treat it as atomic, which means we can lower its max bound to its min bound.
- When we encounter a loop (lazy or greedy) at the end of an expression, if it has a max bound of 1 (i.e. it's optional), we can proceed to eliminate ending backtracking with its child regardless of whether the child could be made atomic with the start of the loop, since it won't ever repeat more than once.

2 years ago[main] Update dependencies from dotnet/runtime dotnet/arcade dotnet/xharness dotnet...
dotnet-maestro[bot] [Wed, 19 Jan 2022 10:20:02 +0000 (11:20 +0100)]
[main] Update dependencies from dotnet/runtime dotnet/arcade dotnet/xharness dotnet/icu dotnet/roslyn-analyzers dotnet/llvm-project (#63737)

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2 years agoJIT: Fix repeatable failure for max CALLSITE_DEPTH (#63966)
Egor Bogatov [Wed, 19 Jan 2022 10:16:28 +0000 (13:16 +0300)]
JIT: Fix repeatable failure for max CALLSITE_DEPTH (#63966)

2 years agoAddress follow-up feedback to CachedCompletedInt32Task (#63968)
Stephen Toub [Wed, 19 Jan 2022 09:10:27 +0000 (04:10 -0500)]
Address follow-up feedback to CachedCompletedInt32Task (#63968)

2 years agoReading beyond EOF should return 0 for FILE_FLAG_NO_BUFFERING (#63625)
Adam Sitnik [Wed, 19 Jan 2022 07:58:20 +0000 (08:58 +0100)]
Reading beyond EOF should return 0 for FILE_FLAG_NO_BUFFERING (#63625)

* move Length to SafeFileHandle, so it's cached value can be reused in more places

2 years ago[wasm][debugger] Added support for StepThroughAttribute (#63679)
Ilona Tomkowicz [Wed, 19 Jan 2022 07:55:35 +0000 (08:55 +0100)]
[wasm][debugger] Added support for StepThroughAttribute (#63679)

* Hidden methods and step through methods behave the same way.

* Perpared flow for setting JustMyCode in the future.

* Tests for JustMyCode setting before debug launch.

* Transformed into dynamic JustMyCode change flow.

* JustMyCode disabled, first 3 cases solved.

* Finished behavior for JMC disabled (with 1 difference).

* JMC enabled: stepIn np bp + stepIn bp + resume bp.

* Functional version (with minor deviations from expected behavior).

* Refactoring.

2 years agoAdd tests for creating memory mapped files from non-seekable files (#63927)
Adam Sitnik [Wed, 19 Jan 2022 07:42:07 +0000 (08:42 +0100)]
Add tests for creating memory mapped files from non-seekable files (#63927)

2 years agoAdd support for libraries testing with NativeAOT (#63781)
Michal Strehovský [Wed, 19 Jan 2022 06:01:43 +0000 (15:01 +0900)]
Add support for libraries testing with NativeAOT (#63781)

This adds support for running libraries tests with NativeAOT. It reuses the single file xunit runner since we cannot `LoadFrom` the tests on NativeAOT. The strategy is the same as for single file testing: do a publish. To do the NativeAOT publish, we include the Microsoft.DotNet.ILCompiler.targets.

2 years agoFix up warnings from delegate thunks (#63980)
Michal Strehovský [Wed, 19 Jan 2022 06:00:52 +0000 (15:00 +0900)]
Fix up warnings from delegate thunks (#63980)

If we hit a p/invoke with a `System.Delegate` in a delegate marshalling stub, blame the delegate type, not the compiler-generated method. Apparently we marshal System.Delegate in MsQuick interop.

2 years agoAdd managed implementation of Math/MathF.Abs (#63881)
Adeel Mujahid [Wed, 19 Jan 2022 05:25:12 +0000 (07:25 +0200)]
Add managed implementation of Math/MathF.Abs (#63881)

* Add managed implementation of  Math/MathF.Abs

* Cleanup trailing whitespaces in changeset

* Delete unused _copysignf macro

2 years agoFix case where we incorrectly select a prefix as a FindFirstChar optimization when...
Jose Perez Rodriguez [Wed, 19 Jan 2022 03:47:09 +0000 (19:47 -0800)]
Fix case where we incorrectly select a prefix as a FindFirstChar optimization when the pattern includdes an alternation that could lead to different prefixes. (#63976)

2 years agoRevert "Improve auto-atomicity for Regex loops (#63518)" (#63984)
Stephen Toub [Wed, 19 Jan 2022 03:15:32 +0000 (22:15 -0500)]
Revert "Improve auto-atomicity for Regex loops (#63518)" (#63984)

This reverts commit 557901e779a009cf4a51327963727a4d1ded0094.

2 years agoFix System.Reflection.Metadata version in ILVerification nuget package metadata ...
Jan Kotas [Wed, 19 Jan 2022 02:59:04 +0000 (18:59 -0800)]
Fix System.Reflection.Metadata version in ILVerification nuget package metadata (#63965)

Fixes #63944

2 years agoFix Failing Globalization Test on OSX (#63971)
Tarek Mahmoud Sayed [Wed, 19 Jan 2022 02:39:37 +0000 (18:39 -0800)]
Fix Failing Globalization Test on OSX (#63971)

2 years agoImprove ILLink.targets integration (#63914)
Michal Strehovský [Wed, 19 Jan 2022 01:58:17 +0000 (10:58 +0900)]
Improve ILLink.targets integration (#63914)

Runtime side of https://github.com/dotnet/sdk/pull/23470 (depends on that getting merged). Skip touching the IL Linker semaphore that tricks the target into not running.

2 years agoImprove auto-atomicity for Regex loops (#63518)
Stephen Toub [Wed, 19 Jan 2022 01:40:35 +0000 (20:40 -0500)]
Improve auto-atomicity for Regex loops (#63518)

* Improve auto-atomicity for Regex loops

- As part of recognizing loops that could be made atomic, we currently only look at the node guaranteed to come immediately after it, e.g. in a+b+c+, when analyzing a+ we only look at the b+.  That's fine in many cases, but if our expression was instead e.g. a*b*c*, we couldn't make a* atomic because we wouldn't be guaranteed it'd be followed by a b, and we wouldn't look at the subsequent nodes to determine what else might follow.  When that situation occurs, we can now walk the tree to find the next node, and repeatedly do so as much as is needed in order to find the next node, enabling us to make all of those loops atomic.
- We currently perform the auto-atomicity reduction for single-char loops as part of reducing concatenations.  But this means we're performing that transformation at a time when the tree isn't fully formed, which means we can't necessarily reach out of a concatenation to what comes after it and use that to influence the atomicity.  It also means we might repeat the analysis unnecessarily multiple times, because it's done as part of parenting a node.  We can instead do that optimization as part of the final optimization phase, after the tree is already created.
- When we find a lazy loop at the end of an expression, we can treat it as atomic, which means we can lower its max bound to its min bound.
- When we encounter a loop (lazy or greedy) at the end of an expression, if it has a max bound of 1 (i.e. it's optional), we can proceed to eliminate ending backtracking with its child regardless of whether the child could be made atomic with the start of the loop, since it won't ever repeat more than once.

* Extend auto-atomicity to lazy loops

2 years agoDo not register ACTIVATION_SIGNAL for secondary PAL copies (#63961)
Jan Kotas [Wed, 19 Jan 2022 01:36:09 +0000 (17:36 -0800)]
Do not register ACTIVATION_SIGNAL for secondary PAL copies (#63961)

Related to #63959

2 years agoJIT: yet another OSR stress mode (#62980)
Andy Ayers [Wed, 19 Jan 2022 00:57:51 +0000 (16:57 -0800)]
JIT: yet another OSR stress mode (#62980)

Existing OSR stress use existing patchpoint placement logic and alter the
policy settings so that OSR methods are created more eagerly.

This new version of OSR stress alters the patchpoint placement logic, to
add patchpoints to more places. In conjunction with the eager policy stress
above this leads to creation and execution of large numbers of OSR methods.

Any IL offset in the method with an empty stack (and not in a handler) is fair
game for a patchpoint, so this new method randomly adds patchpoints to the
starts of blocks when stack empty (future work may extend this to mid-block
stack empty points).

The new mode is enabled by setting `COMPlus_JitRandomOnStackReplacement` to a
non-zero value; this value represents the likelihood of adding a patchpoint
at a stack-empty block start, and also factors into the random seed. (Recall
this is parsed in hex, so 0x64 == 100 or larger will put a patchpoint at the
start of every stack empty block).

Various values are interesting because once a method reaches a patchpoint
and triggers OSR, the remainder of that method's execution is in the OSR method,
so later patchpoints in the original method may never be reached. So some sort
of random/selective patchpoint approach (in conjunction with varying policy
settings) is needed to ensure that we create an execute as many different OSR
variants as possible.

This PR also includes a couple of fixes exposed by local testing of this new
stress mode:
* The OSR prolog may end up empty, which gcencoder doesn't like. Detect this
and add a `nop` for the prolog.
* If we're importing the `fgEntryBB` during OSR, we don't need to schedule it
for re-importation. This happens if we put a patchpoint at IL offset zero.
* Update the selective dumping policy `COMPlus_JitDumpAtOSROoffset` to only
dump OSR method compilations.

A new test leg is added to `jit-experimental` to run with this mode enabled
with a probability of 21% (0x15) and quick OSR triggers.

Also included:
* fix probability calc
* remove obsolete assert
* osr exposed does not apply to simd
* only pad zero-sized OSR prolog if we're reporting generic context
* Add ability to have patchpoint at specified offset.
* Fix interaction of stress patchpoints and profile instrumentation.
We need to force block-based instrumentation if we might have stress
patchpoints.

2 years agoReduce allocations in code generated by Logging generators (#61162) (#62011)
Honza Rameš [Wed, 19 Jan 2022 00:12:18 +0000 (01:12 +0100)]
Reduce allocations in code generated by Logging generators (#61162) (#62011)

2 years ago[mono] Hot Reload: initial push to support adding lambdas (#63513)
Aleksey Kliger (λgeek) [Tue, 18 Jan 2022 23:40:42 +0000 (18:40 -0500)]
[mono] Hot Reload: initial push to support adding lambdas (#63513)

Adds support for:
* Adding static lambdas to existing methods, whether or not they had lambdas before.
* Adding lambdas that capture `this` to existing methods that already captured `this` before
* Adding new static or instance methods to existing types
* Adding static fields to existing types
* Adding new types (note that adding instance fields currently will fail.  It'll go in in a future PR that will address https://github.com/dotnet/runtime/issues/63643).

Note that reflection on newly added members isn't tested yet and likely doesn't work.

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

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

* Add AddStaticField test; cleanup AddLambdaCapturingThis

* Add AddNestedClass testcase

* hot_reload: add a comment about remaining work

* move per-class metadata update info to MonoClassMetadataUpdateInfo

   Use a property on the class instead of a hash table in the baseline image to keep track of added fields and methods

* Cleanup pass1 to check add/update against prior gen

   Instead of the baseline image

* adding a class

   Working on making mono_metadata_nested_in_typedef do the right thing for nested classes

   Contributes to making mono_class_create_from_typedef do the right thing for nested classes.

* fix: correct mutant table population when the baseline table is empty

   In that case the table row_size and size_bitmap of the baseline are both 0, so offset calculations don't work.

   In that case when we know we need to add rows to the mutant table, use the uncompressed layout (32-bit columns, always) same as the EnC delta.

* Calling new methods on a nested class works

* adding fields

   Doesn't work yet.  Dies in mono_class_get_field, called from mono_field_from_token_checked.

   The problem we're going to have to deal with is that unlike MonoMethod which is allocated upon lookup, the MonoClassFields of a class are allocated contiguously in class initialization.  And there are not really enough fields in MonoClassField to indicate "this is not an ordinary field, don't do pointer arithmetic with it".  One idea is to steal a bit from MonoClassField:parent and always check it as a trigger to go on a slower path.

* adding static fields

   Rework the delta info to store info about "members" (rather than methods and fields separately).

   Add a MonoClassMetadataUpdateField subclass of MonoClassField that has extra info.

   Add new component methods to go from a MonoClassField to an index, and from a field token to a MonoClassField.

   Set MonoClassField:offset to -1 to generally go down the "special static field" codepath since we will need to do some one-off work to make a storage area for added static fields.

   Instance fields are not supported yet and error out during the update pass for now.

* fix custom attribute lookups on new classes/methods/fields

* Add a sketch of HotReloadInstanceFieldTable

   This is a class that manages the lifetime for added instance fields for reference types that had new fields added to them by EnC   It's basically ConditionalWeakTable<object, Dictionary<uint, Store>> where the outer key is the object instance, the inner key is the fielddef token, and the value is a Store.  The store has a single object? field which the location where the field's value will go.  For reference types this is the reference directly, and for valuetypes and primitives, this is the boxed object (so to get the actual storage address you need to add sizeof(MonoObject)).

* mono_metadata_update_get_static_field_addr

   two reminders:

   1. The static field area needs to be GC-visible
   2. We should really handle added fields on un-inited classes by allocating the instances in the normal way - in the layout algorithm.

* Free MonoClassMetadataUpdateInfo when BaselineInfo is destroyed

* placeholder struct for runtime class data; instance offset placeholder

* static field storage

   Need to store the fields in a GC root, and in pinned allocations.

* Implement hot_reload_get_static_field_addr()

* Add mono_metadata_update_find_method_by_name

   Now we can find .cctor

   This is enough that a basic sample with an added static lambda works

* Fix infinite loop

* fix build

* fix dynamic components builds

* fix windows build

* Fix inadvertent fallthru in previous fix

* Report new capabilities

   NewTypeDefinition is not completely functional because adding instance fields is not supported yet.   But adding classes with only static methods works.

* tests: describe what existing tests do, add placeholder static lambda test

* tests: Add AddStaticLambda test case

   Adding a brand new static lambda to an existing method body is supported

* Destroy the runtime part of MonoClassMetadataUpdateInfo, too

* rename Mono.HotReload file

   it has more classes than just the instance table

* tests: add ActiveIssue for supporting adding instance fields

* ifdef out Mono.HotReload.InstanceFieldTable

   it's not ready yet

* Remove get_added_members from hot reload component interface

   Doesn't seem necessary to expose this yet.  It's only used in hot_reload.c right now

* Change the AddStaticLambda sample to use Func<string,string>

   To check that lambdas with parameters work

* Use a mempool allocated GSlist for the added members

   This avoids invalidating iterators in case we add members on one thread while another thread is iterating.

   If it turns out we need random access, we can switch to a GArray with locking.  But so far we only ever iterate.

* Use mono_get_corlib instead of passing MonoDefaults to hot_reload

* use normal GENERATE_TRY_GET_CLASS_WITH_CACHE

* [metadata] make m_field_set_parent and m_field_set_meta_flags inline

   m_ prefix functions are supposed to be inline

2 years agoAdd `UnicodeRange.ArabicExtendedB` (#63901)
Bradley Grainger [Tue, 18 Jan 2022 23:32:16 +0000 (15:32 -0800)]
Add `UnicodeRange.ArabicExtendedB` (#63901)

2 years agoUpdate links to the project for DllImportGenerator (#63940)
Andrii Kurdiumov [Tue, 18 Jan 2022 23:23:32 +0000 (05:23 +0600)]
Update links to the project for DllImportGenerator (#63940)

As coincidence, I think `RestoreAdditionalProjectSources` not needed anymore.

2 years ago[iOS/tvOS] Remove P/Invokes to libproc from System.Private.CoreLib (#63934)
Alexander Köplinger [Tue, 18 Jan 2022 22:13:58 +0000 (23:13 +0100)]
[iOS/tvOS] Remove P/Invokes to libproc from System.Private.CoreLib (#63934)

They aren't allowed by Apple when submitting to the App Store.

Finishes https://github.com/dotnet/runtime/issues/61265