platform/upstream/coreclr.git
5 years agoUpdating some local functions to be 'static' (captureless). (#22635)
Tanner Gooding [Fri, 15 Feb 2019 23:17:52 +0000 (15:17 -0800)]
Updating some local functions to be 'static' (captureless). (#22635)

5 years agoJIT: modify how jit determines when to update a type (#22618)
Andy Ayers [Fri, 15 Feb 2019 22:39:33 +0000 (14:39 -0800)]
JIT: modify how jit determines when to update a type (#22618)

For single-def locals, the type of a reference seen at the assignment to the
local may be a more specific type than the local's declared type. If so the jit
would prefer to use the assignment type to describe the local's value, as this
will lead to better optimization. For instance in
```
    object x = "a string";  // only assignment to x
```
the jit can optimize better if it models the type of `x` as `string`.

Instead of relying on `mergeClasses` plus some jit-side screening to decide if
the assignment type is a more specific type, implement a new jit interface
method `isMoreSpecificType` that tries to answer this question more directly.

Added a test case with type equivalence that hit asserts.

Closes #22583.

5 years agoDisable arm64 contracts. (#22605)
Sergey Andreenko [Fri, 15 Feb 2019 22:03:47 +0000 (14:03 -0800)]
Disable arm64 contracts. (#22605)

* Fix ifdef for `g_DbgSuppressAllocationAsserts`.

It needs to be defined under `FEATURE_INTEROP_DEBUGGING`.

* Unify contracts disabling for UNIX/ARM.

It also disables some parts that were disabled for ARM, but not for UNIX.
It fixes the difference that we see between ARM32 and ARM64 Unix Checked.

* Disable contracts on arm64.

FIxes the difference that we see between windows arm32 and arm64 in checked/debug builds.

* Revert CoreFX arm64 timeout change.

That is no longer necessary.

* Reenable arm64 corefx jobs.

They should not fail with timeouts anymore.

* Don't allow `g_DbgSuppressAllocationAsserts` defnition in release builds.

* delete AssertAllocationAllowed

5 years agoPort profiler howtos from David Broman's blog to the documentation folder (#22363)
David Mason [Fri, 15 Feb 2019 22:02:31 +0000 (14:02 -0800)]
Port profiler howtos from David Broman's blog to the documentation folder (#22363)

5 years agoPublish version to dotnet/versions
Steve MacLean [Mon, 11 Feb 2019 21:39:44 +0000 (16:39 -0500)]
Publish version to dotnet/versions

5 years agoFix UpdatePublishedVersions.ps1
Steve MacLean [Thu, 14 Feb 2019 21:04:47 +0000 (16:04 -0500)]
Fix UpdatePublishedVersions.ps1

5 years agoDelete references to System.Memory package that does not exist anymore (#22626)
Jan Kotas [Fri, 15 Feb 2019 19:23:45 +0000 (11:23 -0800)]
Delete references to System.Memory package that does not exist anymore (#22626)

5 years agoDisable failing corefx test (#22625)
Jan Kotas [Fri, 15 Feb 2019 18:25:05 +0000 (10:25 -0800)]
Disable failing corefx test (#22625)

Related to https://github.com/dotnet/corefx/issues/35351

5 years agoManually update the dependencies.props and move S.P.Corelib to use LangVersion=8...
Tanner Gooding [Fri, 15 Feb 2019 17:20:37 +0000 (09:20 -0800)]
Manually update the dependencies.props and move S.P.Corelib to use LangVersion=8.0 (#22452)

* Update BuildTools to preview1-03713-01 (master)

* Updating CoreCLR to use LangVersion=8.0

* Moving the Windows scripts to default to `dotnet msbuild` for managed components

* Setting UseSharedCompilation=true

* Changing some additional callsites that were using msbuild to use dotnet msbuild

* Revert packages.builds to use Desktop msbuild on Windows

* Fixing runtest.cmd to always set DotNetCli

5 years agoReserve fast dictionary slots for Tier1 code (#22619)
Jan Kotas [Fri, 15 Feb 2019 16:20:12 +0000 (08:20 -0800)]
Reserve fast dictionary slots for Tier1 code (#22619)

Disable use of fast dictionary slots for R2R images when tiered JITing is enabled.

Fixes #22400

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 20190214.4 (#22621)
dotnet-maestro[bot] [Fri, 15 Feb 2019 16:10:14 +0000 (08:10 -0800)]
Update dependencies from https://github.com/dotnet/arcade build 20190214.4 (#22621)

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

5 years agoRemove CoreLib's src\Interop\Windows directory (#22622)
Stephen Toub [Fri, 15 Feb 2019 16:05:07 +0000 (11:05 -0500)]
Remove CoreLib's src\Interop\Windows directory (#22622)

It contains only one file with an interop signature that's not actually being used. Deleting the dup.

5 years agoFix CoreFX build breaks
Jan Kotas [Fri, 15 Feb 2019 08:11:29 +0000 (00:11 -0800)]
Fix CoreFX build breaks

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoFixing the number formatting code to only recognize 'R' for double/float. (#22613)
Tanner Gooding [Fri, 15 Feb 2019 06:24:40 +0000 (22:24 -0800)]
Fixing the number formatting code to only recognize 'R' for double/float. (#22613)

5 years agoMove Reflection.Emit Tokens to shared partition (#22602)
Marek Safar [Fri, 15 Feb 2019 02:28:01 +0000 (03:28 +0100)]
Move Reflection.Emit Tokens to shared partition (#22602)

5 years agoMissed optimization from #22497
Grant [Fri, 15 Feb 2019 02:21:52 +0000 (18:21 -0800)]
Missed optimization from #22497

5 years agoRemove unnecessary ProjectReferences to CoreCLRTestLibrary (#22539)
Egor Chesakov [Fri, 15 Feb 2019 01:26:18 +0000 (17:26 -0800)]
Remove unnecessary ProjectReferences to CoreCLRTestLibrary (#22539)

Remove the ProjectReferences to CoreCLRTestLibrary.csproj in the project files where CoreCLRTestLibrary is not actually being used.

Each ProjectReference item is ended up in PrepareProjectReferences target that creates unnecessary items.

5 years agoReplace multi-loaderallocator hash implementation in MethodDescBackpatchInfo (#22285)
David Wrighton [Fri, 15 Feb 2019 01:07:14 +0000 (17:07 -0800)]
Replace multi-loaderallocator hash implementation in MethodDescBackpatchInfo (#22285)

* GCHeapHash
- Hashtable implementation for runtime use
- Implementation written in C++
- Data storage in managed heap memory
- Based on SHash design, but using managed memory

CrossLoaderAllocatorHash
- Hash for c++ Pointer to C++ pointer where the lifetimes are controlled by different loader allocators
 - Support for add/remove/visit all entries of 1 key/visit all entries/ remove all entries of 1 key
- Supports holding data which is unmanaged, but data items themselves can be of any size (key/value are templated types)

* Swap MethodDescBackpatchInfo to use the CrossLoaderAllocatorHash

* The MethodDescBackpatchCrst needs to be around an allocation
- Adjust the Crst so that it can safely be used around code which allocates
- Required moving its use out from within the EESuspend logic used in rejit

5 years agoRemove unnecessary fields from WaitHandle (#22593)
Filip Navara [Thu, 14 Feb 2019 23:02:20 +0000 (00:02 +0100)]
Remove unnecessary fields from WaitHandle (#22593)

* Remove unnecessary fields from WaitHandle

* Drop volatile from _waitHandle

* Address race condition in unmanaged code

* Remove unused hasThreadAffinity parameters

* Fix FCDECL argument counts

5 years agoFix check for memory containment safety. (#22563)
Eugene Rozenfeld [Thu, 14 Feb 2019 22:43:26 +0000 (14:43 -0800)]
Fix check for memory containment safety. (#22563)

This change ensures that if an operand can produce an exception
and any instructions executed after the operand evaluation but before
the operand's parent can also produce an exception, the operand
shouldn't be contained. The reason is that in this case operand
containment may reorder exceptions.

With `strict` set to true the containment is blocked here:
https://github.com/dotnet/coreclr/blob/d27fff3f65193dd71c6197e9876101f496bbd28b/src/jit/sideeffects.cpp#L485-L488

Also, make the check for ordering side-effect interference less
conservative.

Fixes #22556.

5 years agoRevert signing to fixed version (#22609)
Juan Hoyos [Thu, 14 Feb 2019 21:52:10 +0000 (13:52 -0800)]
Revert signing to fixed version (#22609)

SPC signing got broken when #22544 unpinned the SignTool version. Pin the tool version again until issue gets fixed.

@jashook

5 years agoConsolidate implementation of Rotate and PopCount (#22584)
Grant [Thu, 14 Feb 2019 21:51:03 +0000 (13:51 -0800)]
Consolidate implementation of Rotate and PopCount (#22584)

* Perf: BitOps.LeadingZeroCount

* Remove redundant MSIL cast, conv.u8

* Use local functions for SoftwareFallback

* Target BIT32/64

5 years agoAdjust corert for shared SafeHandle and EventRegistrationToken
Stephen Toub [Wed, 13 Feb 2019 22:58:52 +0000 (17:58 -0500)]
Adjust corert for shared SafeHandle and EventRegistrationToken

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoFix netfx build break in Microsoft.Diagnostics.Tracing.EventSource.Redist
Stephen Toub [Wed, 13 Feb 2019 19:49:15 +0000 (14:49 -0500)]
Fix netfx build break in Microsoft.Diagnostics.Tracing.EventSource.Redist

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoMove FrameworkEventSource to shared partition (#22507)
Marek Safar [Thu, 14 Feb 2019 20:14:52 +0000 (21:14 +0100)]
Move FrameworkEventSource to shared partition (#22507)

* Move FrameworkEventSource to shared partition

and remove unused code

* Remove more unused code

* Remove CA8001 suppress message

5 years agoGnuport cleanup 3 (#22581)
Sinan Kaya [Thu, 14 Feb 2019 19:06:57 +0000 (14:06 -0500)]
Gnuport cleanup 3 (#22581)

* Reorder extern "C" and visibility statements

In file included from coreclr/src/pal/inc/pal.h:70:0,
coreclr/src/pal/inc/pal_mstypes.h:30:25: error: expected unqualified-id
before string constant
 #define EXTERN_C extern "C"
                          ^
coreclr/src/pal/inc/rt/palrt.h:216:30: note:
  in expansion of macro 'EXTERN_C'
   #define STDAPI_(type)        EXTERN_C type STDAPICALLTYPE

* Need double quotes around single quotes in error statements

fix error statements

Can't have ' character in error statement

* Abstract __declspec(noinline)

Generate compiler independent macros for noinline request.

* Remove unused DBG_NOINLINE_X86__RET_INLINE

* Abstract __declspec(nothrow)

5 years agoAdd Rune creation API from UTF-16 surrogate pair (#22590)
Levi Broderick [Thu, 14 Feb 2019 19:00:02 +0000 (11:00 -0800)]
Add Rune creation API from UTF-16 surrogate pair (#22590)

Also brings in some perf improvements to existing char and UnicodeUtility APIs

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 20190213.1 (#22594)
dotnet-maestro[bot] [Thu, 14 Feb 2019 18:29:06 +0000 (13:29 -0500)]
Update dependencies from https://github.com/dotnet/arcade build 20190213.1 (#22594)

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

5 years agoAdd coreclr-outerloop build definition jobs (#22578)
Egor Chesakov [Thu, 14 Feb 2019 16:20:06 +0000 (08:20 -0800)]
Add coreclr-outerloop build definition jobs (#22578)

5 years agoDon't use $(_HelixSource) and $(_HelixType) in test-job.yml (#22589)
Egor Chesakov [Thu, 14 Feb 2019 16:17:52 +0000 (08:17 -0800)]
Don't use $(_HelixSource) and $(_HelixType) in test-job.yml (#22589)

5 years agoAnnotate PlatformID as a moved type
Michal Strehovsky [Wed, 13 Feb 2019 12:45:42 +0000 (04:45 -0800)]
Annotate PlatformID as a moved type

This should have been annotated along with the rest in dotnet/corert#6928 but I missed it.

[tfs-changeset: 1733685]

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoImproving an assert in fgInsertInlineeBlocks
Andrew Au [Tue, 29 Jan 2019 21:46:30 +0000 (13:46 -0800)]
Improving an assert in fgInsertInlineeBlocks

5 years agoUse dependency flow for core-setup and corefx dependencies (#22544)
Juan Hoyos [Thu, 14 Feb 2019 02:14:35 +0000 (18:14 -0800)]
Use dependency flow for core-setup and corefx dependencies (#22544)

* Remove old use of signing package used to work around SPC signing now that arcade has bubbled up the version.
* Move dependency update for CoreFX and Core-setup dependencies to BAR/Darc/Maestro++ flow
* Update property references in tests.
* Version bump for CoreFX and Core-Setup dependencies.
* Update test Github_20958 to use revised System.Range constructor as surface area changed with #22331.

5 years agoMerge pull request #22327 from BrianBohe/refactoring_genCodeForBBList
Carol Eidt [Thu, 14 Feb 2019 00:30:44 +0000 (16:30 -0800)]
Merge pull request #22327 from BrianBohe/refactoring_genCodeForBBList

Moving structures initialization before generating code for blocks to…

5 years agoRemove Marshaling MDA (#22579)
Jeremy Koritzinsky [Wed, 13 Feb 2019 23:52:35 +0000 (15:52 -0800)]
Remove Marshaling MDA (#22579)

Remove the "marshaling" MDA. In .NET Framework it was off by default and in .NET Core it was commented out in the boilerplate file. Additionally, from what I can tell only half of its functionality was ever implemented in .NET Core.

Contributes to #22538.

5 years agoRemove some CAS cruft (#22576)
Aaron Robinson [Wed, 13 Feb 2019 23:04:59 +0000 (15:04 -0800)]
Remove some CAS cruft (#22576)

* Update comment on SuppressUnmanagedCodeSecurityAttribute.
* Remove unused declsec.h header.

5 years agoPerf: Consolidate implementation of LeadingZeroCount (#22497)
Grant [Wed, 13 Feb 2019 22:17:01 +0000 (14:17 -0800)]
Perf: Consolidate implementation of LeadingZeroCount (#22497)

* Perf: BitOps.LeadingZeroCount

* CR fix

* CR fixes

* Optimization

* Revert

* Confirmed fix

* Simplify

* Return int

* Fixes

* Simplify

* CR fixes

* CR fixes

* Fix unit failure on Linux-musl x64 Debug

* CR fixes

* CR fixes

* Cleanup

5 years agoFix comment placement. (#22580)
Sergey Andreenko [Wed, 13 Feb 2019 20:15:10 +0000 (12:15 -0800)]
Fix comment placement. (#22580)

5 years agoMoving structures initialization before generating code for blocks to other function
Brian Bohe [Wed, 13 Feb 2019 19:26:49 +0000 (11:26 -0800)]
Moving structures initialization before generating code for blocks to other function

5 years agoReplace Win32Native.cs with Interop files (#22540)
Stephen Toub [Wed, 13 Feb 2019 18:43:13 +0000 (13:43 -0500)]
Replace Win32Native.cs with Interop files (#22540)

* Replace Win32Native.cs with Interop files

- Replace Win32Native usage with existing Interop.* calls where they already existed
- Moved Win32Native.* to their own files otherwise, and changed call sites
- Left a stub Win32Native in place to handle some emitted IL from the runtime.  The current infrastructure doesn't support targeting nested types, like Interop.Kernel32, and fixing that would be more involved.

* Remove Win32Native.cs

Replace emitted calls with ones to Marshal.

* Fix incorrectly changed field

* Fix Kernel32 -> Ole32

5 years agoMove SafeHandle to managed code and shared (#22564)
Stephen Toub [Wed, 13 Feb 2019 16:12:10 +0000 (11:12 -0500)]
Move SafeHandle to managed code and shared (#22564)

* Move SafeHandle to managed code and shared

This moves the implementation of SafeHandle from native code in the runtime to managed.  I used corert's implementation as a base, and reviewed it again against the existing native implementation, making a few tweaks to better match the existing semantics.

This should be a valid move because of the reduced goals around CERs, thread aborts, etc.

However, there are places in the runtime that access SafeHandle functionality via its native counterpart, so I kept the relevant pieces of the native code intact.  Most code will continue to use the managed APIs, but the runtime can continue calling into the native versions when needed.

* Address PR feedback

* Address PR feedback

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 20190212.3 (#22568)
dotnet-maestro[bot] [Wed, 13 Feb 2019 16:10:48 +0000 (11:10 -0500)]
Update dependencies from https://github.com/dotnet/arcade build 20190212.3 (#22568)

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

5 years agoMove EventRegistrationToken to shared (#22565)
Stephen Toub [Wed, 13 Feb 2019 16:10:31 +0000 (11:10 -0500)]
Move EventRegistrationToken to shared (#22565)

* Move EventRegistrationToken to shared

* Address PR feedback

5 years agoFixing the double/float formatting code to use a fallback precision for custom-format...
Tanner Gooding [Wed, 13 Feb 2019 15:36:57 +0000 (07:36 -0800)]
Fixing the double/float formatting code to use a fallback precision for custom-format strings. (#22522)

5 years agoFix gen-buildsys-win for vs2019 x86 (#22567)
Juan Hoyos [Wed, 13 Feb 2019 14:30:34 +0000 (06:30 -0800)]
Fix gen-buildsys-win for vs2019 x86 (#22567)

5 years agoImprove SpanHelpers.Byte (#22503)
Ben Adams [Wed, 13 Feb 2019 14:20:44 +0000 (14:20 +0000)]
Improve SpanHelpers.Byte (#22503)

5 years agoFix min-opts spill of tree temp large vectors (#22530)
Carol Eidt [Wed, 13 Feb 2019 04:49:56 +0000 (20:49 -0800)]
Fix min-opts spill of tree temp large vectors (#22530)

* Fix min-opts spill of tree temp large vectors

Even if we're not enregistering local vars, we may have large vectors live across a call that need to be spilled.

Fix #22200

5 years agoRefactoring siVarLoc creation (#22543)
Brian Bohe [Wed, 13 Feb 2019 01:22:35 +0000 (17:22 -0800)]
Refactoring siVarLoc creation (#22543)

* Moving siVarLoc and siVarLocType from compiler.h to CodeGenInterface.h

* Encapsulating siVarLoc construction with siScope and LclVarDsc

* Encapsulating siVarLoc construction from psiScope

* Adding some argument description on genSetScopInfo header

* Changing const siVarLoc& to const siVarLoc* on eeSetLVInfo

* Changing siVarLoc& to siVarLoc* in genSetScopeInfo arguments

* Rename var in genSetScopeInfo header

5 years agoFix CoreRT build breaks - Adjust resource name - Workaround C# compiler/analyzer bug
Jan Kotas [Tue, 12 Feb 2019 06:33:34 +0000 (22:33 -0800)]
Fix CoreRT build breaks - Adjust resource name - Workaround C# compiler/analyzer bug

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoFix exception sets for indirections in value numbering. (#22542)
Eugene Rozenfeld [Tue, 12 Feb 2019 22:43:14 +0000 (14:43 -0800)]
Fix exception sets for indirections in value numbering. (#22542)

fgValueNumberAddExceptionSetForIndirection had a bug
where INDIR(ADD(x, <big_offset>)) had NullReferenceException(x)
added instead of NullReferenceException(ADD(x, <big_offset>)).

Fixes #20358.

5 years agoEnable arm64 linux musl builds (#22495)
Jarret Shook [Tue, 12 Feb 2019 22:38:27 +0000 (14:38 -0800)]
Enable arm64 linux musl builds (#22495)

* Enable arm64 linux musl builds

Note that -clang5.0 is required to be passed.

* Fix syntax error

* Pass clang arg to build-test.sh

5 years agoBug Fix: Calling System.Diagnostics.Tracing.EventPipe.Enable twice asserts #22247...
José Rivero [Tue, 12 Feb 2019 21:54:33 +0000 (13:54 -0800)]
Bug Fix: Calling System.Diagnostics.Tracing.EventPipe.Enable twice asserts #22247 (#22318)

After disabling EventPipe -> SampleProfiler, we were not closing the thread shutdown event, thus asserting on reentrance of the EventPipe.
* Adding regression test, and removing comment.
* Waits until the specified object is in the signaled state.

5 years agoRenaming RuntimeEventSource to NativeRuntimeEventSource (#22533)
Sung Yoon Whang [Tue, 12 Feb 2019 19:53:39 +0000 (11:53 -0800)]
Renaming RuntimeEventSource to NativeRuntimeEventSource (#22533)

* Renaming RuntimeEventSource to NativeRuntimeEventSource

* missed a couple of comments and XPlatEventLogger

* rename DotNETRuntimeEventSource.cs to NativeRuntimeEventSource.cs

* use condition= instead of ifdef

* removing ifdef from NativeRuntimeEventSource.cs

* Fix case for 'eventing' directory in csproj

* Fix unix builds

* This should fix unix build...

5 years agoEnable portable fast alloc helpers on ARM64 Windows. (#22541)
Aditya Mandaleeka [Tue, 12 Feb 2019 18:20:35 +0000 (10:20 -0800)]
Enable portable fast alloc helpers on ARM64 Windows. (#22541)

5 years agoAdd extensions methods for several of the VectorXXX<T> helper methods (#22336)
Tanner Gooding [Tue, 12 Feb 2019 17:28:02 +0000 (09:28 -0800)]
Add extensions methods for several of the VectorXXX<T> helper methods (#22336)

* Moving several of the Vector128<T> instance methods to be extension methods.

* Moving several of the Vector256<T> instance methods to be extension methods.

* Moving several of the Vector64<T> instance methods to be extension methods.

5 years agoIfdef out code that triggers UTC bug (dotnet/corert#7003)
Michal Strehovský [Tue, 12 Feb 2019 12:45:47 +0000 (13:45 +0100)]
Ifdef out code that triggers UTC bug (dotnet/corert#7003)

This results in bad codegen on AMD64. I filed a bug internally; hopefully we can get a fix soon.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoUpdate COM Activator class (#22317)
Aaron Robinson [Tue, 12 Feb 2019 16:33:58 +0000 (08:33 -0800)]
Update COM Activator class (#22317)

* Update COM Activator to use ALCs

* Update tests to now supply an assembly name rather than an binary "path"
  since the COM activator is now using ALCs.

* Add test for non-rooted assembly path.

* Move the hostpolicy mock project to a Common area
Move hostpolicy mock API to CoreCLR test library

* Add test for COM server isolation

* Move ComActivator class and logic to Internal namespace.

5 years agoJIT: change how we block gc refs from callee saves for inline pinvokes (#22477)
Andy Ayers [Tue, 12 Feb 2019 16:22:47 +0000 (08:22 -0800)]
JIT: change how we block gc refs from callee saves for inline pinvokes (#22477)

Add a new marker instruction that we emit once we've enabled preepmtive gc in
the inline pinvoke method prolog. Use that to kill off callee saves registers
with GC references, instead of waiting until the call.

This closes a window of vulnerability we see in GC stress where if a stress
interrupt happens between the point at which we enable preeemptive GC and
the point at which we make the call, we may report callee saves as GC live
when they're actually dead.

Closes #19211.

5 years agoAdd new rounding modes to System.Math, System.MathF (#20815)
hamish-rose [Tue, 12 Feb 2019 10:56:00 +0000 (23:56 +1300)]
Add new rounding modes to System.Math, System.MathF (#20815)

* add new rounding modes to MidpointRounding.cs

new modes added to enum
implemented ToZero for double in Math.cs

* ToZero implementation

* implement double and float rounding modes

* updating rounding implementation

now round inline with DecCalc internal round implementation

* small bug fix

also replace var to make things obvious

* update implementation - floor/ceil

code review feedback

* review feedback

add comments, update MathF with floor/ceil

* code review feedback

 - fix comments
 - replace ifelse with switch
 - remove RoundingMode enum from DecCalc

* exclude outdated corefx test

5 years agoUpdate dependencies from https://github.com/dotnet/arcade build 20190208.1 (#22506)
dotnet-maestro[bot] [Tue, 12 Feb 2019 09:06:11 +0000 (04:06 -0500)]
Update dependencies from https://github.com/dotnet/arcade build 20190208.1 (#22506)

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

5 years agoSupport building with VS2019 Preview (#22525)
Tanner Gooding [Tue, 12 Feb 2019 07:19:44 +0000 (23:19 -0800)]
Support building with VS2019 Preview (#22525)

* Support building with VS2019 Preview

* Fixing gen-buildsys-win to only set the architecture for the VS generator

* Refactoring Dev11/147911/fpcw.cpp so that it compiles under VS2019

* Removing the remaining traces of VS2015 build support

5 years agoDelete mda.cs and related dead code (#22535)
Stephen Toub [Tue, 12 Feb 2019 04:23:32 +0000 (23:23 -0500)]
Delete mda.cs and related dead code (#22535)

5 years agoMove ConditionalWeakTable to shared (#22531)
Stephen Toub [Tue, 12 Feb 2019 02:34:21 +0000 (21:34 -0500)]
Move ConditionalWeakTable to shared (#22531)

Leaves DependentHandle as being the runtime PAL

5 years ago Make Module partial to allow additional changed for Mono
Marek Safar [Mon, 11 Feb 2019 23:38:55 +0000 (00:38 +0100)]
 Make Module partial to allow additional changed for Mono

5 years agoAnnotate EventCounter as a relocated type (dotnet/corert#6990)
Michal Strehovský [Mon, 11 Feb 2019 14:22:08 +0000 (15:22 +0100)]
Annotate EventCounter as a relocated type (dotnet/corert#6990)

This moved to CoreLib and needs to be annotated as such for Project N.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoMove Volatile to shared (#22523)
Stephen Toub [Mon, 11 Feb 2019 23:18:25 +0000 (18:18 -0500)]
Move Volatile to shared (#22523)

* Move Volatile to shared

This largely takes corert's implementation, which uses Unsafe.As and volatile fields.

We could investigate also removing the JIT's replacements subsequently.

* Add [Intrinsic] attributes

5 years agoLocally define DLLEXPORT in ee_il_dll.cpp
Russ Keldorph [Mon, 11 Feb 2019 19:42:29 +0000 (11:42 -0800)]
Locally define DLLEXPORT in ee_il_dll.cpp

This prevents a desktop build break due to DLLEXPORT being undefined.  If
you know of a better place to put this, I'm happy to try it.  Otherwise,
this should unblock the desktop build.

5 years agoMove runincontext to src/tools
Russ Keldorph [Sat, 9 Feb 2019 00:20:15 +0000 (16:20 -0800)]
Move runincontext to src/tools

This SDK-style project is causing problems on some machines with VS
installs that can't build it.  For now, move it to a place where it
doesn't build with the tests.

5 years agoMove GCHandle to shared (#22499)
Stephen Toub [Mon, 11 Feb 2019 21:52:51 +0000 (16:52 -0500)]
Move GCHandle to shared (#22499)

* Move GCHandle to shared

* Cache the handle in a local to make it easier for JIT to generate good code

* Rename m_handle to _handle to match the coding conventions

* Delete isPinned argument for GCHandleInternalCompareExchange

* Add fast path to GCHandle.Alloc/Free FCalls

* Disable outdated test

5 years agoUpdate master label to preview4
Russ Keldorph [Mon, 11 Feb 2019 16:06:30 +0000 (08:06 -0800)]
Update master label to preview4

5 years agoprestub: fix ExternalMethodFixupWorker (#22519)
Konstantin Baladurin [Mon, 11 Feb 2019 16:20:50 +0000 (19:20 +0300)]
prestub: fix ExternalMethodFixupWorker (#22519)

Use DispatchToken::CreateDispatchToken to get token to resolve
virtual method in case of non interface MT.

5 years agoMake Nullable partial to allow additional method for in under Mono (#22518)
Marek Safar [Mon, 11 Feb 2019 11:33:29 +0000 (12:33 +0100)]
Make Nullable partial to allow additional method for in under Mono (#22518)

5 years agoCleanup DLL exports (#22500)
Jan Kotas [Sun, 10 Feb 2019 21:57:11 +0000 (13:57 -0800)]
Cleanup DLL exports (#22500)

5 years agoFix casing of interop directories (dotnet/corert#6982)
Jan Kotas [Sun, 10 Feb 2019 02:45:30 +0000 (18:45 -0800)]
Fix casing of interop directories (dotnet/corert#6982)

Match convention introduced by https://github.com/dotnet/corefx/pull/35085

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoMove eventpipe buffer to TLS (#21817)
Sung Yoon Whang [Sun, 10 Feb 2019 02:25:10 +0000 (18:25 -0800)]
Move eventpipe buffer to TLS (#21817)

* start ripping out eventpipe buffer to tls

* can now emit events from gc threads

* cleanup

* more cleanup

* more cleanup

* tested on linux

* Addressing PR comments

* Move things around a bit to build in Linux

* change eventpipe buffer deallocation code

* more cleanup

* this while loop doesnt do anything now

* Fix build

* fixing build

* More cleanup

* more pr comments

* Fix unix build

* more pr comments

* trying to add a message to assertion that seems to be causing CIs to fail

* more pr feedback

* handle non-2-byte aligned string payloads inside payload buffers

* some more cleanup

* Fix off by one error in null index calculation

* Make Get/SetThreadEventBufferList a static member of ThreadEventBufferList

* make only the methods public in ThreadEventBufferList

* Addressing noah's comments

* fix comment and last off by 1 error

5 years agoset up CoreLib to include EventCounter in build project (#22501)
Sung Yoon Whang [Sun, 10 Feb 2019 02:23:33 +0000 (18:23 -0800)]
set up CoreLib to include EventCounter in build project (#22501)

5 years agoAdd reporting exception from ResolveEHClause (#17947)
Jan Vorlicek [Sat, 9 Feb 2019 15:07:14 +0000 (16:07 +0100)]
Add reporting exception from ResolveEHClause (#17947)

* Add reporting exception from ResolveEHClause

When an exception, like EEFileLoadException happens in the
ResolveEHClause, it was not caught by the runtime and so it caused exit
with `terminating with uncaught exception of type EEFileLoadException*`
message without any additional details.

This change adds catching the exception, reporting its details and call
stack and then failing fast.

* Change StackSString to SString

* Ensure the catch clause types are loaded before EH

In crossgen-ed images, ensure the types used in catch clauses are loaded
before the function containing these clauses is executed. That ensures
that a failure to load the EH clause type will occur at that time
instead of during the EH stack walking that searches for the catch
handler.

* Fix EH clause class module check

* Remove the EH clause class module check

It turns out that even if the class was from the current module, it may
depend on types from other modules, so we still need to add a fixup for
it.

5 years agomove EventCounter to shared CoreLib (dotnet/corefx#35183)
Sung Yoon Whang [Sat, 9 Feb 2019 03:58:24 +0000 (19:58 -0800)]
move EventCounter to shared CoreLib (dotnet/corefx#35183)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoMove Array's SZGenericArrayEnumerator to shared partition (#22480)
Marek Safar [Sat, 9 Feb 2019 04:11:21 +0000 (05:11 +0100)]
Move Array's SZGenericArrayEnumerator to shared partition (#22480)

* Move Array's SZGenericArrayEnumerator to shared partition

* Remove legacy comment

* Move all array enumerators to a new file

5 years agoDelete EnvironmentAugments (#22485)
Jan Kotas [Sat, 9 Feb 2019 04:10:38 +0000 (20:10 -0800)]
Delete EnvironmentAugments (#22485)

5 years agoSet visibility option to hidden (#21924)
Adeel Mujahid [Sat, 9 Feb 2019 01:24:59 +0000 (03:24 +0200)]
Set visibility option to hidden (#21924)

5 years agoBitOps.TrailingZeroCount has inconsistent software fallback (#22333)
Grant [Fri, 8 Feb 2019 23:46:14 +0000 (15:46 -0800)]
BitOps.TrailingZeroCount has inconsistent software fallback (#22333)

Fix #22326

5 years ago[Official Build] Remove FreeBSD builds (#22451)
Jarret Shook [Fri, 8 Feb 2019 20:04:51 +0000 (12:04 -0800)]
[Official Build] Remove FreeBSD builds (#22451)

Currently all the FreeBSD machines are offline or in an unclean state
which blocks official builds from finishing.

5 years agoRevert "Revert "Re-point Jenkins to new Ubuntu ARM64 queue""
Russ Keldorph [Fri, 8 Feb 2019 19:03:42 +0000 (11:03 -0800)]
Revert "Revert "Re-point Jenkins to new Ubuntu ARM64 queue""

This reverts commit d617f96303c4b65b7b77ff5fa0d7aee38ebc19f8.

5 years agoMove GCSettings to shared (#22483)
Stephen Toub [Fri, 8 Feb 2019 16:57:48 +0000 (11:57 -0500)]
Move GCSettings to shared (#22483)

Mainly just type definitions and error handling that gets shared.

5 years agoPass official build id to build (#22468)
Sven Boemer [Fri, 8 Feb 2019 16:34:54 +0000 (08:34 -0800)]
Pass official build id to build (#22468)

This ensures that coreclr gets a version number based on the build id.

5 years agoUpdate CoreRT with shared array implementation
Jan Kotas [Thu, 7 Feb 2019 23:20:46 +0000 (15:20 -0800)]
Update CoreRT with shared array implementation

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoUpdate BuildTools, CoreFx, CoreSetup to preview1-03706-01, preview.19106.8, preview...
dotnet-maestro-bot [Fri, 8 Feb 2019 16:12:20 +0000 (08:12 -0800)]
Update BuildTools, CoreFx, CoreSetup to preview1-03706-01, preview.19106.8, preview-27406-8, respectively (master) (#22455)

* Update BuildTools, CoreFx, CoreSetup to preview1-03706-01, preview.19106.8, preview-27406-8, respectively

* Disabling some outdated System.ObjectModel CoreFX tests

* Undo BuildTools update

5 years agoJIT: Suppress emitting same-reg zero extending move (#22454)
Andy Ayers [Fri, 8 Feb 2019 16:10:57 +0000 (08:10 -0800)]
JIT: Suppress emitting same-reg zero extending move (#22454)

Add a peephole optimization to suppress emitting zero extending moves
if the previous instruction has already done a suitable zero extension.

Only implemented for x64 currently.

Closes #21923

5 years agoJIT: fix ifdef guarding an assert (#22460)
Andy Ayers [Fri, 8 Feb 2019 16:09:57 +0000 (08:09 -0800)]
JIT: fix ifdef guarding an assert (#22460)

We use `_TARGET_AMD64_`, not `_TARGET_X64_`.

5 years agoForce results of rejected multi-reg-returning tail-call candidates to temp. (#22364)
Eugene Rozenfeld [Fri, 8 Feb 2019 08:14:35 +0000 (00:14 -0800)]
Force results of rejected multi-reg-returning tail-call candidates to temp. (#22364)

* Force results of rejected multi-reg-returning tail-call candidates to temp.

Issue #20269 ran into an assert when trying to merge returns, one of which
is a call to a multi-reg-returning method. The repro in the bug is a pmi
of `System.Reflection.Metadata`. I added a simple repro test case.

Results of calls to multi-reg-returning methods are expected to
be saved to temps. Normally it's ensured by `impFixupCallStructReturn`;
however, it doesn't do that for tail-call candidates.

This change forces results of calls to multi-reg-returning methods
to temps if the tail call is rejected late in morph.

Fixes #20269.

5 years agoFinish removing Environment from corefx
Stephen Toub [Wed, 6 Feb 2019 04:13:26 +0000 (23:13 -0500)]
Finish removing Environment from corefx

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
5 years agoFix the desktop warning (#22481)
Sergey Andreenko [Fri, 8 Feb 2019 06:01:50 +0000 (22:01 -0800)]
Fix the desktop warning (#22481)

5 years agoMove DateTime for Unix to shared partition (#22383)
Marek Safar [Fri, 8 Feb 2019 03:45:44 +0000 (04:45 +0100)]
Move DateTime for Unix to shared partition (#22383)

* Move DateTime for Unix to shared partition

* Keep CoreCLR specific implementation

5 years agoDisable more baseservices/threading/interlocked tests on Ubuntu.Arm64 (#22471)
Egor Chesakov [Fri, 8 Feb 2019 02:40:34 +0000 (18:40 -0800)]
Disable more baseservices/threading/interlocked tests on Ubuntu.Arm64 (#22471)

In the last two weeks the following tests have failed:

* baseservices/threading/interlocked/exchange/ExchangeTClass - 5 times
* baseservices/threading/interlocked/exchange/ExchangeTString - 13 times
* baseservices/threading/interlocked/exchange/ExchangeTString_1 - 12 times
* baseservices/threading/interlocked/exchange/ExchangeTString_2 - 20 times

In addition to the previously disabled tests (in #22304):

* baseservices/threading/interlocked/compareexchange/CompareExchangeTClass - 9 times
* baseservices/threading/interlocked/compareexchange/CompareExchangeTClass_1 - 32 times

All the failures happened on Ubuntu.1804.Arm64.Open Helix queue in Azure DevOps Pri1 jobs

**Related issue:** #22303

5 years agoFix race condition in g_pfnGetSystemTimeAsFileTime initialization (#22466)
Jan Kotas [Fri, 8 Feb 2019 02:35:15 +0000 (18:35 -0800)]
Fix race condition in g_pfnGetSystemTimeAsFileTime initialization (#22466)

Multiple threads initializing g_pfnGetSystemTimeAsFileTime at the same time can end up with different conclusions. Make the result consistent.

5 years agoAdd config option to disable tier 0 JIT (#22370)
Koundinya Veluri [Fri, 8 Feb 2019 01:51:29 +0000 (17:51 -0800)]
Add config option to disable tier 0 JIT (#22370)

Add config option to disable tier 0 JIT

Fixes https://github.com/dotnet/coreclr/issues/21856
- For methods that don't have pregenerated code, using tier 0 JIT can improve startup perf, and disabling tier 0 JIT can be useful to sacrifice some startup time to avoid issues of running tier 0 code for too long. In some cases, it may also be desirable to avoid tiering up much later.
- A fixed value for the call count indicates that tier 0 call counting is disabled. When disabled, the method starts at tier 1.
- Also modified call counting to start from a predetermined threshold and count down to zero, as it simplifies some things, allows for methods to have different thresholds, and likely is what we would want eventually anyway
- Took a small step towards eliminating knowledge of specific tier levels in code that should not care, though more is to be done there

5 years agoMerge pull request #22023 from BruceForstall/FixGSWithLocalloc
Bruce Forstall [Thu, 7 Feb 2019 23:19:06 +0000 (15:19 -0800)]
Merge pull request #22023 from BruceForstall/FixGSWithLocalloc

Fix ARM64 GS with localloc

5 years agoMore PAL layer cleanup for GNU and add build script support for GCC (#22369)
Sinan Kaya [Thu, 7 Feb 2019 21:39:13 +0000 (16:39 -0500)]
More PAL layer cleanup for GNU and add build script support for GCC (#22369)

* Declare throw only when compiling for c++

Prevent the definition from getting defined multiple times and
map it to throw() only when compiling c++ code.

* Suppress warnings for tests

Suppress:
 -Wno-write-strings
 -Wno-sign-compare
 -Wno-narrowing
 -fpermissive
 -Wno-int-to-pointer-cast

to allow tests to compile

* Add gcc option to build.sh script

Following clangx.y model add -gccx.y command line
arguments with gcc5 and gcc7 being the currnetly supported
options.

* Allow environment variable to be used for TOOLCHAIN

Remove CLANG specific compiler options as well.

* Hide non-GNU compiler options

* Do not include local directory if cross compiling

[  0%] Building CXX object src/pal/src/eventprovider/tracepointprovider/CMakeFiles/coreclrtraceptprovider.dir/__/lttng/traceptprovdotnetruntime.cpp.o
cc1plus: error: include location "/usr/local/include" is unsafe for cross-compilation [-Werror=poison-system-directories]

* Suppress unknown pragma warnings

src/pal/src/exception/seh-unwind.cpp:37:0:
warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas]
    #pragma clang diagnostic pop

Removing these cause compilation error on clang7 and arm as follows:

In file included from /bin/obj/Linux.arm.Debug/src/pal/src/libunwind/include/libunwind.h:9:
/src/pal/src/libunwind/include/libunwind-arm.h:247:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat]
typedef struct unw_tdep_save_loc
        ^
/src/pal/src/libunwind/include/libunwind-arm.h:288:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat]
typedef struct

* plt not useful for GNU and ARM64/ARM

src/pal/src/arch/arm64/callsignalhandlerwrapper.S: Assembler messages:
src/pal/src/arch/arm64/callsignalhandlerwrapper.S:31: Error: unexpected characters following instruction at operand 1 -- `bl signal_handler_worker@plt'
src/pal/src/arch/arm64/callsignalhandlerwrapper.S:32: Error: unexpected characters following instruction at operand 1 -- `bl signal_handler_worker@plt'

* Remove double const from argv in PAL_Initialize

Seeing compilation error with GNU for C source files as follows:

if (PAL_Initialize(argc, argv) != 0)
                          ^
src/pal/tests/palsuite/common/palsuite.h:21:0,
from src/pal/tests/palsuite/c_runtime/asinhf/test1/test1.c:18:
src/pal/inc/pal.h:374:1: note: expected ‘const char * const*’ but argument is of type ‘char **’

* Suppress format warnings using GNU for libunwind

warning: format ‘%li’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
     Debug (4, " aligned frame, offset %li\n", f->cfa_reg_offset);

* Fix -fpermissive warnings for GNU

* Suppress unused variable warning in libunwind

src/pal/src/libunwind/include/libunwind-aarch64.h:201:5: warning: right-hand operand of comma expression has no effect [-Wunused-value]
 #define unw_tdep_getcontext(uc) (({     \
                                 ~~~~~~~~~
   unw_tdep_context_t *unw_ctx = (uc);     \
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   register uint64_t *unw_base asm ("x0") = (uint64_t*) unw_ctx->uc_mcontext.regs;  \
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   __asm__ __volatile__ (      \
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x0, x1, [%[base], #0]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x2, x3, [%[base], #16]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x4, x5, [%[base], #32]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x6, x7, [%[base], #48]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x8, x9, [%[base], #64]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x10, x11, [%[base], #80]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x12, x13, [%[base], #96]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x14, x13, [%[base], #112]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x16, x17, [%[base], #128]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x18, x19, [%[base], #144]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x20, x21, [%[base], #160]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x22, x23, [%[base], #176]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x24, x25, [%[base], #192]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x26, x27, [%[base], #208]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "stp x28, x29, [%[base], #224]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "str x30, [%[base], #240]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      "mov x1, sp\n" \
      ~~~~~~~~~~~~~~~~
      "stp x1, x30, [%[base], #248]\n" \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      : [base] "+r" (unw_base) : : "x1", "memory"); \
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   }), 0)

* Fix warning: ‘memset’ used with length equal to number of elements warning

Fix similar warnings to these by including the element size into total size
calculation.

src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp: In function ‘int main(int, char**)’:
src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp:89:31: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
     memset(NewValue,0,BUF_SIZE);

* Define CLR specific compiler option CLR_CMAKE_COMPILER

By the time toolchain.cmake is called, the compiler detection from
cmake is not active. We need an intermediate definition to pass
to compiler detection.

5 years agoFix GCSample bit rot (#22462)
Jan Kotas [Thu, 7 Feb 2019 18:17:45 +0000 (10:17 -0800)]
Fix GCSample bit rot (#22462)

Fixes #22459