platform/upstream/dotnet/runtime.git
4 years agoImprove ProcessManager.Win (#32010)
Next Turn [Wed, 11 Mar 2020 15:48:50 +0000 (23:48 +0800)]
Improve ProcessManager.Win (#32010)

* ---- Style changes start here ----

* Remove unnecessary using directives

* Remove unnecessary assignments

* Use IntPtr.Zero

* Replace magic numbers

* Remove unused parameters

* Replace constructor with initializer

* Simplify delegate interop

* Inline temporary variables

* Remove unnecessary checked keyword

* Remove unnecessary cast

* Introduce using statement

* ---- Style changes end here ----

* Remove magic sleep

* Prealloc list

* Reduce copying

* Use ArrayPool

* Support long path

* Improve P/Invoke signatures

* Optimize modules enumeration

* Rename and move HandleLastWin32Error

* while (true)

* Move comments near codes

* Revert "Support long path"

This reverts commit 1f06435144925668e7273ec458e78b869aad6055.

* Revert "Introduce using statement"

This reverts commit e3d383a229c13b096dbdef9aa9c857ee6cf986e1.

* Revert "Remove magic sleep"

This reverts commit d8bc0017131a9d9d6c1f66569a87699f9f7faea6.

* Add braces

* Simplify initialization

* Fix last Win32 error

* Avoid reallocation if modules count decreased

* Nits

* Simplify codes

4 years agoRe-use StringBuilder inside iteration (#32759)
Alaa Masoud [Wed, 11 Mar 2020 14:59:59 +0000 (17:59 +0300)]
Re-use StringBuilder inside iteration (#32759)

* Re-use StringBuilder inside iteration

* another one

* Reuse StringBuilder in tools

* Revert accidental formatting

* pr feedback

* formatting

* 1 more

4 years agoMerge pull request #33455 from NikolaMilosavljevic/libicu65
Nikola Milosavljevic [Wed, 11 Mar 2020 14:22:00 +0000 (07:22 -0700)]
Merge pull request #33455 from NikolaMilosavljevic/libicu65

Add libicu65 to DEB deps package

4 years ago[arm] Fix branch island disassembly for arm64 and thumb. (#33469)
monojenkins [Wed, 11 Mar 2020 12:43:53 +0000 (08:43 -0400)]
[arm] Fix branch island disassembly for arm64 and thumb. (#33469)

Followup to https://github.com/mono/mono/pull/19126 and
https://github.com/mono/mono/pull/19169.

Bring arm64 `mono_arch_get_call_target` in line with other platforms by
returning NULL on failure instead of asserting. Bits 30-26 in an arm64
unconditional branch are exactly 0b00101, so 0x1f (0b11111) is used as a
mask to determine if the branch uses an immediate target--0x7 (0b111)
would incorrectly match against branches using register targets. The
extracted immediate is now sign extended in a branch-free way.

Avoid following blx entries in the method address table; ld64 can emit 4
different instruction sequences for islands involving thumb, and I'd
rather not implement support for them all now because 32-bit iOS is old
and large unlinked assemblies seem rare.

Co-authored-by: imhameed <imhameed@users.noreply.github.com>
4 years agoUpdate unwind.c to minimize usage of 'while (TRUE)' (#33107)
pi1024e [Wed, 11 Mar 2020 12:41:03 +0000 (08:41 -0400)]
Update unwind.c to minimize usage of 'while (TRUE)' (#33107)

There is no need to have a "while (TRUE)" statement if we can check at the end of the loop or at the beginning.

4 years ago[interp][32bit] Fix warning about precedence/parentheses. (#33468)
monojenkins [Wed, 11 Mar 2020 11:43:21 +0000 (07:43 -0400)]
[interp][32bit] Fix warning about precedence/parentheses. (#33468)

/s/mono2/mono/mini/interp/transform.c:3166:25: note: place parentheses around
      the '&&' expression to silence this warning
        if (mt >= MINT_TYPE_I1 && mt <= MINT_TYPE_I4
            ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years ago[mini] Fix warning about unused variables. (#33453)
monojenkins [Wed, 11 Mar 2020 09:18:02 +0000 (05:18 -0400)]
[mini] Fix warning about unused variables. (#33453)

/s/mono2/mono/mini/mini-generic-sharing.c:1415:9: warning: unused variable
      'param_names' [-Wunused-variable]
        char **param_names;

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years ago[wasm] Fix warnings about unused variables. (#33451)
monojenkins [Wed, 11 Mar 2020 09:14:21 +0000 (05:14 -0400)]
[wasm] Fix warnings about unused variables. (#33451)

/s/mono2/mono/metadata/sgen-mono.c:2883:16: warning: unused variable
      'last_major_gc_warned' [-Wunused-variable]
        static gint32 last_major_gc_warned = -1;
                      ^
/s/mono2/mono/metadata/sgen-mono.c:2884:16: warning: unused variable
      'num_degraded' [-Wunused-variable]
        static gint32 num_degraded = 0;
                      ^
/s/mono2/mono/metadata/sgen-mono.c:2886:9: warning: unused variable
      'major_gc_count' [-Wunused-variable]
        gint32 major_gc_count = mono_atomic_load_i32 (&mono_gc_stats.maj...
               ^

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years agoFix warnings about misleading indentation. (#33456)
monojenkins [Wed, 11 Mar 2020 09:12:18 +0000 (05:12 -0400)]
Fix warnings about misleading indentation. (#33456)

This is subtle and not actually misleading,
because it tends to be space tab or space tab, not wrong
number of tabs or significant wrong number of spaces.

/s/mono2/mono/metadata/class.c:4010:6: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
                                 if (mono_class_implement_interface_slo...

/s/mono2/mono/metadata/class.c:4039:3: warning: misleading indentation;
      statement is not part of the previous 'if' [-Wmisleading-indentation]
        if (m_class_is_delegate (target) && mono_class_has_variant_gener...

/s/mono2/mono/mini/driver.c:1780:4: warning: misleading indentation; statement
      is not part of the previous 'if' [-Wmisleading-indentation]
                if (strncmp (argv [i], "--debugger-agent=", 17) == 0) {

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years ago[wasm] Fix warnings about unused variables. (#33452)
monojenkins [Wed, 11 Mar 2020 09:09:08 +0000 (05:09 -0400)]
[wasm] Fix warnings about unused variables. (#33452)

/s/mono2/mono/mini/mini-runtime.c:2284:15: warning: unused variable 'ji'
      [-Wunused-variable]
        MonoJitInfo *ji;

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years agoImplement CBOR array support
Eirik Tsarpalis [Wed, 11 Mar 2020 05:39:51 +0000 (05:39 +0000)]
Implement CBOR array support

* Implement array support for CborWriter

* convert CborReader to class

* add CborReaderState enum

* Implement CborReader array support

* refactor reader tests

* add peek state assertions in happy path tests

* remove redundant assertion

* Update src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborReaderTests.Array.cs

Co-Authored-By: Jeremy Barton <jbarton@microsoft.com>
* Update src/libraries/System.Security.Cryptography.Encoding/tests/Cbor.Tests/CborWriterTests.Array.cs

Co-Authored-By: Jeremy Barton <jbarton@microsoft.com>
* address feedback

* styling

* BeginWriteArray -> WriteStartArray

* rename CborReaderState.EOF to CborReaderState.EndOfData

* add BytesRead and BytesWritten properties

* add an `Unknown` enum case for zero values

Co-authored-by: Jeremy Barton <jbarton@microsoft.com>
4 years agoDon't probe for A/W variants of entry points on non-Windows. (#33250)
Jeremy Koritzinsky [Wed, 11 Mar 2020 04:16:07 +0000 (21:16 -0700)]
Don't probe for A/W variants of entry points on non-Windows. (#33250)

* Don't probe for A/W variants of entry points on non-Windows.

* Cal PAL_GetProcAddressDirect directly on Unix.

* Remove dependence on A/W probing on non-Windows.

4 years agoRemove `AllocLHeap`. (#33402)
Vladimir Sadov [Wed, 11 Mar 2020 01:09:32 +0000 (18:09 -0700)]
Remove `AllocLHeap`. (#33402)

* The main difference of `AllocLHeap` is that it uses per-heap acontext instead of per-thread. There is no advantage in that and results in allocations under-reported in `GetAllocatedBytesForCurrentThread`

This change unifies to one allocation entry point - `Alloc` (and its `AllocAlign8` variety)

* Removed AllocAlign8

* PR feedback - some refactoring to merge duplicate calls to `Alloc`

* Splited an `ifdef/else`  in two to not cross code blocks.

* No need to update `GC_INTERFACE_MAJOR_VERSION` more than once per release. And we already did for this one.

4 years agoSave stack arguments size in InlinedCallFrame.m_Datum on x86 to handle callee's poppi...
Fadi Hanna [Tue, 10 Mar 2020 23:47:52 +0000 (16:47 -0700)]
Save stack arguments size in InlinedCallFrame.m_Datum on x86 to handle callee's popping of arguments (#33249)

* Save stack arguments size in InlinedCallFrame.m_Datum on x86 to handle callee's popping of arguments

4 years agoAdd libicu65 to DEB deps
Nikola Milosavljevic [Tue, 10 Mar 2020 22:32:07 +0000 (22:32 +0000)]
Add libicu65 to DEB deps

4 years agoRevert "Enable restore for ref and src projects in libraries (#33242)" (#33437)
Viktor Hofer [Tue, 10 Mar 2020 20:33:27 +0000 (21:33 +0100)]
Revert "Enable restore for ref and src projects in libraries (#33242)" (#33437)

This reverts commit 981cc64bc42eeed5c5634ad8f3680398039603cc.

4 years agoImplement Marshal.GetIDispatchForObject on platforms with COM support (#33403)
Elinor Fung [Tue, 10 Mar 2020 19:24:48 +0000 (12:24 -0700)]
Implement Marshal.GetIDispatchForObject on platforms with COM support (#33403)

4 years agoAdd XML doc comments for Get/SetRawSocketOption (#33390)
Stephen Toub [Tue, 10 Mar 2020 18:07:28 +0000 (14:07 -0400)]
Add XML doc comments for Get/SetRawSocketOption (#33390)

* Add XML doc comments for Get/SetRawSocketOption

I neglected to add XML doc comments for these new APIs in previous PR.  Fixing that.

* Update src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs

Co-Authored-By: Günther Foidl <gue@korporal.at>
Co-authored-by: Günther Foidl <gue@korporal.at>
4 years agoFix getting time zone names with Invariant Culture (#33318)
Tarek Mahmoud Sayed [Tue, 10 Mar 2020 16:38:34 +0000 (09:38 -0700)]
Fix getting time zone names with Invariant Culture (#33318)

* Fix getting time zone names with Invariant Culture

* Address the feedback

* Restrict the test to English languages only.

* Fix misspelling

* Remove un-needed line

4 years agoMove JIT documentation to new docs/design/coreclr/jit directory (#33321)
Bruce Forstall [Tue, 10 Mar 2020 15:53:57 +0000 (08:53 -0700)]
Move JIT documentation to new docs/design/coreclr/jit directory (#33321)

Reduce clutter in the shared directory, and make it easier to find
all the JIT-related documentation.

4 years agoFix very minor typo (#33423)
tub5 [Tue, 10 Mar 2020 15:11:02 +0000 (15:11 +0000)]
Fix very minor typo (#33423)

Co-authored-by: Ben Rothermel <ben.rothermel@tocabot.io>
4 years ago[mono] Include filename in Invalid image error messages (#33117)
Mitchell Hwang [Tue, 10 Mar 2020 14:48:36 +0000 (10:48 -0400)]
[mono] Include filename in Invalid image error messages (#33117)

* [mono] Include filename in Invalid Image message

* [mono] Rename Invalid Image to File Not Found where applicable

* [Mono] Remove ActiveIssue attributes 31649 and 31650

* Touch up callers of mono_error_set_simple_file_not_found in appdomain.c

* Specify file name in mono_error_set_simple_file_not_found reflection_only message

* Touch up mono_error_set_file_not_found callers in icall.c

* Include image name in mono_error_set_bad_image_by_name calls in metadata.c

* Include aot name in mono_error_set_bad_image_by_name calls in aot-runtime.c

Co-authored-by: Mitchell Hwang <mihw@microsoft.com>
Co-authored-by: Mitchell Hwang <mitchell.hwang@microsoft.com>
4 years ago[mono] Disable SIMD support for Windows target (#33421)
Egor Bogatov [Tue, 10 Mar 2020 13:45:23 +0000 (16:45 +0300)]
[mono] Disable SIMD support for Windows target (#33421)

A temp fix for #1933.

4 years agoEnable restore for ref and src projects in libraries (#33242)
Viktor Hofer [Tue, 10 Mar 2020 12:48:20 +0000 (13:48 +0100)]
Enable restore for ref and src projects in libraries (#33242)

* Enable restore for projects in libraries

Enabling project restore for ref and src projects

* Remove winrt.depproj

* Remove tools.depproj

* Enable upfront restore

* Fix casing of PInvokeAnalyzerException file

* Remove harvestPackages.depproj and refactoring

Removing havestPackages.depproj in favor of a target that is hooked
into Arcade's repo restore phase in Tools.props.

Additionally moving common properties that are used both in Arcade and
the repo inside Configurations.props. Before they were scattered around
multiple places (Versions.props, Subsets.props).

* Set ilasm/ildasm RID for restore

* Sequence restore into steps out of upfront restore

* Fix docker entrypoints by using build.cmd/sh

4 years ago[interp] Add EXCEPTION_CHECKPOINT to MINT_JMP consistent with other method tranform...
monojenkins [Tue, 10 Mar 2020 12:00:53 +0000 (08:00 -0400)]
[interp] Add EXCEPTION_CHECKPOINT to MINT_JMP consistent with other method tranform paths. (#33359)

Co-authored-by: jaykrell <jaykrell@users.noreply.github.com>
4 years agoConvert PLT table and call site to execute only on AMD64. (#33120)
monojenkins [Tue, 10 Mar 2020 11:20:11 +0000 (07:20 -0400)]
Convert PLT table and call site to execute only on AMD64. (#33120)

Current implementation embedded critical runtime information directly into PLT slot. It also depends on finding call site in generic trampoline reading call target from instruction stream in order to locate PLT slot in use and then read GOT offset as well as PLT info offset from PLT slot instruction stream.

This is problematic on platforms where code is execute only. Fix changes how the metadata needed in order to correctly patch PLT is discovered. Instead of depending on reading instruction stream, it is loaded into RAX (free to be used when calling through PLT on AMD64) in PLT slot before jmp takes place that moves control over to generic trampoline.

The PLT slot is the only place where we have access to both GOT index (used in jmp), PLT info offset (currently embedded after jmp instruction) and emitted PLT slot index. Since PLT slot index can be used to recover GOT offset used by PLT slot as well as PLT info offset at runtime, PLT slot index will be emitted into instruction stream and loaded into RAX (prepared to be configurable to other reg if needed) before doing the jump over to generic trampoline. Size of emitted imm constant is optimized based on number of total PLT slots used in image, meaning that 1, 2, or 4 bytes could be used to store PLT slot index as an imm constant in instruction stream. The additional jmp should have minimal to no performance overhead since it should complete within 1 cycle, reading imm constant from instruction stream that shouldn’t incur additional cache misses and sine there is no data dependency between mov and jmp, there should be options to pipeline both instructions.  Since mov has smaller latency than indirect jmp, mov should be complete once control gets into the generic tramp (if pipelined).

In order to resolve plt info offset at runtime, needed information is now emitted as part of got_info_offsets, increase table with 4 bytes/plt slot, same size currently emitted into the PLT slot instruction stream.

Code size of PLT slot is currently 10 bytes (6 bytes jmp and 4 byte PLT info offset). Since PLT info offset has been moved into got_info_offset table, size of PLT slot will be 2, 4, 5 byte mov (depending on needed imm size) and 6 bytes jmp instruction. As an example, mscorlib can emit all its PLT slots using 2 byte imm constant, meaning that the PLT slot will still be 10 bytes, but since PLT info offset of 4 bytes is moved into got_info_offset, total image increase will be 4 bytes/PLT slot. This is however still cheaper than alternatives that would burn 1 trampoline/PLT slot (at least 10 additional bytes/slot) or setup lookup tables in image or calculate more info at runtime, all-consuming more memory in total.

Note, using this approach is optional and runtime needs to be built using MONO_ARCH_CODE_EXEC_ONLY in order to enable it since it’s only an opt in features on platforms that can't read from instructions stream.

Current implementation is AMD64 only, but same pattern could be applied to other architectures when needed.

Co-authored-by: lateralusX <lateralusX@users.noreply.github.com>
4 years agoFix overaggressive CanBeMadeAtomic check for Set + Notone (#33405)
Stephen Toub [Tue, 10 Mar 2020 10:51:07 +0000 (06:51 -0400)]
Fix overaggressive CanBeMadeAtomic check for Set + Notone (#33405)

We're erroneously converting a set loop to be atomic when it's followed by a notone where the notone's character is in the set.  But if we for example have `[ab]*[^a]`, we can't make the loop atomic, because the `[ab]*` can actually give back something (a `b`) that the `[^a]` will match.  The fix is simply to delete the erroneous, overaggressive checks.

4 years ago[Mono] Intrinsify Interlocked.And and Interlocked.Or using LLVM (#33253)
Egor Bogatov [Tue, 10 Mar 2020 08:49:05 +0000 (11:49 +0300)]
[Mono] Intrinsify Interlocked.And and Interlocked.Or using LLVM (#33253)

* Intrinsify Interlocked.And and Interlocked.Or

4 years agoFix misleading-indentation compilation error under clang 10 (#33406)
Omair Majid [Tue, 10 Mar 2020 07:13:14 +0000 (03:13 -0400)]
Fix misleading-indentation compilation error under clang 10 (#33406)

The error looks like this (seen in dotnet/coreclr repo):

    In file included from /root/coreclr/src/ildasm/dasm_mi.cpp:7:
    /root/coreclr/src/ildasm/exe/../../tools/metainfo/mdinfo.cpp:1951:9: error: misleading indentation; statement is not part of the previous 'if' [-Werror,-Wmisleading-indentation]
        if (!wcscmp(W("__DecoratedName"), rcName))
        ^
    /root/coreclr/src/ildasm/exe/../../tools/metainfo/mdinfo.cpp:1947:5: note: previous statement is here
if (pSig && pMethName)
^
    1 error generated.

4 years agoMark PerformanceCounter_PerformanceData is a stress test. (#33410)
Tarek Mahmoud Sayed [Tue, 10 Mar 2020 07:12:09 +0000 (00:12 -0700)]
Mark PerformanceCounter_PerformanceData is a stress test. (#33410)

This is done to avoid running this test by default which can cause a timeout in CI.

4 years agoDelete porting_guide (#33411)
Jan Kotas [Tue, 10 Mar 2020 05:48:46 +0000 (22:48 -0700)]
Delete porting_guide (#33411)

The live version of the porting guide with a lot more details lives at https://docs.microsoft.com/en-us/dotnet/standard/serialization/system-text-json-migrate-from-newtonsoft-how-to

4 years agoAdd License Header to Installer Test Assets (#33408)
Swaroop Sridhar [Tue, 10 Mar 2020 01:48:00 +0000 (18:48 -0700)]
Add License Header to Installer Test Assets (#33408)

D:\git\_runtime\src\installer\test\Assets\TestProjects\... files were missing licence headers.
This change adds them.

4 years agoConsolidate objcopy detection (#33342)
Adeel Mujahid [Tue, 10 Mar 2020 00:08:21 +0000 (02:08 +0200)]
Consolidate objcopy detection (#33342)

4 years ago[jit] Implement support for all Sse1 intrinsics for netcore. (#33356)
Zoltan Varga [Mon, 9 Mar 2020 22:37:37 +0000 (18:37 -0400)]
[jit] Implement support for all Sse1 intrinsics for netcore. (#33356)

* [jit] Implement support for all Sse1 intrinsics for netcore.

* Add generic OP_XOP opcodes for opcodes which the JIT doesn't care about.
  Add a SimdOp enum to list the operations performed by these opcodes.
* Add a SimdIntrinsic struct so the mapping between the .net methods
  and the JIT opcodes can be specified declaratively.
* Add all intrinsics from the Sse class.

* Fix UnpackHigh/UnpackLow.

* Implement missing load/store intrinsics.

* Implement missing opcodes.

* Fix nontemporal metadata.

* Fix MOVNTPS alignment..

* Fix OP_XOP_X_X.

4 years agoDisable IBCMerge on OSX builds (#33393)
Jeremy Koritzinsky [Mon, 9 Mar 2020 22:37:24 +0000 (15:37 -0700)]
Disable IBCMerge on OSX builds (#33393)

* Disable System.Private.CoreLib IBCMerge on MacOS.

* Disable IBCMerge on mac across the board.

* Update comment to include link to issue.

4 years agoCalculate log path after build type is set (#33196)
Juan Hoyos [Mon, 9 Mar 2020 22:24:01 +0000 (15:24 -0700)]
Calculate log path after build type is set (#33196)

4 years agoAnnotate System.Net.NetworkInformation for nullable (#32990)
buyaa-n [Mon, 9 Mar 2020 22:02:21 +0000 (15:02 -0700)]
Annotate System.Net.NetworkInformation for nullable (#32990)

* Annotate System.Net.NetworkInformation for nullable

4 years agoSimplify codeman (#33380)
pi1024e [Mon, 9 Mar 2020 21:30:26 +0000 (17:30 -0400)]
Simplify codeman (#33380)

4 years agoRemove duplicated entries (#33371)
pi1024e [Mon, 9 Mar 2020 21:14:27 +0000 (17:14 -0400)]
Remove duplicated entries (#33371)

4 years agoUpdate SDK to 5.0.100-preview.2.20157.1 (#33396)
Viktor Hofer [Mon, 9 Mar 2020 20:51:07 +0000 (21:51 +0100)]
Update SDK to 5.0.100-preview.2.20157.1 (#33396)

This contains the Microsoft.Build.NuGetSdkResolver change with the commit 64f2febf7d1de8b0228eca5afed97a96c5a30bba. This fixes the flaky nuget restore issues.

4 years ago[arm][ios] Follow branch islands when determining method entry addresses. (#33182)
monojenkins [Mon, 9 Mar 2020 19:31:17 +0000 (15:31 -0400)]
[arm][ios] Follow branch islands when determining method entry addresses. (#33182)

Fixes https://github.com/mono/mono/issues/18612; `aot_code_low_addr` and
`aot_code_high_addr` were set to a range that included only first-level
branch islands, so `find_aot_module` would fail early when passed a
genuine function address.

This change only affects monotouch for now.

Why not use relative offsets stored in a read-only section? One reason
is that llvm-as cannot handle a `.long` directive containing a
subtraction expression involving externally-defined symbols. The AOT
method address table and AOT LLVM-generated code are currently emitted
in separate object files, so the method address table would include
expressions with undefined symbols.

Related: https://xamarin.github.io/bugzilla-archives/70/707/bug.html

Co-authored-by: imhameed <imhameed@users.noreply.github.com>
4 years agoNo need to force to bool, when C does that automatically in the if statement. (#33045)
pi1024e [Mon, 9 Mar 2020 19:28:57 +0000 (15:28 -0400)]
No need to force to bool, when C does that automatically in the if statement. (#33045)

In C, the if statement checks if the value is 0 or not 0. !!, or forcing to 1 or 0, is unnecessary here.

4 years agoRevert "Revert "Dynamic generic dictionary expansion feature (#32270) (#33343)
Jan Kotas [Mon, 9 Mar 2020 17:34:36 +0000 (10:34 -0700)]
Revert "Revert "Dynamic generic dictionary expansion feature (#32270) (#33343)

* Revert "Revert "Dynamic generic dictionary expansion feature (#32270)" (#33310)"

This reverts commit dca34293ad3741dfa4a4f7b81ac821d28460801e.

* Fix race condition in dynamic dictionary resizing

4 years agoRemove redundant mono_gc_collect during domain unload (#33229)
monojenkins [Mon, 9 Mar 2020 15:49:12 +0000 (11:49 -0400)]
Remove redundant mono_gc_collect during domain unload (#33229)

During unload_thread_main, **mono_gc_collect** is called 3 times.

First: https://github.com/mono/mono/blob/280e9d2423549d86686716f0818bcdbac9702ea1/mono/metadata/gc.c#L455

Second: https://github.com/mono/mono/blob/b4c506c3045516349d03ce8f3fe9fa5b79a7271c/mono/metadata/appdomain.c#L3305

Third: https://github.com/mono/mono/blob/b4c506c3045516349d03ce8f3fe9fa5b79a7271c/mono/metadata/appdomain.c#L3324

This PR #ifdefs the Second GC Collect for Boehm as it does not use remsets, and removes the third one completely.

The comment for the second gc_collect existence mentions that:

> We need to make sure that we don't have any remsets pointing into static data...(cont)
> However, Unity uses Boehm so it can be defined out.

There seems to be no good reason for the third GC collect, as it is already called before in mono_domain_finalize, It seems like it doesn't do anything using Visual Studio Profiler to check the heap size before and after the gc_collect. **mono_get_heap_size** also remains the same before and after as well (for the second and third at least).

Co-authored-by: Rares95 <Rares95@users.noreply.github.com>
4 years agoRespect -runtimeconfiguration with -vs switch (#33355)
Viktor Hofer [Mon, 9 Mar 2020 14:15:58 +0000 (15:15 +0100)]
Respect -runtimeconfiguration with -vs switch (#33355)

When using the -vs switch, the -runtimeconfiguration value will now be
respected so that building with mixed configurations between libraries
and the runtime inside VS is possible.

4 years agoms-vscode.csharp to ms-dotnettools.csharp (#33354)
Mattias Karlsson [Mon, 9 Mar 2020 13:00:22 +0000 (14:00 +0100)]
ms-vscode.csharp to ms-dotnettools.csharp (#33354)

C# extension has changed its name from "ms-vscode.csharp" to "ms-dotnettools.csharp".

4 years agoFix ARM64 intrinsic namespace in crossgen and crossgen2 (#32942)
Anton Lapounov [Mon, 9 Mar 2020 10:15:04 +0000 (03:15 -0700)]
Fix ARM64 intrinsic namespace in crossgen and crossgen2 (#32942)

We did not update the hard-coded intrinsic namespace in crossgen and crossgen2 when moved ARM64 intrinsics to a different namespace.

4 years agoWorkaround inefficient codegen for thread statics in latest MSVC (#33347)
Jan Kotas [Mon, 9 Mar 2020 06:50:05 +0000 (23:50 -0700)]
Workaround inefficient codegen for thread statics in latest MSVC (#33347)

GetThread() is no longer getting in latest MSVC and includes unnecessary call
to __dyn_tls_on_demand_init. Removing the extern "C" and applying a __declspec(selectany)
makes the compiler to generate same code as before.

Fixes for #33341

4 years agoGCC compilation fixes (#33345)
Sinan Kaya [Mon, 9 Mar 2020 04:37:23 +0000 (00:37 -0400)]
GCC compilation fixes (#33345)

* Multiply defined

* Cast to size_t

* operator precedence

4 years agoDelete .NET Framework-specific hosting flags (#33353)
Jan Kotas [Mon, 9 Mar 2020 03:56:18 +0000 (20:56 -0700)]
Delete .NET Framework-specific hosting flags (#33353)

There is only one way to host CoreCLR. These hosting flags always ended up being set the same way in CoreCLR.

4 years agoDelete dead code (#33348)
Jan Kotas [Mon, 9 Mar 2020 03:55:20 +0000 (20:55 -0700)]
Delete dead code (#33348)

* Delete remoting left-overs

* Delete StressOn

* Delete API thread stress

* Delete unused variables

* Delete REGUTIL::s_fUseRegistry

4 years agoMerge pull request #33306 from NikolaMilosavljevic/osx.version
Nikola Milosavljevic [Sun, 8 Mar 2020 21:41:33 +0000 (14:41 -0700)]
Merge pull request #33306 from NikolaMilosavljevic/osx.version

Change minimum required OSX version to 10.13

4 years agoFix the guid for the transaction (#32573)
Saurabh Singh [Sun, 8 Mar 2020 07:03:34 +0000 (23:03 -0800)]
Fix the guid for the transaction (#32573)

* Fix the guid for the transaction

* Remove unused using

* Remove duplicate interfaces

* Release the com objects after we are done using them

4 years agoRemove my ownership of System.Reflection.Metadata (#33340)
Nick Guerrera [Sat, 7 Mar 2020 20:56:06 +0000 (12:56 -0800)]
Remove my ownership of System.Reflection.Metadata (#33340)

4 years agoDelete unnecessary CLSCompliant attributes (#33326)
Jan Kotas [Sat, 7 Mar 2020 20:55:36 +0000 (12:55 -0800)]
Delete unnecessary CLSCompliant attributes (#33326)

All members of non-CLSCompliant types are non-CLSCompliant

4 years agoJIT: remove GTF_INX_REFARR_LAYOUT (#33098)
Andy Ayers [Sat, 7 Mar 2020 18:34:05 +0000 (10:34 -0800)]
JIT: remove GTF_INX_REFARR_LAYOUT (#33098)

When morphing `GT_INDEX` nodes, we were inadvertently also setting
`GTF_IND_NONFAULTING` for the `GT_IND` subtree for ref type arrays, because
`GTF_IND_NONFAULTING` has the same value as `GTF_INX_REFARR_LAYOUT`.

This turns out to be safe since in general there is an upstream bounds check to
cover the null check from the indexing operation, so the fact that we were
claiming the `GT_IND` can't fault is ok.

A no diff change would remove the `GTF_INX_REFARR_LAYOUT` flag and then modify
`fgMorphArrayIndex` to set `GTF_IND_NONFAULTING` for ref type arrays with bounds
checks:
```
    // If there's a bounds check, the the indir won't fault.
    if (bndsChk && (tree->gtType == TYP_REF))
    {
        tree->gtFlags |= GTF_IND_NONFAULTING;
    }

    tree->gtFlags |= GTF_EXCEPT;
```

But there's no good reason to limit the above change to ref type arrays and no
good reason to OR in `GTF_EXCEPT` when there are bounds checks.

Closes #32647.

4 years agoFix test for COM + dynamic keyword (#33334)
Elinor Fung [Sat, 7 Mar 2020 17:20:03 +0000 (09:20 -0800)]
Fix test for COM + dynamic keyword (#33334)

4 years agoImplement new COM interop API for RCW/CCW creation/management (#32091)
Aaron Robinson [Sat, 7 Mar 2020 07:37:47 +0000 (23:37 -0800)]
Implement new COM interop API for RCW/CCW creation/management (#32091)

* Implement RuntimeHelpers.AllocateTypeAssociatedMemory().

* Add tests for RuntimeHelpers.AllocateTypeAssociatedMemory().

* Implement ComWrappers API.

* Add tests for ComWrappers API.

* Add a FEATURE_COMWRAPPERS feature flag.

4 years ago[llvm] Move intrinsics definitions into a template header file llvm-intrinsics.h...
monojenkins [Sat, 7 Mar 2020 05:49:07 +0000 (00:49 -0500)]
[llvm] Move intrinsics definitions into a template header file llvm-intrinsics.h. (#33235)

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
4 years agoFix artifact paths in doc (#33324)
Next Turn [Sat, 7 Mar 2020 04:50:42 +0000 (12:50 +0800)]
Fix artifact paths in doc (#33324)

4 years agoDon't inline StelemRef_Helper. (#33319)
Eugene Rozenfeld [Sat, 7 Mar 2020 04:49:18 +0000 (20:49 -0800)]
Don't inline StelemRef_Helper. (#33319)

Under some jit stress modes the jit tries to inline StelemRef_Helper into
StelemRef. StelemRef is jitted very early and the jit is not yet prepared
to handle this inline.

Fixes #33298.

4 years agoin a case of error reporting `load_library` should pass `char*`, not `string_t` ...
Vladimir Sadov [Sat, 7 Mar 2020 04:21:18 +0000 (20:21 -0800)]
in a case of error reporting `load_library` should pass `char*`, not `string_t` (#33323)

4 years agoenable Path tests (#33313)
Anirudh Agnihotry [Sat, 7 Mar 2020 01:24:28 +0000 (17:24 -0800)]
enable Path tests (#33313)

4 years agoenable tests (#33314)
Anirudh Agnihotry [Sat, 7 Mar 2020 01:24:00 +0000 (17:24 -0800)]
enable tests (#33314)

4 years agoRevert "Dynamic generic dictionary expansion feature (#32270)" (#33310)
Fadi Hanna [Sat, 7 Mar 2020 01:00:48 +0000 (17:00 -0800)]
Revert "Dynamic generic dictionary expansion feature (#32270)" (#33310)

This reverts commit 718255964a078883e49ba2c06dfa739aadbfea3b.

4 years agoRuntime composite support, 2nd attempt (fixing DAC) (#33304)
Tomáš Rylek [Sat, 7 Mar 2020 00:59:23 +0000 (01:59 +0100)]
Runtime composite support, 2nd attempt (fixing DAC) (#33304)

[2nd attempt after the initial version was rolled back]

This change changes CoreCLR runtime to support running
composite R2R apps with standalone MSIL produced by
Crossgen2. It introduces the new concept of a NativeImage
representing the composite R2R with native executable header
and adds basic support for loading these native images
upon loading the original MSIL assemblies and for using
the R2R code information therein as the native code cache
for the component MSIL assemblies.

Thanks

Tomas

4 years agoUse lib prefix in all native library names (#33236)
Adeel Mujahid [Sat, 7 Mar 2020 00:32:36 +0000 (02:32 +0200)]
Use lib prefix in all native library names (#33236)

Also consolidated related MSBuild properties in
`/eng/native/naming.props` file.

4 years agoRemove "Interop.winsock" from platform-agnostic Socket tracing (#33289)
Stephen Toub [Sat, 7 Mar 2020 00:30:02 +0000 (19:30 -0500)]
Remove "Interop.winsock" from platform-agnostic Socket tracing (#33289)

This tracing could stand to be overhauled in general, but for now I'm cleaning up the Windows-specific references in the platform-agnostic tracing.

4 years agoTemporarily disable Interop\COM\Dynamic test on x86 (#33301)
Elinor Fung [Sat, 7 Mar 2020 00:10:46 +0000 (16:10 -0800)]
Temporarily disable Interop\COM\Dynamic test on x86 (#33301)

4 years agoEnable starting SampleProfiler from startup EventPipe session (#33200)
Sung Yoon Whang [Fri, 6 Mar 2020 23:10:00 +0000 (15:10 -0800)]
Enable starting SampleProfiler from startup EventPipe session (#33200)

* Enable SampleProfiler to be enabled from startup

* Remove EventPipeController.cs

* PR feedback

4 years agoImprove stack overflow stack trace dumping (#33281)
Jan Vorlicek [Fri, 6 Mar 2020 22:48:35 +0000 (23:48 +0100)]
Improve stack overflow stack trace dumping (#33281)

It was discovered that the stack overflow stack trace dumping to console
doesn't work properly in some cases due to the fact that there was not
enough stack space left to display more complex method signatures on the
call stack.

To remove such fragility, this change updates the stack trace dumping by
running the actual dumping and stack walking on a new thread and
waiting for its completion. That means that we should be able to dump
any stack trace reliably.

4 years agoMerge pull request #32669 from steveharter/NullConvertersAndNotSupportedException
Steve Harter [Fri, 6 Mar 2020 22:46:48 +0000 (16:46 -0600)]
Merge pull request #32669 from steveharter/NullConvertersAndNotSupportedException

Don't allow null converters and add Path support to NotSupportedException

4 years agoReduce thread consumption for sync HTTP/2 reads (#32917)
Stephen Toub [Fri, 6 Mar 2020 22:38:39 +0000 (17:38 -0500)]
Reduce thread consumption for sync HTTP/2 reads (#32917)

The response Stream returned from SocketsHttpHandler.SendAsync supports all of the various forms of read operations, including synchronous reads.

For HTTP/1.x, we're able to implement these as sync all the way down to synchronous calls on the underlying Socket, as every request/response owns its own connection (at least for the duration of the operation; the connection may be returned to the pool for subsequent reuse after).

For HTTP/2, however, a single connection is shared across all requests multiplexed onto it, and as such, reads on those individual responses need to coordinate, which can mean waiting one's turn.  Such waiting for asynchronous operations is implemented via async/await and a ManualResetValueTaskSource-based implementation.  For the sync operations, though, they're implemented as simply blocking waiting on the async equivalent, aka sync-over-async.  This not only blocks the calling thread, but because the MRVTS-based implementation specifies RunContinuationsAsynchronously==true (which is important for reliability with how the async code paths are structured) it means that, in order to unblock this waiter, another thread pool thread needs to be available to run the small continuation that will in turn unblock the sync primitive being blocked on.

This PR tweaks the use of MRVTS so that when we perform a synchronous read, we set MRVTS.RunContinuationsAsynchronously to false.  Since the only action that will be taken as part of the continuation is to set a sync primitive, we don't need to worry about arbitrary code running as part of the completing call stack.  This in turn means that in the common case, sync reads will still end up blocking the calling thread _but_ won't require an additional thread pool thread to unblock it, other than for the task running the main connection loop.

4 years agoAdd Socket.Get/SetRawSocketOption (#33261)
Stephen Toub [Fri, 6 Mar 2020 22:35:39 +0000 (17:35 -0500)]
Add Socket.Get/SetRawSocketOption (#33261)

4 years agoChange minimum required OSX version to 10.13
Nikola Milosavljevic (CLR) [Fri, 6 Mar 2020 22:07:28 +0000 (14:07 -0800)]
Change minimum required OSX version to 10.13

4 years agoFix uname usage and add binlogs (#33223)
Juan Hoyos [Fri, 6 Mar 2020 20:20:08 +0000 (12:20 -0800)]
Fix uname usage and add binlogs  (#33223)

* Add binlogs back to PGO reads and native version header generation
* Use POSIX compliant `uname -m`

4 years agoFix error logging in referenceFromRuntime.targets (#33290)
Viktor Hofer [Fri, 6 Mar 2020 19:34:03 +0000 (20:34 +0100)]
Fix error logging in referenceFromRuntime.targets (#33290)

The RuntimeProjectFile property is used in the FilterReferenceFromRuntime target for error logging but is only available in the AddRuntimeProjectReference target. Moving this out onto the project level.

4 years agoUpdate SDK version to 5.0.100-preview.2.20155.14 (#33277)
Juan Hoyos [Fri, 6 Mar 2020 17:53:07 +0000 (09:53 -0800)]
Update SDK version to 5.0.100-preview.2.20155.14 (#33277)

4 years agoupdate branding to preview3 (#33262)
Anirudh Agnihotry [Fri, 6 Mar 2020 17:30:25 +0000 (09:30 -0800)]
update branding to preview3 (#33262)

4 years agoCorrects interim prerelease version for Extensions packages (#33278)
Maryam Ariyan [Fri, 6 Mar 2020 17:20:50 +0000 (09:20 -0800)]
Corrects interim prerelease version for Extensions packages (#33278)

4 years agoPrevent null converters and add Path support to NotSupportedException
Steve Harter [Fri, 21 Feb 2020 18:40:55 +0000 (12:40 -0600)]
Prevent null converters and add Path support to NotSupportedException

4 years agoFix re-declations of builtin functions with clang 10 (#32837)
Omair Majid [Fri, 6 Mar 2020 14:50:28 +0000 (09:50 -0500)]
Fix re-declations of builtin functions with clang 10 (#32837)

Clang commit 39aa8954a4846b317d3da2f0addfce8224b438de has moved
exception handling mismatches under the -fms-compatibility flag. This
breaks compilation of pal under clang 10 (and newer).

The compilation error looks like this:

In file included from .../pal/src/misc/tracepointprovider.cpp:19:
In file included from .../pal/src/include/pal/palinternal.h:620:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/stdlib.h:30:
/usr/include/stdlib.h:112:36: error: exception specification in declaration does not match previous declaration
__extension__ extern long long int atoll (const char *__nptr)
                                   ^
.../pal/inc/pal.h:4227:33: note: previous declaration is here
PALIMPORT long long int __cdecl atoll(const char *) THROW_DECL;
                                ^

The simplest fix seems to be to make clang do the same thing as gcc and
define THROW_DECL as 'throw()'.

Testing via https://godbolt.org shows that even clang 3.3 compiles this
successfully without additional compiler options:

    extern "C" long long atoll(char const*) throw();
    #include <stdlib.h>

An alternative fix would be to use -fms-compatibility.

More details at https://bugzilla.redhat.com/show_bug.cgi?id=1807176

4 years agoSupport rodata relocations in crossgen2 for ARM32 (#33153)
Dong-Heon Jung [Fri, 6 Mar 2020 14:09:55 +0000 (23:09 +0900)]
Support rodata relocations in crossgen2 for ARM32 (#33153)

4 years agoChanged signedness of iterator to fix warnings. (#32742)
pi1024e [Fri, 6 Mar 2020 13:19:02 +0000 (08:19 -0500)]
Changed signedness of iterator to fix warnings. (#32742)

numOperands is an unsigned integer. In addition, getArgOperand has unsigned int arguments. As a result, I have no idea why i is an int, but to fix compiler warnings, I made it an unsigned int.

4 years ago[jit] Use OP_EXTRACT_R4 in simd-intrinsics.c when using LLVM. (#33213)
monojenkins [Fri, 6 Mar 2020 12:32:39 +0000 (07:32 -0500)]
[jit] Use OP_EXTRACT_R4 in simd-intrinsics.c when using LLVM. (#33213)

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
4 years agoRemove more OSGroup usages from src/mono (#33247)
Alexander Köplinger [Fri, 6 Mar 2020 11:03:08 +0000 (12:03 +0100)]
Remove more OSGroup usages from src/mono (#33247)

* Remove more OSGroup usages from src/mono

Follow-up to https://github.com/dotnet/runtime/pull/32833

* PR feedback

4 years agoCopy UCRT from versioned directory as fallback and fully incremental (#33209)
Juan Hoyos [Fri, 6 Mar 2020 08:38:59 +0000 (00:38 -0800)]
Copy UCRT from versioned directory as fallback and fully incremental (#33209)

4 years agoFix build warnings (#32208)
Next Turn [Fri, 6 Mar 2020 04:02:53 +0000 (12:02 +0800)]
Fix build warnings (#32208)

4 years agoAdd missing IAsyncDisposable interfaces to System.Data.Common (#33265)
Eric StJohn [Fri, 6 Mar 2020 02:08:25 +0000 (18:08 -0800)]
Add missing IAsyncDisposable interfaces to System.Data.Common (#33265)

4 years agoOverride SerializeToStreamAsync(..., cancellationToken) on Utf8StringContent (#32987)
Stephen Toub [Fri, 6 Mar 2020 01:19:41 +0000 (20:19 -0500)]
Override SerializeToStreamAsync(..., cancellationToken) on Utf8StringContent (#32987)

4 years agoMove Utf8String and Utf8Span code to src/libraries. (#33254)
Stephen Toub [Fri, 6 Mar 2020 01:19:08 +0000 (20:19 -0500)]
Move Utf8String and Utf8Span code to src/libraries. (#33254)

This is the first step in getting Utf8String and Utf8Span working on netstandard2.0.

Contributes to #29442

4 years agoAdd new properties for Obsolete Attribute (#33248)
buyaa-n [Fri, 6 Mar 2020 00:46:50 +0000 (16:46 -0800)]
Add new properties for Obsolete Attribute (#33248)

* Add DiagnosticId UrlFormat propertites for Obsolete attribute

4 years agoRemove Array.IsValueOfElementType internal call (#33239)
Jan Kotas [Fri, 6 Mar 2020 00:28:51 +0000 (16:28 -0800)]
Remove Array.IsValueOfElementType internal call (#33239)

4 years agoFix for solving lock contention issue in GC statics scanning. (#32795)
Jan Kotas [Fri, 6 Mar 2020 00:10:01 +0000 (16:10 -0800)]
Fix for solving lock contention issue in GC statics scanning. (#32795)

* Fix for solving lock contention issue in GC statics scanning.

* Comment change to clarify benefit of switching order in GcScanRoots.

4 years agoSupport COM objects with dynamic keyword (#33060)
Elinor Fung [Thu, 5 Mar 2020 23:02:23 +0000 (15:02 -0800)]
Support COM objects with dynamic keyword (#33060)

4 years agoFix allocation of RuntimeTypeCache GC handle (#33243)
Jan Vorlicek [Thu, 5 Mar 2020 20:57:16 +0000 (21:57 +0100)]
Fix allocation of RuntimeTypeCache GC handle (#33243)

When there is a race calling RuntimeType.InitializeCache, each of the
racing threads creates a new GC handle using
new RuntimeTypeHandle(this).GetGCHandle(GCHandleType.WeakTrackResurrection);
This ends up calling RuntimeTypeHandle::GetGCHandle native method that
adds the allocated handle into the handle cleanup list of the
AssemblyLoaderAllocator specific for the runtime type.
All but the winning thread then call GCHandle.InternalFree on the just
allocated handle. That frees the handle, but leaves it on the cleanup
list of the loader allocator. The same handle can be later allocated for some
other purpose. When the AssemblyLoaderAllocator is being destroyed, all
the handles on the cleanup list are destroyed too. So it destroys also
the handle that was left on the cleanup list incorrectly. That can cause
all kinds of hard to diagnose issues, like the #32171.

This change fixes it by adding a FreeGCHandle method on the
RuntimeTypeHandle that besides freeing the handle also removes it from
the cleanup list of the related AssemblyLoadContext.

4 years agoChanges to excluded test failures when using mono runtime. (#33176)
Nathan Ricci [Thu, 5 Mar 2020 20:20:20 +0000 (15:20 -0500)]
Changes to excluded test failures when using mono runtime. (#33176)

4 years agoFix an assert in ReadyToRunReader constructor (#33203)
Andrew Au [Thu, 5 Mar 2020 19:37:20 +0000 (11:37 -0800)]
Fix an assert in ReadyToRunReader constructor (#33203)

4 years agoCalculate if we're in an instance method in one place to support reverse IL stubs...
msftbot[bot] [Thu, 5 Mar 2020 18:42:02 +0000 (18:42 +0000)]
Calculate if we're in an instance method in one place to support reverse IL stubs. (#33199)

4 years agoMove elfreader assertions (#33195)
Steve MacLean [Thu, 5 Mar 2020 18:20:30 +0000 (13:20 -0500)]
Move elfreader assertions (#33195)

* Move elfreader assertions

Assert before operating on parsed program header

* Remove blank lines