platform/upstream/coreclr.git
5 years agoImplement the Count property, the IEquatable and IFormattable interfaces, and the...
Tanner Gooding [Thu, 29 Nov 2018 20:15:43 +0000 (12:15 -0800)]
Implement the Count property, the IEquatable and IFormattable interfaces, and the standard object overrides on Vector64/128/256<T> (#21259)

* Exposing the Count property on Vector64/128/256<T>

* Implementing IEquatable, IFormattable, and the object overrides on Vector64/128/256<T>

* Use StringBuilderCache, HashCode, and the provided format specifier

* Use StringBuilderCache.GetStringAndRelease and get the correct element when formatting Vector64/128/256<T>

5 years agoAdd more advanced SafeArray tests (#21063)
Jeremy Koritzinsky [Thu, 29 Nov 2018 19:57:36 +0000 (11:57 -0800)]
Add more advanced SafeArray tests (#21063)

* Port simple SafeArray tests over from .NET Framework's test suite.

* Clean up native calling conventions.

* Add basic field array -> field SAFEARRAY* tests.

* Fix some hiding stdcall calling convention decorators.

* PR Feedback.

* Rewrite native part of SafeArray tests

* Wrote the managed side of the tests. Non-passing ones are currently commented out.

* Fix up tests and enable marshalling a string[] as a SAFEARRAY of LPSTR or LPWSTR.

* Add blittable records test with a return parameter.

* Add returning non-blittable record safearray test.

* Fix which typedef we're using

* Clean up

* Fix/cleanup RecordNative

* Replace "" with <> for platformdefines.h include.

* Use macro for calling convention.

* PR Feedback.

* Remove residual "Helpers.h" include.

* Fix remaining incorrect calling conventions.

* One more calling convention fix.

5 years agoFix build parallelism on Windows with NUMA (#21278)
Jan Vorlicek [Thu, 29 Nov 2018 18:06:34 +0000 (19:06 +0100)]
Fix build parallelism on Windows with NUMA (#21278)

When multiple NUMA nodes are enabled on the machine where coreclr is
built, we incorrectly detect the number of cores that we use for build
parallelism of the native part of the build (NumberOfCores) as only
a number in the last NUMA node.
The reason is that the `wmic cpu get NumberOfCores /value` returns
multiple lines, one per each NUMA node.
This change fixes it by summing values from all the lines.

5 years agoDon't treat the Vector64/128/256<T> helper methods as intrinsic if featureSIMD is...
Tanner Gooding [Thu, 29 Nov 2018 17:46:34 +0000 (09:46 -0800)]
Don't treat the Vector64/128/256<T> helper methods as intrinsic if featureSIMD is disabled (#21274)

5 years agoMerge pull request #21267 from BruceForstall/FixExclusion
Bruce Forstall [Thu, 29 Nov 2018 17:46:18 +0000 (09:46 -0800)]
Merge pull request #21267 from BruceForstall/FixExclusion

Fix ObjectStackAllocationTests on Linux under minopts

5 years agopublish symbols on FreeBSD (#21179)
Tomas Weinfurt [Thu, 29 Nov 2018 17:31:46 +0000 (09:31 -0800)]
publish symbols on FreeBSD (#21179)

* enable build-id on FreeBSD

* start publishing symbols for freebsd

* enable FEATURE_PERFMAP on FreeBSD

5 years agoUpdating genSIMDZero to only use `xorps` (#21249)
Tanner Gooding [Thu, 29 Nov 2018 15:59:27 +0000 (07:59 -0800)]
Updating genSIMDZero to only use `xorps` (#21249)

5 years agoTrack single def locals in importer (#21251)
Andy Ayers [Thu, 29 Nov 2018 08:32:55 +0000 (00:32 -0800)]
Track single def locals in importer (#21251)

* Defer setting lvSingleDef until lvaMarkLocalVars

Since this information isn't used early on in the jit, defer setting this bit
until later.

* Track single-def locals in the importer

and use this information to enable type updates during late devirtualization.
This gets some cases where the exact type materializes late (perhaps via a
chain of copies).

5 years agoFix #21209 (#21237)
Swaroop Sridhar [Thu, 29 Nov 2018 07:09:30 +0000 (23:09 -0800)]
Fix #21209 (#21237)

This commit has two changes to Native Load Library Tests fix the failures in:
https://github.com/dotnet/coreclr/issues/21209

1) Windows: The test tried to load a DLL from Win32 directory which doesn't exist
   in Windows server 2016. So changed to use a file that exists.
2) Linux: Disable the test when run against packages -- because in this configuration
   the tests are built on Windows, and the native DLL is built separately and copied
   over to the CORE_ROOT directory instead of the test directory.
   [Several other tests are disabled with the comment "Issue building native DLL" on Linux]

5 years agoAdd IsCollectible property to Memberinfo and MethodInfo (#21155)
John Salem [Thu, 29 Nov 2018 06:34:48 +0000 (22:34 -0800)]
Add IsCollectible property to Memberinfo and MethodInfo (#21155)

5 years agoImprove Enum.ToString perf for [Flags] enums (#21254)
Stephen Toub [Thu, 29 Nov 2018 04:04:08 +0000 (23:04 -0500)]
Improve Enum.ToString perf for [Flags] enums (#21254)

Two main changes:
- Rather than using a StringBuilder to insert the strings for all of the consistuent values, we track the constituent values in a span, summing the expected length, and then new up a string and copy the results directly into it.
- When there's a single value that matches the supplied value, we just return the cached string rather than allocating a new one.

5 years agoRemove obsolete assert (#21260)
Andrew Au [Thu, 29 Nov 2018 02:23:00 +0000 (18:23 -0800)]
Remove obsolete assert (#21260)

5 years agoDelete code related to LoaderOptimization and SharedDomain (#21031)
Jan Kotas [Thu, 29 Nov 2018 02:18:04 +0000 (18:18 -0800)]
Delete code related to LoaderOptimization and SharedDomain (#21031)

5 years agoFix ObjectStackAllocationTests on Linux under minopts
Bruce Forstall [Thu, 29 Nov 2018 01:16:23 +0000 (17:16 -0800)]
Fix ObjectStackAllocationTests on Linux under minopts

Fix the capitalization of COMPlus_JITMinOpts variable, which
is case-sensitive on Linux.

Fixes #21266

5 years agoQueue ValueTaskAwaiter IAsyncStateMachineBox directly to ThreadPool (#21159)
Ben Adams [Wed, 28 Nov 2018 21:45:16 +0000 (21:45 +0000)]
Queue ValueTaskAwaiter IAsyncStateMachineBox directly to ThreadPool (#21159)

* Queue ValueTaskAwaiter IAsyncStateMachineBox directly to ThreadPool

* Invert the dependency

* Move to UnsafeQueueUserWorkItem

* MRVTSC queue null or Deafult EC to UnsafeQUWI

* Revert MRVTSC change

* Add comment and validation

* Use s_invokeAsyncStateMachineBox for AsTask

* nits

* nits 2

* Rever ValueTask

* nits

5 years agoUpdate Helix queues used for testing
Russ Keldorph [Wed, 28 Nov 2018 18:43:50 +0000 (10:43 -0800)]
Update Helix queues used for testing

5 years agoMerge pull request #21217 from AndyAyersMS/Fix21051
Andy Ayers [Wed, 28 Nov 2018 20:51:46 +0000 (12:51 -0800)]
Merge pull request #21217 from AndyAyersMS/Fix21051

JIT: retype some return expressions

5 years agoMerge pull request #21226 from AndyAyersMS/HandleMoreGeneralIndirInJmpAddr
Andy Ayers [Wed, 28 Nov 2018 20:51:04 +0000 (12:51 -0800)]
Merge pull request #21226 from AndyAyersMS/HandleMoreGeneralIndirInJmpAddr

JIT: handle general indir case for GT_JMP address

5 years agoSwitch to preemptive mode before calling COM (#21238)
Jan Kotas [Wed, 28 Nov 2018 19:19:48 +0000 (11:19 -0800)]
Switch to preemptive mode before calling COM (#21238)

* Switch to preemptive mode before calling COM

COM can call back the runtime via RCW that leads to contract violations

Fixes #20373

* Fix one places

5 years ago Delete test dev10_630880 (#21239)
Jan Kotas [Wed, 28 Nov 2018 19:18:54 +0000 (11:18 -0800)]
 Delete test dev10_630880 (#21239)

* Revert "Disable test Dev10_630880"

This reverts commit 4fb76de35184fb80054f29779f51af82a4aa7ad8.

* Delete test dev10_630880

This test has been exercising internal CoreLib details that have been deleted.

5 years agoMerge pull request #21204 from briansull/issue_20185
Brian Sullivan [Wed, 28 Nov 2018 18:17:45 +0000 (10:17 -0800)]
Merge pull request #21204 from briansull/issue_20185

Change VNUnpackExc to always write an exception set

5 years agoexclude tests\src\Interop\COM\NativeClients\Primitives from GCStress runs. (#21222)
Sergey Andreenko [Wed, 28 Nov 2018 17:36:09 +0000 (09:36 -0800)]
exclude tests\src\Interop\COM\NativeClients\Primitives from GCStress runs. (#21222)

* exclude tests\src\Interop\COM\NativeClients\Primitives.csproj from GCStress runs.

* fix alignment

5 years agoFixing up Utf8Parser.TryParseNumber to not fail for overly large exponents (#21233)
Tanner Gooding [Wed, 28 Nov 2018 11:54:12 +0000 (03:54 -0800)]
Fixing up Utf8Parser.TryParseNumber to not fail for overly large exponents (#21233)

5 years agoImplement the S.R.I.VectorXXX `get_Zero` and `As` helper methods as JIT intrinsics...
Tanner Gooding [Wed, 28 Nov 2018 11:52:43 +0000 (03:52 -0800)]
Implement the S.R.I.VectorXXX `get_Zero` and `As` helper methods as JIT intrinsics (#21198)

* Remove ARM64_SIMD_StaticCast intrinsic and the x86 TwoTypeGeneric flag

* Implementing the `S.R.Intrinsic.VectorXXX.As` methods as runtime intrinsics

* Implementing the get_Zero method on the S.R.Intrinsic.VectorXXX types as runtime intrinsics

5 years agoImprove performance of cgroup access (#21229)
Jan Vorlicek [Wed, 28 Nov 2018 08:55:35 +0000 (09:55 +0100)]
Improve performance of cgroup access (#21229)

Currently, we create a CGroup instance on each request for getting
used or total physical memory. This has an extra cost of finding
filesystem paths of the current cgroup files. I have found that
if we do the initialization just once, the performance of getting
the used or total memory in a tight loop improves 22 times.

Accidentally, I was also looking into a perf regression in the
ByteMark.BenchBitOps test that was observed in the past, seemingly
related to the recent change to the way we get the used memory.
And I've found that the benchmark results improve two fold with
the change in this commit.

This change was made both in PAL and in the standalone GC.

5 years agoFix ILStubCache allocation for collectible assemblies (#21188)
Jan Vorlicek [Wed, 28 Nov 2018 05:36:59 +0000 (06:36 +0100)]
Fix ILStubCache allocation for collectible assemblies (#21188)

The ILStubCache was being allocated per domain unless the domain was a
compilation AppDomain. This is wrong for collectible assemblies, since
after an assembly is collected, the cache keeps stale entries referring
to already deleted MethodTables.
The fix is to make ILStubChange per LoaderAllocator instead (and keep
the per module instances for compilation AppDomain).

5 years agoMerge pull request #21234 from BruceForstall/Disable630880
Bruce Forstall [Wed, 28 Nov 2018 03:39:04 +0000 (19:39 -0800)]
Merge pull request #21234 from BruceForstall/Disable630880

Disable test Dev10_630880

5 years agoMove all the math functions undef #ifndef PAL_STDCPP_COMPAT (#21170)
Ilia [Wed, 28 Nov 2018 01:34:29 +0000 (04:34 +0300)]
Move all the math functions undef #ifndef PAL_STDCPP_COMPAT (#21170)

Bug: 20786

5 years agoDisable test Dev10_630880
Bruce Forstall [Wed, 28 Nov 2018 01:04:36 +0000 (17:04 -0800)]
Disable test Dev10_630880

It was made obsolete by https://github.com/dotnet/coreclr/pull/21157

5 years agoCode review feedback
Brian Sullivan [Wed, 28 Nov 2018 00:40:58 +0000 (16:40 -0800)]
Code review feedback

5 years agoDisable failing Linux/arm32 corefx tests (#21225)
Bruce Forstall [Wed, 28 Nov 2018 00:33:25 +0000 (16:33 -0800)]
Disable failing Linux/arm32 corefx tests (#21225)

* Disable failing Linux/arm32 corefx tests

5 years agoUpdate changing-corelib.md (#21220)
Dan Moseley [Tue, 27 Nov 2018 21:24:57 +0000 (13:24 -0800)]
Update changing-corelib.md (#21220)

* Update changing-corelib.md

@jkotas

* Update changing-corelib.md

5 years agoDiff-able disassembly fixes (#20863)
Pent Ploompuu [Tue, 27 Nov 2018 21:24:30 +0000 (23:24 +0200)]
Diff-able disassembly fixes (#20863)

5 years agoJIT: handle general indir case for GT_JMP address
Andy Ayers [Tue, 27 Nov 2018 21:11:02 +0000 (13:11 -0800)]
JIT: handle general indir case for GT_JMP address

Some upcoming changes to reduce tiering overhead require that directly
invoked virtual methods be called indirectly via their slot, so that the
method body can be updated and callers patched up by patching the method
table slot.

Existing code for x64 implicitly assumes that a GT_JMP indirect target address
is near enough to the call site that a 32 bit RIP-relative displacement will
work. We can ensure this is true by always generating a reloc (and hence
potentially a jump stub) -- unless the target happens to fit in 32 bits and
so can be addressed absolutely.

5 years agoremove workaround comments
Andy Ayers [Tue, 27 Nov 2018 19:38:56 +0000 (11:38 -0800)]
remove workaround comments

5 years agoMerge pull request #21151 from CarolEidt/Fix21080
Carol Eidt [Tue, 27 Nov 2018 19:12:52 +0000 (11:12 -0800)]
Merge pull request #21151 from CarolEidt/Fix21080

Use LclFld for full-width cpblk of different types

5 years agoJIT: retype some return expressions
Andy Ayers [Sat, 17 Nov 2018 18:26:25 +0000 (10:26 -0800)]
JIT: retype some return expressions

The jit is fairly tolerant of byref/native int mismatches for inline arguments
and return values. And some of the new unsafe helpers do this kind of
reinterpretation across call boundaries as well. This sometimes leads the jit
to lose track of byrefs.

A general fix for this is likely somewhat involved. For now we simply detect if
we're about to lose track of a byref when substituting a particular kind of
return expression, and retype the expression to a byref.

Fixes #21051.

5 years agoUse local array in ConcurrentQueue<T> for small perf improvement (#21192)
Stephen Toub [Tue, 27 Nov 2018 14:27:06 +0000 (09:27 -0500)]
Use local array in ConcurrentQueue<T> for small perf improvement (#21192)

Enqueue/TryDequeue/TryPeek are all repeatedly accessing the same array from a readonly field.  Changing them to instead access that same array but from a cached local results in an ~10% throughput boost on a microbenchmark that does uncontended reads/writes of objects from/to the queue. (I also tried using a ref local to point directly to the target slot in the array, but that actually resulted in a measurable regression.)

5 years agoImprove perf for Index based span indexers (#21196)
Andy Ayers [Tue, 27 Nov 2018 08:36:35 +0000 (00:36 -0800)]
Improve perf for Index based span indexers (#21196)

First, evaluate the actual index before invoking the underlying int indexer,
so that the jit doesn't think the span is address taken.

Second, improve the jit's ability to remove some redundant comparisons like
those that arise in computing the actual index.

5 years agoFix a use after free for Managed Data BP (#21205)
Chuck Ries [Tue, 27 Nov 2018 06:06:34 +0000 (22:06 -0800)]
Fix a use after free for Managed Data BP (#21205)

ShimProxyCallback::DataBreakpoint::DataBreakpointEvent was holding onto a bare
BYTE* for the CONTEXT rather than copying the buffer and taking ownership. Due to
lifetime, this resulted in a use after free. Apparently in retail code we got lucky
and this worked enough of the time that we never noticed it.

5 years agoFix Rune.ToUpper / ToLower under GlobalizationMode.Invariant (#21203)
Levi Broderick [Tue, 27 Nov 2018 05:08:10 +0000 (21:08 -0800)]
Fix Rune.ToUpper / ToLower under GlobalizationMode.Invariant (#21203)

5 years agoDisable noncollectible alc finalization (#21189)
Jan Vorlicek [Tue, 27 Nov 2018 03:15:45 +0000 (04:15 +0100)]
Disable noncollectible alc finalization (#21189)

* Disable noncollectible AssemblyLoadContext finalization

The constructor of AssemblyLoadContext was missing a call to
GC.SuppressFinalize for non-collectible AssemblyLoadContext. That means
that the finalizer can be executed and unloading being initialized even
for non-collectible AssemblyLoadContext.
This change fixes that.

* SuppressFinalize non-collectible AssemblyLoadContext

The finalizer for the non-collectible AssemblyLoadContext is never
called and so it should not be in the finalization queue.

* Handle finalizer call without constructor executed

Check if the constructor was executed before we run the finalizer code.

5 years agoDisable domain neutral loading (#21156)
Jan Kotas [Tue, 27 Nov 2018 01:55:10 +0000 (17:55 -0800)]
Disable domain neutral loading (#21156)

5 years agoDeleting a format.patch file that got checked in (#21202)
Tanner Gooding [Tue, 27 Nov 2018 01:54:36 +0000 (17:54 -0800)]
Deleting a format.patch file that got checked in (#21202)

5 years agoUpdate documentation for changing CoreLib (#21201)
Jan Kotas [Tue, 27 Nov 2018 01:06:35 +0000 (17:06 -0800)]
Update documentation for changing CoreLib (#21201)

5 years agoUse LclFld for full-width cpblk of different types
Carol Eidt [Wed, 21 Nov 2018 22:12:03 +0000 (14:12 -0800)]
Use LclFld for full-width cpblk of different types

This issue arose because the source tree was a struct with a single double field, and the destination was a struct with a single long field. Copy prop replaced the lclVar in the source, which was under a `IND(ADDR)` with a lclVar that was not address taken, although it was marked `GTF_DONT_CSE`. Replacing the src tree with a `GT_LCL_FLD` addresses this issue.

Also, ensure that the target is marked `DoNotEnregister` if it isn't referenced as the same size/type.

Fix #21080
Fix #21064

5 years agoMerge pull request #21184 from mikedn/load-norm
Brian Sullivan [Tue, 27 Nov 2018 00:31:37 +0000 (16:31 -0800)]
Merge pull request #21184 from mikedn/load-norm

Fix normalize on load handling in assertion propagation

5 years agoFix issue 20185
Brian Sullivan [Tue, 27 Nov 2018 00:19:44 +0000 (16:19 -0800)]
Fix issue 20185
Change VNUnpackExc to always write an exception set to pvnx

5 years agoFix Azure DevOps endpoint (#21038)
Morgan Brown [Mon, 26 Nov 2018 22:46:36 +0000 (14:46 -0800)]
Fix Azure DevOps endpoint (#21038)

* Delete incorrect resources section

Remove reference to arcade repo

5 years agoUpdating runtest.py to support printing coredump information (#21149)
Tanner Gooding [Mon, 26 Nov 2018 21:27:46 +0000 (13:27 -0800)]
Updating runtest.py to support printing coredump information (#21149)

* Updating runtest.py to support printing coredump information

* Adding some comments to the coredump collection methods in runtest.py

5 years agoFixing a few small issues with the SIMD vs SIMD HWIntrinsics (#21097)
Tanner Gooding [Mon, 26 Nov 2018 19:44:51 +0000 (11:44 -0800)]
Fixing a few small issues with the SIMD vs SIMD HWIntrinsics (#21097)

* Fixing the simdHandleCache to add entries for Vector64FloatHandle and Vector128FloatHandle

* Fixing two places that were calling just OperIsSIMD() rather than OperIsSIMDorSimdHWintrinsic()

5 years agoMerge pull request #21194 from mmitche/fix-debug-checked
Matt Mitchell [Mon, 26 Nov 2018 19:38:31 +0000 (11:38 -0800)]
Merge pull request #21194 from mmitche/fix-debug-checked

Don't attempt to sign xstate in debug/checked builds

5 years agoRemove TypedReference.MakeTypedReference readonly restriction (#21193)
Stephen Toub [Mon, 26 Nov 2018 19:08:38 +0000 (14:08 -0500)]
Remove TypedReference.MakeTypedReference readonly restriction (#21193)

TypedReference.MakeTypedReference validates that the fields aren't readonly, which limits our ability to make fields readonly in core while maintaining BinaryFormatter compatibility.  This restriction isn't useful for a variety of reasons, though: reflection allows readonly fields to be set, but more importantly, TypedReference.SetTypedReference has always thrown NotSupportedException, so it's not even actually usable.

This change just removes the readonly check from MakeTypedReference.

5 years agoMerge pull request #21164 from kvochko/no_hw_intrinsics_x86
Carol Eidt [Mon, 26 Nov 2018 19:04:56 +0000 (11:04 -0800)]
Merge pull request #21164 from kvochko/no_hw_intrinsics_x86

[x86] Do not support hardware intrinsics on x86 unix

5 years agoHandle the remaining known issues (modulo snan) with the double/single parsing logic...
Tanner Gooding [Mon, 26 Nov 2018 19:01:04 +0000 (11:01 -0800)]
Handle the remaining known issues (modulo snan) with the double/single parsing logic (#21036)

* Fixing the double/single parser to return negative zero for `-0`

* Updating the Utf8Parser to allow exponents of arbitrary length

* Updating the double/single parser to support case-insensitive and signed infinity/nan

* Ensure TryParseAsSpecialFloatingPoint handles the case where we have an empty source

* Fixing the number parser to allow `-0` for decimal and to not parse '++infini'

5 years agoTar arm build outputs to workaround unicode issues (#21127)
Michelle McDaniel [Mon, 26 Nov 2018 16:31:30 +0000 (08:31 -0800)]
Tar arm build outputs to workaround unicode issues (#21127)

5 years agoDon't attempt to sign xstate in debug/checked builds
Matt Mitchell [Mon, 26 Nov 2018 16:18:03 +0000 (08:18 -0800)]
Don't attempt to sign xstate in debug/checked builds

5 years agoDon't generate copy assertions for normalize on load variables
Mike Danes [Sun, 25 Nov 2018 09:22:08 +0000 (11:22 +0200)]
Don't generate copy assertions for normalize on load variables

5 years agoAdd test for 18867
Mike Danes [Sun, 25 Nov 2018 08:44:31 +0000 (10:44 +0200)]
Add test for 18867

5 years agoFix Interop/PInvoke/Miscellaneous/HandleRef tests under GCStress (#21131)
Jeremy Koritzinsky [Sun, 25 Nov 2018 00:35:17 +0000 (18:35 -0600)]
Fix Interop/PInvoke/Miscellaneous/HandleRef tests under GCStress (#21131)

* Add GC.KeepAlive call in the IL stub when marshalling a HandleRef.

* Add a GC.KeepAlive call for the BoxedInt since it isn't kept alive when running GC Stress

* Reference HandleRef._handle via the binder instead of by field offset arithmetic

* Alignment

* Use Marshal.Alloc/FreeHGlobal instead of the weird no-pinning machinery that was failing before

* Update HandleRefTest.cs

5 years agoFixing typo (#21081)
Ayende Rahien [Sat, 24 Nov 2018 15:18:36 +0000 (17:18 +0200)]
Fixing typo (#21081)

5 years agoRefactor AppDomain.IsAppXModel and a few other AppDomain methods (#21181)
Jan Kotas [Sat, 24 Nov 2018 15:00:36 +0000 (07:00 -0800)]
Refactor AppDomain.IsAppXModel and a few other AppDomain methods (#21181)

Contributes to #21028

5 years agoMove AppDomain local data store to AppContext and cleanup AppContext (#21180)
Jan Kotas [Sat, 24 Nov 2018 14:59:54 +0000 (06:59 -0800)]
Move AppDomain local data store to AppContext and cleanup AppContext (#21180)

Contributes to #21028

5 years agoDon't assume objects don't escape in pure helpers.
Eugene Rozenfeld [Fri, 23 Nov 2018 22:55:02 +0000 (14:55 -0800)]
Don't assume objects don't escape in pure helpers.

We can't assume objects don't escape in helpers marked as pure for the following reasons:

1. The helpers may call user code that may make objects escape, e.g.,
https://github.com/dotnet/coreclr/blob/c94d8e68222d931d4bb1c4eb9a52b4b056e85f12/src/vm/jithelpers.cpp#L2371

2. The helpers usually protect gc pointers with GCPROTECT_BEGIN() so the pointers are reported as normal pointers to the gc.
Pointers to stack-allocated objects need to be reported as interior so they have to be protected with
GCPROTECT_BEGININTERIOR().

3. The helpers may cause these asserts in ValidateInner on stack-allocated objects:
https://github.com/dotnet/coreclr/blob/c94d8e68222d931d4bb1c4eb9a52b4b056e85f12/src/vm/object.cpp#L723
https://github.com/dotnet/coreclr/blob/c94d8e68222d931d4bb1c4eb9a52b4b056e85f12/src/vm/object.cpp#L730

5 years agoFix debugger collectible thread statics access (#21175)
Jan Vorlicek [Fri, 23 Nov 2018 18:14:03 +0000 (19:14 +0100)]
Fix debugger collectible thread statics access (#21175)

The CordbClass::GetStaticFieldValue2 was missing support for accessing
thread statics in collectible classes. Fortunately the fix was simple,
we can use the same code path as for non-collectible thread statics.

5 years agoUpdate CoreClr, CoreFx, CoreSetup, PgoData to preview-27123-02, preview.18573.2,...
dotnet-maestro-bot [Fri, 23 Nov 2018 17:34:42 +0000 (09:34 -0800)]
Update CoreClr, CoreFx, CoreSetup, PgoData to preview-27123-02, preview.18573.2, preview-27123-01, master-20181123-0042, respectively (#21158)

5 years agoTypos (#21171)
John Doe [Thu, 22 Nov 2018 22:23:46 +0000 (14:23 -0800)]
Typos (#21171)

* accesible -> accessible

* acheive -> achieve

* actutl -> actual

* appied -> applied

* apropriate -> appropriate

* aprox -> approx

* aquired -> acquired

* argumemts -> arguments

* Argumens -> Arguments

* argumetn -> argument

5 years agoDelete System.AppDomainSetup (#21157)
Jan Kotas [Thu, 22 Nov 2018 22:22:40 +0000 (14:22 -0800)]
Delete System.AppDomainSetup (#21157)

* Delete System.AppDomainSetup

Contributes to #21028

* Add test hook for null entry assembly

* Validate that the binder paths are absolute

5 years agoMark the String.Empty field as Intrinsic (#21162)
Michal Strehovský [Thu, 22 Nov 2018 18:09:37 +0000 (19:09 +0100)]
Mark the String.Empty field as Intrinsic (#21162)

This is required so that the CPAOT compiler can recognize this field as a RyuJIT intrinsic.

5 years agoNarrow the assert in fgLateDevirtualization (#21163)
Michal Strehovský [Thu, 22 Nov 2018 17:38:16 +0000 (18:38 +0100)]
Narrow the assert in fgLateDevirtualization (#21163)

As suggested by Andy in dotnet/corert#6601.

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 434 (#21166)
dotnet-maestro[bot] [Thu, 22 Nov 2018 14:43:20 +0000 (14:43 +0000)]
Update dependencies from https://github.com/dotnet/arcade build 434 (#21166)

This change updates the following dependencies
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.18571.7
- Microsoft.DotNet.Helix.Sdk - 1.0.0-beta.18571.7

5 years agoDo not support HW intrinsics on x86 linux
Andrey Kvochko [Thu, 22 Nov 2018 12:27:01 +0000 (15:27 +0300)]
Do not support HW intrinsics on x86 linux

5 years agoSequel to NativeLibrary API (#21148)
Swaroop Sridhar [Thu, 22 Nov 2018 09:24:08 +0000 (01:24 -0800)]
Sequel to NativeLibrary API (#21148)

Small changes to address furhter feedback:
 - Perform argument validation in the Marshall.cs instead of DllImport helpers
 - Improve doc comments.

5 years agoUpdate CoreClr, CoreFx, CoreSetup to preview-27121-03, preview.18571.3, preview-27121...
dotnet-maestro-bot [Thu, 22 Nov 2018 00:51:45 +0000 (16:51 -0800)]
Update CoreClr, CoreFx, CoreSetup to preview-27121-03, preview.18571.3, preview-27121-03, respectively (#21142)

5 years agoSingle stepping out of the unsafe places (#21135)
Andrew Au [Thu, 22 Nov 2018 00:17:06 +0000 (16:17 -0800)]
Single stepping out of the unsafe places (#21135)

5 years agoMerge pull request #21146 from AaronRobinsonMSFT/comtoclrworker_av
Aaron Robinson [Wed, 21 Nov 2018 21:59:57 +0000 (13:59 -0800)]
Merge pull request #21146 from AaronRobinsonMSFT/comtoclrworker_av

COMToCLRWorker AV

5 years agoMinor clean up in COMToCLRWorker
Aaron Robinson [Wed, 21 Nov 2018 19:21:24 +0000 (11:21 -0800)]
Minor clean up in COMToCLRWorker

5 years agoIntroduce Marshall.LoadLibrary API (#20871)
Swaroop Sridhar [Wed, 21 Nov 2018 19:42:01 +0000 (11:42 -0800)]
Introduce Marshall.LoadLibrary API (#20871)

Implement Native LoadLibrary API

This change commits the following changes:
1) Refactoring DllImport code to reuse LodLibrary by search for
   pInvoke and LoadLibrary cases
2) Implement the new Native Library API in System.Runtime.Interop.Marshall
3) Add tests for the new APIs

5 years agoDisable object stack allocation verification under GCStress.
Eugene Rozenfeld [Mon, 19 Nov 2018 21:25:56 +0000 (13:25 -0800)]
Disable object stack allocation verification under GCStress.

ObjectStackAllocationTests use GC.GetAllocatedBytesForCurrentThread to
verify object stack allocations. Under GCStress the vm may initiate additional
heap allocations in GCHeap::StressHeap (see the call to 'pGenGCHeap->allocate' below).

This change re-enables ObjectStackAllocationTests and updates then to not verify stack allocations under GCStress.
It's useful to run the tests even without the verification to catch crashes, gc asserts, etc.

```
if (Interlocked::Increment(&OneAtATime) == 0 &&
        !TrackAllocations()) // Messing with object sizes can confuse the profiler (see ICorProfilerInfo::GetObjectSize)
    {
        StringObject* str;

        // If the current string is used up
        if (HndFetchHandle(m_StressObjs[m_CurStressObj]) == 0)
        {
            // Populate handles with strings
            int i = m_CurStressObj;
            while(HndFetchHandle(m_StressObjs[i]) == 0)
            {
                _ASSERTE(m_StressObjs[i] != 0);
                unsigned strLen = (LARGE_OBJECT_SIZE - 32) / sizeof(WCHAR);
                unsigned strSize = PtrAlign(StringObject::GetSize(strLen));

                // update the cached type handle before allocating
                SetTypeHandleOnThreadForAlloc(TypeHandle(g_pStringClass));
                str = (StringObject*) pGenGCHeap->allocate (strSize, acontext);
                if (str)
                {
                    str->SetMethodTable (g_pStringClass);
                    str->SetStringLength (strLen);

                    HndAssignHandle(m_StressObjs[i], ObjectToOBJECTREF(str));
                }
                i = (i + 1) % NUM_HEAP_STRESS_OBJS;
                if (i == m_CurStressObj) break;
            }

            // advance the current handle to the next string
            m_CurStressObj = (m_CurStressObj + 1) % NUM_HEAP_STRESS_OBJS;
        }

        // Get the current string
        str = (StringObject*) OBJECTREFToObject(HndFetchHandle(m_StressObjs[m_CurStressObj]));
        if (str)
        {
            // Chop off the end of the string and form a new object out of it.
            // This will 'free' an object at the begining of the heap, which will
            // force data movement.  Note that we can only do this so many times.
            // before we have to move on to the next string.
            unsigned sizeOfNewObj = (unsigned)Align(min_obj_size * 31);
            if (str->GetStringLength() > sizeOfNewObj / sizeof(WCHAR))
            {
                unsigned sizeToNextObj = (unsigned)Align(size(str));
                uint8_t* freeObj = ((uint8_t*) str) + sizeToNextObj - sizeOfNewObj;
                pGenGCHeap->make_unused_array (freeObj, sizeOfNewObj);
                str->SetStringLength(str->GetStringLength() - (sizeOfNewObj / sizeof(WCHAR)));
            }
            else
            {
                // Let the string itself become garbage.
                // will be realloced next time around
                HndAssignHandle(m_StressObjs[m_CurStressObj], 0);
            }
        }
    }
    Interlocked::Decrement(&OneAtATime);
```

5 years agoCheck for null on COM to CLR call if error occurs during thread instance get.
Aaron Robinson [Wed, 21 Nov 2018 19:07:41 +0000 (11:07 -0800)]
Check for null on COM to CLR call if error occurs during thread instance get.

5 years agoChange System.Object to ClassInterface.None (#21137)
Jan Kotas [Wed, 21 Nov 2018 18:24:11 +0000 (10:24 -0800)]
Change System.Object to ClassInterface.None (#21137)

* Change System.Object to ClassInterface.None

Prevents .NET Framework legacy interfaces from leaking out.

Fixes https://github.com/dotnet/corefx/issues/33638

* Use AutoDispatch for System.Object

5 years agoFix Unix ARM JIT_MemCpy and JIT_MemSet (#21141)
Jan Vorlicek [Wed, 21 Nov 2018 18:20:01 +0000 (19:20 +0100)]
Fix Unix ARM JIT_MemCpy and JIT_MemSet (#21141)

The functions were incorrectly using 4 byte loads to probe for
the address validity. While the comment on JIT_MemCpy requires
4 byte aligned address, it doesn't match the way JIT uses it and
the Windows version of the function works with unaligned addresses
too.
This bug was discovered as a crash in an application where the
JIT_MemCpy was called with count=2 and an address that was two
bytes below the end of a memory page where the following page
was not mapped.

5 years agoEnsuring that gc_stress and gc_stress_c are marked global when writing, but not when...
Tanner Gooding [Wed, 21 Nov 2018 16:37:35 +0000 (08:37 -0800)]
Ensuring that gc_stress and gc_stress_c are marked global when writing, but not when reading (#21128)

5 years agoDelete dead/unused code (#21138)
Jan Kotas [Wed, 21 Nov 2018 16:23:30 +0000 (08:23 -0800)]
Delete dead/unused code (#21138)

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 420 (#21140)
dotnet-maestro[bot] [Wed, 21 Nov 2018 14:43:28 +0000 (14:43 +0000)]
Update dependencies from https://github.com/dotnet/arcade build 420 (#21140)

This change updates the following dependencies
- Microsoft.DotNet.Arcade.Sdk - 1.0.0-beta.18570.17
- Microsoft.DotNet.Helix.Sdk - 1.0.0-beta.18570.17

5 years agoUpdate CoreSetup, PgoData to preview-27121-02, master-20181121-0042, respectively...
dotnet-maestro-bot [Wed, 21 Nov 2018 12:20:33 +0000 (04:20 -0800)]
Update CoreSetup, PgoData to preview-27121-02, master-20181121-0042, respectively (#21136)

5 years agoUpdate BuildTools, CoreClr, CoreFx, CoreSetup, IbcData, PgoData to preview1-03420...
dotnet-maestro-bot [Wed, 21 Nov 2018 07:26:39 +0000 (23:26 -0800)]
Update BuildTools, CoreClr, CoreFx, CoreSetup, IbcData, PgoData to preview1-03420-02, preview-27121-02, preview.18571.1, preview-27120-04, master-20181120-0045, master-20181120-0044, respectively (#21045)

5 years agoMerge pull request #21129 from mmitche/sign-xstat
Matt Mitchell [Wed, 21 Nov 2018 02:13:59 +0000 (18:13 -0800)]
Merge pull request #21129 from mmitche/sign-xstat

Sign api-ms-win-core-xstate-l2-1-0.dll

6 years agoExpose generic UnsafeQueueUserWorkItem (#21125)
Stephen Toub [Wed, 21 Nov 2018 00:52:08 +0000 (19:52 -0500)]
Expose generic UnsafeQueueUserWorkItem (#21125)

6 years agoVectorize string.IndexOf(..., StringComparison.Ordinal) (#21076)
Ben Adams [Wed, 21 Nov 2018 00:50:26 +0000 (00:50 +0000)]
Vectorize string.IndexOf(..., StringComparison.Ordinal) (#21076)

* Vectorize string.IndexOf(..., StringComparison.Ordinal)

* Merge two IndexOf(..., int* matchLengthPtr)

* fix

2 callers expect value.Length == 0 to be tested first
3rd caller ReplaceCore doesn't allow a value.Length == 0 so moving it
first is ok

6 years agoVectorize Array.{Last}IndexOf<T>(...) for byte and char (#21116)
Ben Adams [Wed, 21 Nov 2018 00:44:56 +0000 (00:44 +0000)]
Vectorize Array.{Last}IndexOf<T>(...) for byte and char (#21116)

* Vectorize Array.IndexOf<T>(...) for byte and char

* Also LastIndexOf

6 years agoMerge pull request #21058 from CarolEidt/FixVZeroUpper
Carol Eidt [Tue, 20 Nov 2018 23:58:41 +0000 (15:58 -0800)]
Merge pull request #21058 from CarolEidt/FixVZeroUpper

Record AVX use for SIMD indirections

6 years agoSign api-ms-win-core-xstate-l2-1-0.dll
Matt Mitchell [Mon, 13 Aug 2018 18:15:05 +0000 (11:15 -0700)]
Sign api-ms-win-core-xstate-l2-1-0.dll
This file is only catalog signed in RS4.  Sign during the build. To achieve this copy the CRT binaries locally rather than referencing from the UCRT location directly.

6 years agoRemove remaining StringBuilder marshaling use from Corelib (#21120)
Stephen Toub [Tue, 20 Nov 2018 22:03:33 +0000 (17:03 -0500)]
Remove remaining StringBuilder marshaling use from Corelib (#21120)

* Remove remaining StringBuilder marshaling use from Corelib

- Unix globalization functions were using StringBuilder.  Replaced them with stackallocs, as the max sizes were all relatively small.
- Registry methods were declared to use StringBuilder, but these weren't actually used by corelib, and in fact, corefx isn't using StringBuilder with them either.  I've changed the definitions for now to use char[] instead (all the call sites are passing in null), and I'll fix up some corefx usage separately.
- Resource-related functions were using StringBuilder, and have been replaced with stackallocs, given reasonably small max buffer sizes.
- ExpandEnvironmentVariables was using a StringBuilder, but it's rewritten equivalent code in corefx is not.  For now I've copied the corefx function over to coreclr to replace the different implementation, but we can look at subsequently consolidating them into one.

* Address PR feedback

6 years agoRemove StringBuilder from HebrewNumber formatting (#21122)
Stephen Toub [Tue, 20 Nov 2018 20:59:37 +0000 (15:59 -0500)]
Remove StringBuilder from HebrewNumber formatting (#21122)

Rather than allocating a new StringBuilder, writing into that, getting its string, and then appending that string to another StringBuilder, we can just write directly to the original one.

6 years agoFix for #21011: propagate GTF_DONT_CSE on comma returns
Eugene Rozenfeld [Tue, 20 Nov 2018 01:08:06 +0000 (17:08 -0800)]
Fix for #21011: propagate GTF_DONT_CSE on comma returns

When a method returns a multi-reg struct, we set GTF_DONT_CSE on return local: https://github.com/dotnet/coreclr/blob/497419bf8f19c649d821295da7e225e55581cce9/src/jit/importer.cpp#L8783

Setting GTF_DONT_CSE blocks assertion propagation here:
https://github.com/dotnet/coreclr/blob/9d49bf1ec6f102b89e5c2885e8f9d3d77f2ec144/src/jit/assertionprop.cpp#L2845-L2848

In the test we have a synchronized method so we change the return node to
return a comma that include a call to HELPER.CORINFO_HELP_MON_EXIT.
If the rightmost comma expression doesn't have GTF_DONT_CSE,
assertion propagation is not blocked and we end up with this tree:

```
               [000040] -----+------                 /--*  CNS_INT   struct 0
               [000043] --C-G+------              /--*  COMMA     struct
               [000036] --C-G+------              |  \--*  CALL help void   HELPER.CORINFO_HELP_MON_EXIT
               [000032] L----+------ arg1 in x1   |     +--*  ADDR      long
               [000031] ----G+-N----              |     |  \--*  LCL_VAR   ubyte (AX) V03 tmp1
               [000033] -----+------ arg0 in x0   |     \--*  LCL_VAR   ref    V00 this
               [000041] -AC-G+------              *  COMMA     struct
               [000006] -----+-N----              |  /--*  LCL_VAR   struct V01 loc0
               [000039] -A---+------              \--*  ASG       struct (copy)
               [000037] D----+-N----                 \--*  LCL_VAR   struct V05 tmp3
```

Downstream phases can't handle struct zero return expressed as
```
               [000040] -----+------                 /--*  CNS_INT   struct 0
```

The fix is to propagate GTF_DONT_CSE to the rightmost comma expression
to block bad assertion propagation.

Fixes #21011.

6 years agoFixing up some issues with the HWIntrinsic test templates (#21104)
Tanner Gooding [Tue, 20 Nov 2018 20:01:25 +0000 (12:01 -0800)]
Fixing up some issues with the HWIntrinsic test templates (#21104)

* Updating the VectorNotSupportedTest to throw on failure

* Updating the HWIntrinsic test templates to check success on a per-scenario basis

* Regenerating the templated HWIntrinsic tests

6 years agoReplace custom AnsiToLower with more efficient ToLowerAsciiInvariant (#21121)
Stephen Toub [Tue, 20 Nov 2018 19:58:47 +0000 (14:58 -0500)]
Replace custom AnsiToLower with more efficient ToLowerAsciiInvariant (#21121)

Avoids all of the StringBuilder-related costs.

6 years agoDelete CORCOMPILE_IMPORT_TABLE_ENTRY (#21109)
Jan Kotas [Tue, 20 Nov 2018 18:56:12 +0000 (10:56 -0800)]
Delete CORCOMPILE_IMPORT_TABLE_ENTRY (#21109)

6 years agoLinux: FlushProcessWriteBuffers using membarrier when available (#20949)
Tom Deseyn [Tue, 20 Nov 2018 18:52:46 +0000 (19:52 +0100)]
Linux: FlushProcessWriteBuffers using membarrier when available (#20949)

* Linux: FlushProcessWriteBuffers using membarrier when available

* Ensure __NR_membarrier is defined for x64 portable build.

* Define __NR_membarrier on all portable architectures