platform/upstream/dotnet/runtime.git
4 years agofix inlining
Egor Bogatov [Fri, 9 Aug 2019 09:55:50 +0000 (12:55 +0300)]
fix inlining

Commit migrated from https://github.com/mono/mono/commit/a7e428d82f3042960e42a638e26afe73b1381eda

4 years agoMake System.Runtime.Intrinsics.X86.*.IsSupported intrinsic
Egor Bogatov [Thu, 8 Aug 2019 16:38:39 +0000 (19:38 +0300)]
Make System.Runtime.Intrinsics.X86.*.IsSupported intrinsic

Commit migrated from https://github.com/mono/mono/commit/7deb53514dfd0c0662c2a8a95e019b9ec6244f3d

4 years agofix minor issues
Egor Bogatov [Thu, 8 Aug 2019 15:29:53 +0000 (18:29 +0300)]
fix minor issues

Commit migrated from https://github.com/mono/mono/commit/9442ed95d7b781fd2562f73bbd5f4fac326f32b2

4 years ago[merp] Use a separate program as the hang supervisor. (mono/mono#15715)
Alexis Christoforides [Fri, 9 Aug 2019 07:31:57 +0000 (10:31 +0300)]
[merp] Use a separate program as the hang supervisor. (mono/mono#15715)

* [merp] Use a separate program as the hang supervisor.

Fixes https://github.com/mono/mono/issues/15646

macOS does not like signals being sent from the forked supervisor process, possibly towards anywhere but definitely when sent to the parent process. The following message is currently spewed after the supervisor process attempting to send a SIGSEGV to a hanged Mono process:
"The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec()."

We follow that direction and introduce a new binary that, when available in the mono executable's binary directory, is used to abort the parent process for us.

Commit migrated from https://github.com/mono/mono/commit/2c4b60fe24bfbccb3fa1553aed1065ce072343e1

4 years ago[netcore] Don't return REFERENCE_MISSING in netcore_load_reference
Ryan Lucia [Thu, 8 Aug 2019 22:07:54 +0000 (18:07 -0400)]
[netcore] Don't return REFERENCE_MISSING in netcore_load_reference

Commit migrated from https://github.com/mono/mono/commit/6a459c25d771dec436bb6a8785c683f6b15fe6f7

4 years agoMerge pull request mono/mono#16125 from vargaz/wasm-keep-config-cache
Zoltan Varga [Fri, 9 Aug 2019 07:20:03 +0000 (03:20 -0400)]
Merge pull request mono/mono#16125 from vargaz/wasm-keep-config-cache

[wasm] Add a KEEP_CONFIG_CACHE option to Make.config to avoid deleting the autoconf cache file on make clean.

Commit migrated from https://github.com/mono/mono/commit/e71604d695f57dc39a496509dddd99f898d39eb2

4 years ago[tests] Fix accessing field of MarshalByRefObject in remoting1.cs (mono/mono#16119)
Alexander Köplinger [Thu, 8 Aug 2019 22:07:41 +0000 (00:07 +0200)]
[tests] Fix accessing field of MarshalByRefObject in remoting1.cs (mono/mono#16119)

We need to copy it to a local variable first.
This was exposed by a new Roslyn optimization for String.Concat (see https://github.com/dotnet/roslyn/issues/37830).

Commit migrated from https://github.com/mono/mono/commit/ec35e146360962d49a26d628d2254c85c5322449

4 years ago[perfcounter] Define mono_perfcounter_foreach even if perfcounters are disabled....
Aleksey Kliger (λgeek) [Thu, 8 Aug 2019 18:06:21 +0000 (14:06 -0400)]
[perfcounter] Define mono_perfcounter_foreach even if perfcounters are disabled. (mono/mono#16100)

Fixes netcore build on win32

Commit migrated from https://github.com/mono/mono/commit/36af44e3be4a0f73586e886b96f86ee500f8ab32

4 years ago[sdb][interp] Use the interpreter's resume state to compute the IL offset in compute_...
imhameed [Thu, 8 Aug 2019 00:05:55 +0000 (17:05 -0700)]
[sdb][interp] Use the interpreter's resume state to compute the IL offset in compute_frame_info. (mono/mono#15936)

[sdb][interp] Use the interpreter's resume state to compute the IL offset in compute_frame_info.

This recovers the relevant bits of the "resume state" from the interpreter and uses that to recalculate the `il_offset` for the top frame.

Fixes https://github.com/mono/mono/issues/15687.

Commit migrated from https://github.com/mono/mono/commit/fc4d234ef61bc3150be6a3d15e8e80a6bc9fbfa5

4 years ago[llvm] Explicitly check for errors when calling LegacyIRCompileLayer::addModule....
imhameed [Wed, 7 Aug 2019 19:15:55 +0000 (12:15 -0700)]
[llvm] Explicitly check for errors when calling LegacyIRCompileLayer::addModule. (mono/mono#16082)

[llvm] Explicitly check for errors when calling LegacyIRCompileLayer::addModule.

LLVM built with LLVM_ENABLE_ASSERTIONS=On will crash if errors are not
explicitly consumed.

Commit migrated from https://github.com/mono/mono/commit/4462f10fb66e85b66d8d5497653fdbcd2775eb93

4 years agoRelax locking (mono/mono#15986)
Ryan Lucia [Wed, 7 Aug 2019 18:17:19 +0000 (14:17 -0400)]
Relax locking (mono/mono#15986)

* Remove usage of loader lock

Originally added in https://github.com/mono/mono/commit/mono/mono@c4cbd3b700eea52c84c68c9450d80357b3be681d but no longer relevant

* Make get_agent_domain_info lock-free and relax loader lock

* Syntax errors

* Undo first commit, other than the commit message

* Fixes

Commit migrated from https://github.com/mono/mono/commit/aece3efc9939a22e970f0d30a654bfaece61aea0

4 years ago[netcore] Re-enable IsAssignableFrom test
Ryan Lucia [Tue, 6 Aug 2019 18:12:59 +0000 (14:12 -0400)]
[netcore] Re-enable IsAssignableFrom test

This was fixed a while back but never removed from the exclusions

Commit migrated from https://github.com/mono/mono/commit/dcd57151613af34b213e0bd49de70e402d19cc47

4 years agoMerge pull request mono/mono#16085 from kjpou1/wasm-sdk-v0.2.0
Zoltan Varga [Wed, 7 Aug 2019 15:17:12 +0000 (11:17 -0400)]
Merge pull request mono/mono#16085 from kjpou1/wasm-sdk-v0.2.0

[wasm][sdk] Bump SDK Version 0.2.0

Commit migrated from https://github.com/mono/mono/commit/d18daefdbc9fa6ad530f1d28642f305d308cc90a

4 years agoThere is no need to zero static data, and it is racy (mono/mono#15699)
Jay Krell [Wed, 7 Aug 2019 14:40:57 +0000 (07:40 -0700)]
There is no need to zero static data, and it is racy (mono/mono#15699)

if there are multiple threads calling (unlikely).
This zeroing was made moot by mono/mono@470354fa817716739615ff0c6cfefca42ec8b385 January 2019.

Commit migrated from https://github.com/mono/mono/commit/e8d28feb1e7a8cb0820704aee66410f4ae13c252

4 years agoAllow generating DIM bitcode (mono/mono#16070)
Thays Grazia [Wed, 7 Aug 2019 14:06:56 +0000 (11:06 -0300)]
Allow generating DIM bitcode (mono/mono#16070)

Commit migrated from https://github.com/mono/mono/commit/e690fb0240027d95908f1d7ffa3d401b8d1167ba

4 years ago[utils] Move MAP_ANONYMOUS check after sys/mman.h import
Alexander Köplinger [Wed, 7 Aug 2019 13:54:09 +0000 (15:54 +0200)]
[utils] Move MAP_ANONYMOUS check after sys/mman.h import

The flag is defined in that header on OSX. Followup to mono/mono@2abe569ede069f172c3213a49cfb07c39c5c58dc

Commit migrated from https://github.com/mono/mono/commit/521d4c839555a9df6d0dcade229072c7b8b9ee21

4 years ago[w32socket] Translate ELOOP and ENAMETOOLONG (mono/mono#16039)
Aleksey Kliger (λgeek) [Wed, 7 Aug 2019 13:42:39 +0000 (09:42 -0400)]
[w32socket] Translate ELOOP and ENAMETOOLONG (mono/mono#16039)

Translate to WSAELOOP and WSAENAMETOOLONG, respectively.

See https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2

Addresses part of https://github.com/mono/mono/issues/16024

Commit migrated from https://github.com/mono/mono/commit/aea457cdb3ea8217ef702e8a521e732f6f3e3693

4 years ago[trace] Improve enter/leave output formatting (mono/mono#16036)
Nikolay Sivov [Wed, 7 Aug 2019 13:05:44 +0000 (16:05 +0300)]
[trace] Improve enter/leave output formatting (mono/mono#16036)

* [trace] Use specific integer types for return value traces.

* [trace] Improve argument list formatting for ENTER lines.

Return value changes are especially visible for bools, where currently 4 bytes integers are printed.

Commit migrated from https://github.com/mono/mono/commit/10c5e6407ec5f3f691cd65b4fe6591e05cb224aa

4 years ago[win32] Fix some compilation warnings (mono/mono#15956)
Nikolay Sivov [Wed, 7 Aug 2019 12:45:19 +0000 (15:45 +0300)]
[win32] Fix some compilation warnings (mono/mono#15956)

* [mini] Remove unused variable.

* [mini] Mark win32 exception handling functions static.

* [mini] Remove unused variable.

* [mini] Suppress unused function warning.

* [metadata] Fix unused function warning for Win32 build.

Commit migrated from https://github.com/mono/mono/commit/d34381f72e0a04febdb6d6ea084377d0d635e15f

4 years agoFix compilation on OSX 10.9 (mono/mono#14411)
iamphi [Wed, 7 Aug 2019 12:42:57 +0000 (05:42 -0700)]
Fix compilation on OSX 10.9 (mono/mono#14411)

Found solution from:
https://github.com/eclipse/omr/issues/902#issuecomment-288559044

Commit migrated from https://github.com/mono/mono/commit/2abe569ede069f172c3213a49cfb07c39c5c58dc

4 years ago[runtime] Fix an autoconf warning. (mono/mono#16078)
Zoltan Varga [Wed, 7 Aug 2019 10:06:00 +0000 (06:06 -0400)]
[runtime] Fix an autoconf warning. (mono/mono#16078)

[runtime] Fix an autoconf warning.

<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->

Commit migrated from https://github.com/mono/mono/commit/ba1c949a24594c65d9fca77fb13c3af09c54c16b

4 years ago[interp] Fix DEBUG_INTERP build (mono/mono#16057)
Vlad Brezae [Wed, 7 Aug 2019 09:47:41 +0000 (12:47 +0300)]
[interp] Fix DEBUG_INTERP build (mono/mono#16057)

Commit migrated from https://github.com/mono/mono/commit/e702e8286fc3a7267fdd9eda572b0539446701cc

4 years agoRemove code moved to shared partition
Marek Safar [Wed, 7 Aug 2019 06:54:49 +0000 (08:54 +0200)]
Remove code moved to shared partition

Commit migrated from https://github.com/mono/mono/commit/25b84915e180d6721d6e2dd87585e366a61ca9ec

4 years ago[netcore] Set flag for processor arch when parsing assembly names
Ryan Lucia [Tue, 6 Aug 2019 17:22:45 +0000 (13:22 -0400)]
[netcore] Set flag for processor arch when parsing assembly names

Commit migrated from https://github.com/mono/mono/commit/022fc4ea3798f6c8e56a9c888e27c0bcc562245c

4 years ago[arm] respect I1 and I2 on gsharedvt out transition (mono/mono#16000)
Bernhard Urban [Tue, 6 Aug 2019 22:25:51 +0000 (00:25 +0200)]
[arm] respect I1 and I2 on gsharedvt out transition (mono/mono#16000)

[arm] respect I1 and I2 on gsharedvt out transition

In order to trigger the problem, we must call into gsharedvt code ("in" transition) and then escape the gsharedvt world ("out" transition). The bug happens in the latter. Also some other stars need to align (I haven't fully understood it), thus the repro is quite long.

The provided repro only triggers with LLVM, which we don't have enabled on CI yet: https://github.com/mono/mono/issues/15999

Fixes https://github.com/mono/mono/issues/15261
Fixes https://github.com/mono/mono/issues/15262
Fixes https://github.com/mono/mono/issues/15263
Fixes https://github.com/mono/mono/issues/15307

Commit migrated from https://github.com/mono/mono/commit/fe0f311a848068ab2d17a9b9dd15326e5712d520

4 years agoMerge pull request mono/mono#16071 from vargaz/wasm-xunit-3
Zoltan Varga [Tue, 6 Aug 2019 21:57:22 +0000 (17:57 -0400)]
Merge pull request mono/mono#16071 from vargaz/wasm-xunit-3

[wasm] More xunit fixes.

Commit migrated from https://github.com/mono/mono/commit/add830f9cbffc7a531a744baf76211e4300193ab

4 years ago[wasm] Compile interp.c with -mllvm -join-liveintervals=false to fix compilation...
Zoltan Varga [Sun, 4 Aug 2019 21:50:54 +0000 (17:50 -0400)]
[wasm] Compile interp.c with -mllvm -join-liveintervals=false to fix compilation times.

Commit migrated from https://github.com/mono/mono/commit/476af240d242b557ea82723f601795697fffb2e5

4 years ago[Coop] Convert mono_object_isinst_icall. (mono/mono#15963)
Jay Krell [Tue, 6 Aug 2019 19:26:55 +0000 (12:26 -0700)]
[Coop] Convert mono_object_isinst_icall. (mono/mono#15963)

Commit migrated from https://github.com/mono/mono/commit/9bf703b031bf81fa621c3d2318a4fc4333b80d3b

4 years agoUpdate NetBSD support (mono/mono#15938)
coypoop [Tue, 6 Aug 2019 18:32:38 +0000 (18:32 +0000)]
Update NetBSD support (mono/mono#15938)

Based on the FreeBSD variation.
Needs some additional changes I'm still ironing out.

Commit migrated from https://github.com/mono/mono/commit/5a4283d1b3d0dc4dacac97cd56326179324fde78

4 years ago[netcore] Update test exclusions to reflect ALC work (mono/mono#16059)
Ryan Lucia [Tue, 6 Aug 2019 18:08:18 +0000 (14:08 -0400)]
[netcore] Update test exclusions to reflect ALC work (mono/mono#16059)

Commit migrated from https://github.com/mono/mono/commit/64bf7ef9db3db3d4ed27a3809bc7b98e9322208a

4 years ago[netcore] Avoid calling load hooks during AOT.
Zoltan Varga [Tue, 6 Aug 2019 13:49:28 +0000 (09:49 -0400)]
[netcore] Avoid calling load hooks during AOT.

Fixes https://github.com/mono/mono/issues/16046.

Commit migrated from https://github.com/mono/mono/commit/3c88e9f251684c46ca07286a9637a2e5266eec15

4 years agoMerge pull request mono/mono#16058 from vargaz/wasm-requests-2
Zoltan Varga [Tue, 6 Aug 2019 16:53:44 +0000 (12:53 -0400)]
Merge pull request mono/mono#16058 from vargaz/wasm-requests-2

[wasm] Update WASM-REQUESTS.md.

Commit migrated from https://github.com/mono/mono/commit/662b72f913db6e7e8a3f51540a6c8361e188763f

4 years ago[netcore] Make the load hook ALC-aware (mono/mono#16012)
Ryan Lucia [Tue, 6 Aug 2019 10:16:15 +0000 (06:16 -0400)]
[netcore] Make the load hook ALC-aware (mono/mono#16012)

The meat of this PR is what the title suggests, and with this commit all the basic ALC functionality should be working properly. Probably worth checking if this makes any new tests pass.

Additionally, this PR includes a second commit that switches over the search hook to use loaded_assemblies from the ALCs. This may break some existing tests due to remaining unimplemented ALC behavior, notably the native loading mechanism needed for Openssl in some of the cryptography tests. My inclination is to include the commit regardless and just disable the failing tests so that any future ALC work can watch for regressions in the loader, but I would appreciate input from steveisok on how important those tests are. I've not disabled anything yet in order to see exactly what new failures are introduced.

Commit migrated from https://github.com/mono/mono/commit/85296ef1be7bb34c1c92953ca66a026e5dcd0771

4 years agoUWP now allows LoadLibrary. (mono/mono#16015)
Jay Krell [Tue, 6 Aug 2019 10:14:38 +0000 (03:14 -0700)]
UWP now allows LoadLibrary. (mono/mono#16015)

Commit migrated from https://github.com/mono/mono/commit/474092add6c0c9f41ff3724485d3d05be48b4c5f

4 years agoMerge pull request mono/mono#16006 from vargaz/as-gsharedvt
Zoltan Varga [Tue, 6 Aug 2019 01:04:44 +0000 (21:04 -0400)]
Merge pull request mono/mono#16006 from vargaz/as-gsharedvt

[jit] Avoid asserting on Unsafe.As<T> in gsharedvt methods.

Commit migrated from https://github.com/mono/mono/commit/9b4bc613e4193441c041f7f33e4da668da75b9b1

4 years agoBump version to 6.7 (mono/mono#16031)
Jo Shields [Mon, 5 Aug 2019 19:31:47 +0000 (15:31 -0400)]
Bump version to 6.7 (mono/mono#16031)

* Bump version to 6.7

Commit migrated from https://github.com/mono/mono/commit/c8c52f7e9f75113a8fcaa58397496a3423b47e58

4 years ago[netcore] ifdef out unused icalls/files. (mono/mono#16009)
Zoltan Varga [Mon, 5 Aug 2019 15:13:40 +0000 (11:13 -0400)]
[netcore] ifdef out unused icalls/files. (mono/mono#16009)

* [netcore] ifdef out unused icalls/files.

* Add MONO_EMPTY_SOURCE_FILE.

Commit migrated from https://github.com/mono/mono/commit/93a6bc31511decdf93357e78fb2a1a14bf7c76c1

4 years agoMerge pull request mono/mono#15640 from vargaz/wasm-xunit
Zoltan Varga [Sun, 4 Aug 2019 21:05:59 +0000 (17:05 -0400)]
Merge pull request mono/mono#15640 from vargaz/wasm-xunit

Add beginnings of support for running xunit tests.

Commit migrated from https://github.com/mono/mono/commit/17b35dc4fc96144e19078a5fca965cb8c4c75805

4 years ago[jit] Avoid asserting on Unsafe.As<T> in gsharedvt methods.
Zoltan Varga [Sat, 3 Aug 2019 19:06:55 +0000 (15:06 -0400)]
[jit] Avoid asserting on Unsafe.As<T> in gsharedvt methods.

Fixes https://github.com/mono/mono/issues/15992.

Commit migrated from https://github.com/mono/mono/commit/60bfa99043e0112a4d30ebccd5c9f800d0cc101a

4 years ago[netcore] Minor fixes around System.Reflection (mono/mono#15905)
Egor Bogatov [Sat, 3 Aug 2019 18:49:38 +0000 (21:49 +0300)]
[netcore] Minor fixes around System.Reflection (mono/mono#15905)

* Minor fixes

* Update HelloWorld.csproj

Commit migrated from https://github.com/mono/mono/commit/e08bddaa63bd117fad4fe6b99d41e272689adf97

4 years ago[netcore] Enable ALC loaded_assemblies (mono/mono#15850)
Ryan Lucia [Sat, 3 Aug 2019 18:47:38 +0000 (14:47 -0400)]
[netcore] Enable ALC loaded_assemblies (mono/mono#15850)

* Typo

* Enable loaded_assemblies and lock

* Make mono_domain_assembly_open_internal ALC-aware

* Populate loaded_assemblies

Switch from prepend to append

* Some notes

* Exclude add_assembly_to_alc on non-netcore

* Cleanup appdomain.c

* Remove mono_alc_cleanup for now

* Update comment

* Disable using loaded_assemblies in the search hook

* Adjust alc cleanup

Commit migrated from https://github.com/mono/mono/commit/848811e4b26519ce62672886813f6eb73d572be5

4 years agoRemove error_init from native icall wrappers since managed does it. (mono/mono#15943)
Zoltan Varga [Sat, 3 Aug 2019 16:00:46 +0000 (12:00 -0400)]
Remove error_init from native icall wrappers since managed does it. (mono/mono#15943)

Preferable would be native only, i.e. for interpreter and for when
it is actually unused, but ok for now.

Between removing the managed and the native, managed is preserved
in case there uses of MonoError in C# other than icall wrappers.
Keep them safe.

But again ideally move it to native and remove the managed type,
pending debugging WebAssembly failure doing so.

Commit migrated from https://github.com/mono/mono/commit/9da563509e7d6f0e05d0c9f14dc949dc182567df

4 years agoFix usage of mono_debug_get_seq_points to avoid leaks (mono/mono#15977)
Jb Evain [Sat, 3 Aug 2019 15:59:25 +0000 (08:59 -0700)]
Fix usage of mono_debug_get_seq_points to avoid leaks (mono/mono#15977)

Commit migrated from https://github.com/mono/mono/commit/283c0557d376a7c680cfe5993d1ea872391bbf99

4 years ago[llvm] Add support for JIT + LLVM 9.0. (mono/mono#15997)
imhameed [Sat, 3 Aug 2019 15:58:40 +0000 (08:58 -0700)]
[llvm] Add support for JIT + LLVM 9.0. (mono/mono#15997)

* [llvm] Add support for llvm 9.0.

Works with this branch:
https://github.com/mono/llvm/tree/release_90

* Add support for JIT + LLVM 9.

* Don't assume that all memset targets will be aligned; fixes LLVM 6 on amd64.

Commit migrated from https://github.com/mono/mono/commit/3ab93f97e681868216327b8b0b7c19112ccfc1d3

4 years agoEnable MONO_ARCH_EMULATE_FCONV_TO_U4 on PPC (mono/mono#15991)
Calvin Buckley [Fri, 2 Aug 2019 23:00:02 +0000 (20:00 -0300)]
Enable MONO_ARCH_EMULATE_FCONV_TO_U4 on PPC (mono/mono#15991)

Fixes regression related to floating point introduced in mono/mono#15930.

This does mean we have to take a slower path instead of using the
PPC instruction, but it provides consistent results. Other CPUs
have to do this too, so it's not like PPC is impacted unfairly.
(i.e, NaN gives an inconsistent result, at least with POWER7 and
some amd64 CPUs tested)

Fixes mono/mono#15990.

Commit migrated from https://github.com/mono/mono/commit/e70ac8c6ae7ff3f03517be90babb8f7c25d18b97

4 years agoDon't use clock_nanosleep on PASE (mono/mono#15988)
Calvin Buckley [Fri, 2 Aug 2019 21:04:50 +0000 (18:04 -0300)]
Don't use clock_nanosleep on PASE (mono/mono#15988)

* Don't use clock_nanosleep on PASE

PASE exports this AIX syscall so autoconf detects it, but using it
will trigger SIGILL (for unimplemented syscall), which emits a LIC
log entry type of 4700-000F.

* Change ifdef guard for clock_nanosleep in threads

It only used clock_nanosleep on Linux, but enable it for all except
PASE. Android used to be guarded against, but the reasoning was
unknown, so @akoeplinger requested to have that guard removed.

Commit migrated from https://github.com/mono/mono/commit/9ea07610ee4c2879f5d598aa6f34b6df79401047

4 years ago[netcore] Fix comments in ALC to use Mono terminology (mono/mono#15998)
Aleksey Kliger (λgeek) [Fri, 2 Aug 2019 20:31:06 +0000 (16:31 -0400)]
[netcore] Fix comments in ALC to use Mono terminology (mono/mono#15998)

Commit migrated from https://github.com/mono/mono/commit/713df6a9c48c2c4da4037b4bbad43244fbcc505f

4 years ago[netcore] Implement referenced assembly resolving and ALC.GetLoadContext (mono/mono...
Aleksey Kliger (λgeek) [Fri, 2 Aug 2019 18:06:44 +0000 (14:06 -0400)]
[netcore] Implement referenced assembly resolving and ALC.GetLoadContext (mono/mono#15946)

* [netcore] Implement GetLoadContext

* [netcore] Implement ALC-aware referenced assembly resolution.

The process is described in
https://docs.microsoft.com/en-us/dotnet/api/system.runtime.loader.assemblyloadcontext?view=netcore-3.0#usage-in-the-runtime

We try four things until one of them returns a non-null assembly.

1. Check if the assembly is already loaded in the ALC of the requesting
assembly.
2. If the ALC is not the default ALC, invoke the Load override.
3. Try the default ALC (TPA - trusted platform assemblies) loading.
4. Invoke the Resolving event of the original ALC.

The implementation borrows some managed code from
https://github.com/dotnet/coreclr/blob/mono/mono@8ba2e15201361402acd0ae9710bd37d50785cdfa/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.CoreCLR.cs#L84-L187

It would be nice if that code was shared between the runtimes.

* [runtime] Implement mono_assembly_name_culture_is_neutral

* [netcore] Add mono_alc_invoke_resolve_using_resolve_satellite

* [netcore] Use ResolveSatelliteAssembly for satellite assembly refs

* [netcore] Some AssemblyLoadContextTest tests now pass

System.Runtime.Loader.Tests.AssemblyLoadContextTest.PublicConstructor_Default
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_NullParameter
System.Runtime.Loader.Tests.AssemblyLoadContextTest.LoadFromAssemblyName_AssemblyNotFound
System.Runtime.Loader.Tests.AssemblyLoadContextTest.PublicConstructor_Theory (with isCollectible: False)
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_ValidAssembly
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetLoadContextTest_SystemPrivateCorelibAssembly
System.Runtime.Loader.Tests.AssemblyLoadContextTest.DefaultAssemblyLoadContext_Properties
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetAssemblyNameTest_AssemblyNotFound
System.Runtime.Loader.Tests.AssemblyLoadContextTest.GetLoadContextTest_ValidTrustedPlatformAssembly

Commit migrated from https://github.com/mono/mono/commit/2f2f6c104b2a0115a7fb1ab24673b587c27e4365

4 years ago[netcore] Use mono-netcore to run real world apps using `dotnet run` (mono/mono#15942)
Egor Bogatov [Fri, 2 Aug 2019 15:06:37 +0000 (18:06 +0300)]
[netcore] Use mono-netcore to run real world apps using `dotnet run` (mono/mono#15942)

So currently we have two .NET Core:

1) `mono-repo/.dotnet` - we use it to bootstrap and build stuff (the SDK version is specified in `global.json`) - if you open `netcore/Makefile` it's referred there as `$(DOTNET)` variable.
2) `mono-repo/netcore/.dotnet` - it's just a runtime + CoreFX libs (it doesn't contain SDK stuff, templates, msbuild, etc) - we use it only to run tests because this runtime is synchronized with corefx tests in `eng/Versions.prop` file which is updated by a bot and `netcore/shared` sources for our System.Private.CoreLib also depend on that exact runtime version (the sources also updated by the bot).

This PR introduces a rule to copy mono bits to the `mono-repo/.dotnet` folder to be able to run real world apps (at your own risk) using mono-netcore (so when you run `mono-root/.dotnet/.dotnet run -c Release` for an app - even MSBuild will use mono runtime to build that app). However in theory we need exact SDK for the runtime version we have but I have no idea where and how to get one.

BTW, currently MSBuild crashes when it's powered by mono on `$(DOTNET) build` command for a hello world.
```
monoeg_assertion_message
mono_domain_assembly_preload
invoke_assembly_preload_hook
...
at <unknown> <0xffffffff>
at System.Reflection.RuntimeAssembly:GetExportedTypes <0x000a2>
at AssemblyInfoToLoadedTypes:ScanAssemblyForPublicTypes <0x0008e>
```

Commit migrated from https://github.com/mono/mono/commit/d0aa0310ee386433a9ef0b4c15ac07c928211bcb

4 years agoMake System.Private.CoreLib.csproj VS friendly (mono/mono#15965)
Egor Bogatov [Fri, 2 Aug 2019 14:05:22 +0000 (17:05 +0300)]
Make System.Private.CoreLib.csproj VS friendly (mono/mono#15965)

Now it's possible to open System.Private.CoreLib.csproj in an IDE and build (use Roslyn version from eng/Versions.props).

Commit migrated from https://github.com/mono/mono/commit/40f28b2e6371c708989ff59dd1cb4f7dcc22aedc

4 years ago[debugger] Invoke method with fixed size array as an attribute of this (mono/mono...
Thays Grazia [Fri, 2 Aug 2019 13:47:25 +0000 (10:47 -0300)]
[debugger] Invoke method with fixed size array as an attribute of this (mono/mono#15766)

Implement debugger invoke when the this has an attribute that is a fixed size array.

Fixes mono/mono#15556

Commit migrated from https://github.com/mono/mono/commit/3a9df67a64c129fa3c5c32334c231739965f1efb

4 years ago[interp] Remove unconditional branches to next instruction (mono/mono#15939)
Vlad Brezae [Fri, 2 Aug 2019 09:16:07 +0000 (12:16 +0300)]
[interp] Remove unconditional branches to next instruction (mono/mono#15939)

[interp] Remove unconditional branches to next instruction

These are very common, at least in debug builds. Optimize them away so it doesn't distort performance numbers.

Commit migrated from https://github.com/mono/mono/commit/4883b56c10a077e4c82feff604172d6994994e1a

4 years ago[netcore] Minor fixes, fix GetTypeTests.GetType_EmptyString (mono/mono#15933)
Egor Bogatov [Thu, 1 Aug 2019 20:56:56 +0000 (23:56 +0300)]
[netcore] Minor fixes, fix GetTypeTests.GetType_EmptyString (mono/mono#15933)

* Fixes https://github.com/mono/mono/issues/15023

* Fixes https://github.com/mono/mono/issues/15189 (were marked as "require large array
support" in dotnet/corefx by @filipnavara)

* Move InternalGetHashCode to RuntimeHelpers

Commit migrated from https://github.com/mono/mono/commit/26f3df98810411b62fcf41daaff5d407df3ba7b5

4 years ago[netcore] Add a README. (mono/mono#15934)
Zoltan Varga [Thu, 1 Aug 2019 20:27:40 +0000 (16:27 -0400)]
[netcore] Add a README. (mono/mono#15934)

* [netcore] Add a README.

Commit migrated from https://github.com/mono/mono/commit/6f0519266903983c28d159a8e9154e02a1467cc4

4 years agoBump monolite version. (mono/mono#15969)
Jay Krell [Thu, 1 Aug 2019 19:38:52 +0000 (12:38 -0700)]
Bump monolite version. (mono/mono#15969)

It got out of sync for some reason.

Commit migrated from https://github.com/mono/mono/commit/75a99b7e84dfa6716e9c1ef5eaf7740bd689a53d

4 years ago[sgen] Fix check-nursery-pinned debug option (mono/mono#15865)
Vlad Brezae [Thu, 1 Aug 2019 18:48:23 +0000 (21:48 +0300)]
[sgen] Fix check-nursery-pinned debug option (mono/mono#15865)

* [sgen] Remove dead unpin_queue argument

* [sgen] Fix check-nursery-pinned debug option

And rename it to better reflect what is is doing now (which is to check that we don't leave any vtables tagged at the end of a collection). It used to also check that nursery objects are pinned, back when we were doing a nursery collection as part of the finishing pause of a concurrent collection.

Commit migrated from https://github.com/mono/mono/commit/87ba12e13f98a24eb140e933876a25b45fd806b8

4 years ago[jit] Align float/double Nan/Inf to uint conversion behavior with CoreCLR/LLVM/Roslyn...
Filip Navara [Thu, 1 Aug 2019 17:37:41 +0000 (19:37 +0200)]
[jit] Align float/double Nan/Inf to uint conversion behavior with CoreCLR/LLVM/Roslyn (mono/mono#15930)

* [jit] Align float/double Nan/Inf to uint conversion behavior with CoreCLR/LLVM

* Fix float/double -> ulong conversion for edge cases

* Fix mono_fconv_u8 / mono_rconv_u8 to also return 0 for PositiveInfinity

* Enable support for platform specific implementations of OP_RCONV_U8/OP_FCONV_U8/OP_FCONV_U4

* Restore OP emulation on WASM target

* Update tests

* Disable failing tests for now

* Adjust tests

* Adjust tests

* Fix float -> uint conversion on WASM

* Make interpreter consistent with compiled code

* Blind attempt to fix WASM test leg

* Implement remaining conversions in LLVM

* Fix ARM32

* Workaround for Windows x64 FullAOT+LLVM

* Bump AOT version

Commit migrated from https://github.com/mono/mono/commit/3c92cd8c94c027b7c9215a12044345106851262b

4 years agoSupport proper Windows kernel Unicode thread names. (mono/mono#15919)
Jay Krell [Thu, 1 Aug 2019 13:53:41 +0000 (06:53 -0700)]
Support proper Windows kernel Unicode thread names. (mono/mono#15919)

These do not require a debugger, can be retrieved, appear in ETW, etc.

Extracted from https://github.com/mono/mono/pull/15859.

Commit migrated from https://github.com/mono/mono/commit/a7b74fc69c8c42911c5406bceca35220c87fccc4

4 years ago [wasm] Add normal GC support. (mono/mono#15577)
Zoltan Varga [Thu, 1 Aug 2019 13:50:28 +0000 (09:50 -0400)]
 [wasm] Add normal GC support. (mono/mono#15577)

* [llvm] Spill all ref variables to the stack on wasm, so GC stack scanning can scan all references.

* [runtime] Add an option to enable on-demand GC.

Commit migrated from https://github.com/mono/mono/commit/6a66472815ff06d365281cd5cb6c2cf60b4ac138

4 years ago[marshal] Free delegates with target that are passed to native code. (mono/mono#15935)
Vlad Brezae [Thu, 1 Aug 2019 13:06:05 +0000 (16:06 +0300)]
[marshal] Free delegates with target that are passed to native code. (mono/mono#15935)

* [marshal] Always use gchandles in delegate_hash_table

Makes the code easier to follow and it also fixes race from https://github.com/mono/mono/commit/mono/mono@caa4a753ca8e15d43baaa01adb0f56f374b74a2b with boehm.

* [marshal] Free delegates with target that are passed to native code.

For static method delegates, we have a unique delegate_trampoline that is shared among all delegates. We always keep alive the first static method delegate passed to native, by creating a normal gchandle to it and storing it in delegate_hash_table. For instance methods, each delegate will create a separate wrapper and these wrappers are never shared (which was wrongly assumed in https://github.com/mono/mono/commit/mono/mono@caa4a753ca8e15d43baaa01adb0f56f374b74a2b). We shuldn't keep the delegate alive and this commit reverts the behavior for delegate with instance methods introduced in the mentioned commit.

Fixes https://github.com/mono/mono/issues/15751

Commit migrated from https://github.com/mono/mono/commit/e3ca891235609663785d70aa1bbc544232070321

4 years ago[mini] Ignore conv.r.un if top of stack is already float (mono/mono#15818)
Vlad Brezae [Thu, 1 Aug 2019 12:21:50 +0000 (15:21 +0300)]
[mini] Ignore conv.r.un if top of stack is already float (mono/mono#15818)

Fixes https://github.com/mono/mono/issues/15794

Commit migrated from https://github.com/mono/mono/commit/ce398411a06b85441611565b9b6119c2702cb284

4 years agoFactor copy/pasted code into mono_gstring_append_thread_name. (mono/mono#15920)
Jay Krell [Wed, 31 Jul 2019 23:25:31 +0000 (16:25 -0700)]
Factor copy/pasted code into mono_gstring_append_thread_name. (mono/mono#15920)

Extracted from https://github.com/mono/mono/pull/15859.

Commit migrated from https://github.com/mono/mono/commit/180fcfe1fdbddb22b0c52c6e0b169b427b583ab3

4 years agoRemove error_init from native icall wrappers since managed does it.
Jay Krell [Wed, 31 Jul 2019 22:48:43 +0000 (15:48 -0700)]
Remove error_init from native icall wrappers since managed does it.
Preferable would be native only, i.e. for interpreter and for when
it is actually unused, but ok for now.

Between removing the managed and the native, managed is preserved
in case there uses of MonoError in C# other than icall wrappers.
Keep them safe.

But again ideally move it to native and remove the managed type,
pending debugging WebAssembly failure doing so.

Commit migrated from https://github.com/mono/mono/commit/3db9635bf59b84651329287e4c6b71783d30f8d6

4 years ago[tests] Bump sleep for pinvoke3 test (mono/mono#15937)
Vlad Brezae [Wed, 31 Jul 2019 21:24:06 +0000 (00:24 +0300)]
[tests] Bump sleep for pinvoke3 test (mono/mono#15937)

On some operating systems, this test can take forever because the worker starves the other threads by holding the gc_lock. Bump sleeping so it doesn't rely on OS scheduling that much and guarantees other threads can progress in reasonable amount of time.

Commit migrated from https://github.com/mono/mono/commit/985a1c33f26b698c10a0789ae5b241059c2d203f

4 years ago[zlib] Fix typo in readme and remove deleted file from msvc projects
Alexander Köplinger [Wed, 31 Jul 2019 20:58:21 +0000 (22:58 +0200)]
[zlib] Fix typo in readme and remove deleted file from msvc projects

Commit migrated from https://github.com/mono/mono/commit/cf0e2dd97253007b3e0f4b3ddea64436073753f4

4 years agoUpdate zlib from 1.2.5 to 1.2.11. (mono/mono#15480)
Jay Krell [Wed, 31 Jul 2019 20:56:34 +0000 (13:56 -0700)]
Update zlib from 1.2.5 to 1.2.11. (mono/mono#15480)

Circa 2010 to circa 2017.

Retrieved with apt-get source zlib on WSL Ubuntu 18.04.2 LTS.

This matches Debian or Ubuntu (they differ by one commit, and one of them restores a dummy function for compat).

---

* [minizip] Ensure we don't ever accidentally change calling convention

Make sure we always #define ZCALLBACK to empty so we don't change
the calling convention on windows by including a header which defines
'CALLBACK'. This will keep things as cdecl as required by the c#
pinvokes.

* Update zlib readme.

* Update zlib from 1.2.5 to 1.2.11.

* [zlib] Small fix for Visual C++.
see https://github.com/madler/zlib/pull/435/files#diff-0558e84b0c24a83ca790dcb05cd26212R1087
and https://github.com/madler/zlib/pull/435/files#diff-0558e84b0c24a83ca790dcb05cd26212R1104

* Add gzguts.h to Makefiles.

* Add .h files to Visual Studio project files just for GUI purposes.

Commit migrated from https://github.com/mono/mono/commit/431bb95c715abd830a5cfd3e9c37cf79f863cf45

4 years agoFix the netcore build. (mono/mono#15941)
Zoltan Varga [Wed, 31 Jul 2019 20:04:37 +0000 (16:04 -0400)]
Fix the netcore build. (mono/mono#15941)

Commit migrated from https://github.com/mono/mono/commit/1d9a87e449d4badaab86c989b92f3dc9ab792f9c

4 years ago[runtime] Convert more icalls to use handles. (mono/mono#15862)
Zoltan Varga [Wed, 31 Jul 2019 18:08:50 +0000 (14:08 -0400)]
[runtime] Convert more icalls to use handles. (mono/mono#15862)

* [runtime] Convert Volatile to use the same approach as the netcore version, get rid of most Volatile icalls.

* [runtime] Reduce the number of handles used by construct_culture ().

* [runtime] Convert some icalls to handles.

* Fix signature of FAMNextEvent.

* [aot] Avoid aoting the gsharedvt versions of Volatile:Read<T>/Write<T>.

* Bump API snapshot submodule

* Convert Marshal:UnsafeAddrOfPinnedArrayElement to use coop handles.

Commit migrated from https://github.com/mono/mono/commit/60c277cb4eec4bac9b4149cc345155f3b810e7da

4 years ago[threads] Enter GC Unsafe before pumping HP queue in unregister_thread (mono/mono...
Aleksey Kliger (λgeek) [Wed, 31 Jul 2019 17:30:30 +0000 (13:30 -0400)]
[threads] Enter GC Unsafe before pumping HP queue in unregister_thread (mono/mono#15890)

If the thread info TLS key dtor runs unregister_thread from a foreign thread
and we have work in the hazard pointer queue, we need to first switch to GC
Unsafe mode because some of the free methods passed to
mono_thread_hazardous_try_free need to be coop-aware.

Also, added checked mode assertions that conc_table_free and
jit_info_table_free are called from GC Unsafe mode.

Fixes https://github.com/mono/mono/issues/15878

Commit migrated from https://github.com/mono/mono/commit/349a3d5eef9ceaae51ef4d9d984cebab36ef0a2f

4 years agoCleanup and resynchronize Thread/InternalThread fields. (mono/mono#15910)
Jay Krell [Wed, 31 Jul 2019 16:30:50 +0000 (09:30 -0700)]
Cleanup and resynchronize Thread/InternalThread fields. (mono/mono#15910)

- Remove unused.
- Add missing that just happened to work.
- Synchronize size between netcore and regular. `#if` considered bad.

Extracted from https://github.com/mono/mono/pull/15859.

Commit migrated from https://github.com/mono/mono/commit/499a02d6a14edb90263023a452df439f5ab5bd05

4 years agomono_thread_set_name_internal change unreadable boolean parameters to enum flags...
Jay Krell [Wed, 31 Jul 2019 16:30:28 +0000 (09:30 -0700)]
mono_thread_set_name_internal change unreadable boolean parameters to enum flags. (mono/mono#15921)

Extracted from https://github.com/mono/mono/pull/15859.

Commit migrated from https://github.com/mono/mono/commit/9acd4c8004852aa0d2589e78fcfb86c4cf2459f8

4 years ago[jit] Optimize the initialize of MonoError locals. (mono/mono#15869)
Zoltan Varga [Wed, 31 Jul 2019 12:26:24 +0000 (08:26 -0400)]
[jit] Optimize the initialize of MonoError locals. (mono/mono#15869)

Previously, we would emit a call to memset since the struct is large (> 100 bytes). Only the error code field needs to be initialized.

Commit migrated from https://github.com/mono/mono/commit/6223e7468892cd1371fc52a5d1fd0ac1c4e1b273

4 years agoUpdate Haiku support (mono/mono#15674)
Calvin Buckley [Wed, 31 Jul 2019 12:23:48 +0000 (09:23 -0300)]
Update Haiku support (mono/mono#15674)

* Build System.Native.

* Disable `pthread_mutexattr_setprotocol` use, since it returns EINVAL on Haiku.

* Disable the `strerror` cache on Haiku. On Haiku, errors begin at `0x8000_0000` like a Win32 HRESULT. This means the indexing would be on negative numbers, which is a no-no. There are a few alternative ways to keep it though: hashtable, tuple array, offset...

Unfortunately, doesn't build all the way through. Has a tendency to bomb out during building `build-unix`. Will investigate why.

Commit migrated from https://github.com/mono/mono/commit/1059b3e6f59ef92ccba55092fa410e59fdae091f

4 years agoconfigure.ac: Use = as a test(1) operator. (mono/mono#15876)
coypoop [Wed, 31 Jul 2019 12:22:26 +0000 (12:22 +0000)]
configure.ac: Use = as a test(1) operator. (mono/mono#15876)

== is a bash extension
= is POSIX and equivalent

Commit migrated from https://github.com/mono/mono/commit/f86d46d136f2b09f85f005a5a0469db69fafa00d

4 years agoSave 64 bytes from most Linux/amd64 interpreter frames. (mono/mono#15926)
Jay Krell [Wed, 31 Jul 2019 12:20:03 +0000 (05:20 -0700)]
Save 64 bytes from most Linux/amd64 interpreter frames. (mono/mono#15926)

 Probably same on all 64bit architectures. half on 32bit.

before:
```
0000000000003ce0 <interp_exec_method_full>:
    3ce0: 55                    push   %rbp
    3ce1: 48 89 e5              mov    %rsp,%rbp
    3ce4: 41 57                 push   %r15
    3ce6: 41 56                 push   %r14
    3ce8: 41 55                 push   %r13
    3cea: 41 54                 push   %r12
    3cec: 49 89 f4              mov    %rsi,%r12
    3cef: 53                    push   %rbx
    3cf0: 48 89 fb              mov    %rdi,%rbx
    3cf3: 48 81 ec 78 01 00 00  sub    $0x178,%rsp
```

after:
```
0000000000003ce0 <interp_exec_method_full>:
    3ce0: 55                    push   %rbp
    3ce1: 48 89 e5              mov    %rsp,%rbp
    3ce4: 41 57                 push   %r15
    3ce6: 41 56                 push   %r14
    3ce8: 41 55                 push   %r13
    3cea: 41 54                 push   %r12
    3cec: 49 89 f4              mov    %rsi,%r12
    3cef: 53                    push   %rbx
    3cf0: 48 89 fb              mov    %rdi,%rbx
    3cf3: 48 81 ec 38 01 00 00  sub    $0x138,%rsp
```

It was 0x158 recently.

Some frames will be larger, i.e. dynamic + pinvoke.

Classic technique:
 pointer instead of struct
 initialized to null
 alloca it when needed and not null

A more detailed analysis might enable better, such as making
the parameter optional, and/or having the callee default it to its
local storage.

Commit migrated from https://github.com/mono/mono/commit/e0335d357056f9017f7c170ed41f5cb7e3e32399

4 years agoFix some compiler warnings for Win32/mingw64 build (mono/mono#15903)
Nikolay Sivov [Wed, 31 Jul 2019 12:18:53 +0000 (15:18 +0300)]
Fix some compiler warnings for Win32/mingw64 build (mono/mono#15903)

* [mono] Fix unused variable warning in mono_config_parse().

* [ligc] Fix strict prototype warning for Win32 build.

* Add some casts.

Commit migrated from https://github.com/mono/mono/commit/c8fd75734b7f34ed42968bf7ed9b315303b31abc

4 years agoRemove unused libdl setting (mono/mono#15884)
coypoop [Wed, 31 Jul 2019 12:17:34 +0000 (12:17 +0000)]
Remove unused libdl setting (mono/mono#15884)

We test dlopen with no library and in libdl later, without the
use of this setting.

Got the hint since I'm building for a configuration which had it set wrong.

Commit migrated from https://github.com/mono/mono/commit/bed4c00e02400bc49431af8b8095c76caea71220

4 years agoRemove unused declarations (mono/mono#15907)
coypoop [Wed, 31 Jul 2019 12:16:37 +0000 (12:16 +0000)]
Remove unused declarations (mono/mono#15907)

Commit migrated from https://github.com/mono/mono/commit/a65eec76be06778c355e2a74fc36cfa4e241a37a

4 years agoAlways marshal a class as a COM interface if it has the InterfaceType attribute set...
Zebediah Figura [Wed, 31 Jul 2019 12:15:38 +0000 (07:15 -0500)]
Always marshal a class as a COM interface if it has the InterfaceType attribute set. (mono/mono#15671)

This fixes Game Maker Studio 2 Desktop under Wine.

Commit migrated from https://github.com/mono/mono/commit/dc48d9e241e96e3fd26ce09f69bc2b2672f0f39e

4 years ago[cominterop] Handle NULL pointers when marshalling native-to-managed return values...
Zebediah Figura [Wed, 31 Jul 2019 12:14:39 +0000 (07:14 -0500)]
[cominterop] Handle NULL pointers when marshalling native-to-managed return values. (mono/mono#15906)

Fixes a bug running Rak24u with wine-mono: bugs.winehq.org/show_bug.cgi?id=47561

Commit migrated from https://github.com/mono/mono/commit/b51c696081a58515adf53a50e5746ed08bd1062e

4 years agoFix race condition and use less memory in mono_lookup_icall_symbol. (mono/mono#14532)
Jay Krell [Wed, 31 Jul 2019 12:13:21 +0000 (05:13 -0700)]
Fix race condition and use less memory in mono_lookup_icall_symbol. (mono/mono#14532)

It is racy because it is doing on-demand initialization, which is often racy.

The rewrite changes the result to be one pointer, atomically swapped, which implies a full barrier and data dependency, so no race.

It could also be fixed by copying and sorting an array of pairs, and one pointer to that.

However in order to save memory I instead use indirect data that is an array of uint16 pointing into the original data. That is a slight memory vs. time tradeoff.

Yes there is debugging code left, under #if, that I prefer to leave, both as evidence that I tested it, and to make it somewhat but ideally testable in future.

The code also was using an unnecessary somewhat risky but probably ok here way to compare pointers, that I fixed.

As well the result is marginally smaller and faster because it was inlining something like bubblesort, now reuses qsort.

Commit migrated from https://github.com/mono/mono/commit/c37fc12ca5edd9cbf169ac7e4ab5b2e6ef202f79

4 years ago[Coop] Add `TYPED_HANDLE_DECL`. (mono/mono#15909)
Jay Krell [Wed, 31 Jul 2019 10:35:59 +0000 (03:35 -0700)]
[Coop] Add `TYPED_HANDLE_DECL`. (mono/mono#15909)

Extracted from mono/mono#15900.

Commit migrated from https://github.com/mono/mono/commit/bd0c46a8422dc5bbfb6a41fcf913d8db8d817632

5 years agoUpdate CoreFX.issues.rsp (mono/mono#15870)
Filip Navara [Tue, 30 Jul 2019 21:39:34 +0000 (23:39 +0200)]
Update CoreFX.issues.rsp (mono/mono#15870)

Removed tests fixed by mono/mono#13907.
Fixes mono/mono#14945
Fixes mono/mono#14946
Fixes mono/mono#14948

Commit migrated from https://github.com/mono/mono/commit/60bb726eac6d33038d35c27b23f98c73ff5abc4d

5 years ago[Coop] Convert ves_icall_string_new_wrapper_impl. (mono/mono#15901)
Jay Krell [Tue, 30 Jul 2019 21:37:59 +0000 (14:37 -0700)]
[Coop] Convert ves_icall_string_new_wrapper_impl. (mono/mono#15901)

Static analysis prefers not even these short lived raw pointers.
Extracted from mono/mono#15900.

Commit migrated from https://github.com/mono/mono/commit/ca8f155983139beaa306b77cabc2dde365021bd0

5 years ago[Coop] Convert mono_string_from_byvalwstr_impl. (mono/mono#15902)
Jay Krell [Tue, 30 Jul 2019 21:37:09 +0000 (14:37 -0700)]
[Coop] Convert mono_string_from_byvalwstr_impl. (mono/mono#15902)

Remove the raw pointer that static analysis will flag.
Extracted from mono/mono#15900.

Commit migrated from https://github.com/mono/mono/commit/56082ab5284a61cb5e2ca764e71bbeaeee16c374

5 years ago[interp] Simplify the main interpreter loop code to speed up compilation. (mono/mono...
Zoltan Varga [Tue, 30 Jul 2019 20:02:27 +0000 (16:02 -0400)]
[interp] Simplify the main interpreter loop code to speed up compilation. (mono/mono#15889)

* [interp] Simplify the control flow in the main loop to speed up compilation of interp.c.

Get rid of the handle_finally and main_loop labels.

* [interp] Move some rarely used locals to InterpFrame to speed up compilation and to increase the chance that the other locals end up in registers.

* Add macros for throwing exceptions to shorten the code a bit.

* Fix a previous change.

Commit migrated from https://github.com/mono/mono/commit/f8fd60b5c088753a4a0ccb79483ebae73489e7a2

5 years ago[netcore] Replace dl-test-assets.py with msbuild download (mono/mono#15883)
Alexander Köplinger [Tue, 30 Jul 2019 17:27:42 +0000 (19:27 +0200)]
[netcore] Replace dl-test-assets.py with msbuild download (mono/mono#15883)

The python file was unreliable on macOS, let's see whether a simple msbuild replacement is better.

Also fixed dependencies on some of the Makefile targets so that they correctly detect when they need to run.

Commit migrated from https://github.com/mono/mono/commit/9f0d493eea7da2b9494f1e8185740a99fbee00a1

5 years agoFix warnings. (mono/mono#15768)
Jay Krell [Tue, 30 Jul 2019 10:10:30 +0000 (03:10 -0700)]
Fix warnings. (mono/mono#15768)

* boehm-gc.c:1923:14: warning: variable old_obj set but not used [-Wunused-but-set-variable]

* class-init.c:1720:1: warning: compare_by_interface_id defined but not used [-Wunused-function]

* class.c:1724:1: warning: compare_interface_ids defined but not used [-Wunused-function]

* icall.c:8190:13: warning: variable klass set but not used [-Wunused-but-set-variable]

* image.c:1063:20: warning: variable header set but not used [-Wunused-but-set-variable]

* metadata.c:2573:25: warning: right shift count >= width of type [-Wshift-count-overflow]

* sgen-dynarray.h:194:1: warning: dyn_array_int_is_copy defined but not used [-Wunused-function]

* sgen-mono.c:255:1: warning: emit_managed_allocater_noilgen defined but not used [-Wunused-function]
sgen-mono.c:238:1: warning: emit_nursery_check_noilgen defined but not used [-Wunused-function]

* sgen-tarjan-bridge.c:449:25: warning: right shift count >= width of type [-Wshift-count-overflow]

* threads.c:1451:11: warning: variable res set but not used [-Wunused-but-set-variable]

* w32process-unix-default.c:239:19: warning: variable min_dev set but not used [-Wunused-but-set-variable]
w32process-unix-default.c:239:10: warning: variable maj_dev set but not used [-Wunused-but-set-variable]

* w32process-unix.c:2107:25: warning: variable waitret set but not used [-Wunused-but-set-variable]

* aot-compiler.c:4180:1: warning: add_lazy_init_wrappers defined but not used [-Wunused-function]

* aot-compiler.c:7200:86: warning: format %lu expects argument of type long unsigned int, but argument 3 has type gsize {aka unsigned int} [-Wformat=]

* aot-compiler.c:10013:7: warning: unused variable index [-Wunused-variable]

* aot-compiler.c:10012:15: warning: variable method set but not used [-Wunused-but-set-variable]

* method-to-ir.c:4031:22: warning: variable tmpreg set but not used [-Wunused-but-set-variable]

* mini-runtime.c:2977:14: warning: variable invoke set but not used [-Wunused-but-set-variable]

* mono-rand.c:94:1: warning: mono_getentropy defined but not used [-Wunused-function]

Commit migrated from https://github.com/mono/mono/commit/a8d8fb6ceadde1fa0f7ae5dfe4a82f91442877f9

5 years agoRemove mono_thread_get_name. (mono/mono#15875)
Jay Krell [Tue, 30 Jul 2019 01:08:55 +0000 (18:08 -0700)]
Remove mono_thread_get_name. (mono/mono#15875)

Unused since https://github.com/mono/mono/commit/mono/mono@b5c0c831da328b8ab7b7283a38fa56baaa7ae380.
And not likely to come back.

Commit migrated from https://github.com/mono/mono/commit/f1958bacaad3efd3f6f824664d1db39d50d532bb

5 years agoHANDLE_FUNCTION_RETURN_VAL must not use handles in current frame (mono/mono#15873)
Jay Krell [Mon, 29 Jul 2019 23:39:44 +0000 (16:39 -0700)]
HANDLE_FUNCTION_RETURN_VAL must not use handles in current frame (mono/mono#15873)

Commit migrated from https://github.com/mono/mono/commit/929e3135bb12c55f6976763f43dda1371465d1fa

5 years agoFix thread name leak in debugger. (mono/mono#15858)
Jay Krell [Mon, 29 Jul 2019 09:31:14 +0000 (02:31 -0700)]
Fix thread name leak in debugger. (mono/mono#15858)

Commit migrated from https://github.com/mono/mono/commit/b5c0c831da328b8ab7b7283a38fa56baaa7ae380

5 years ago[Coop] Convert System.Buffer. (mono/mono#15861)
Jay Krell [Mon, 29 Jul 2019 09:30:16 +0000 (02:30 -0700)]
[Coop] Convert System.Buffer. (mono/mono#15861)

And inline `mono_array_handle_length`.
And remove `inline` in .c files a little -- it only belongs in .h.

Commit migrated from https://github.com/mono/mono/commit/babcdbdcbd354296a74fa038daf24c38853d9d20

5 years ago[interp] Optimize ldelema (mono/mono#15846)
Vlad Brezae [Sat, 27 Jul 2019 14:37:00 +0000 (17:37 +0300)]
[interp] Optimize ldelema (mono/mono#15846)

Makes the opcode 2-3x time faster

Commit migrated from https://github.com/mono/mono/commit/91b9ff3e535c6d635a07a2d84696a1e333c38800

5 years ago[WIP] [runtime] Convert WindowsIdentity.GetRoles () icall to coop. (mono/mono#15849)
Zoltan Varga [Sat, 27 Jul 2019 06:27:24 +0000 (02:27 -0400)]
[WIP] [runtime] Convert WindowsIdentity.GetRoles () icall to coop. (mono/mono#15849)

* [runtime] Convert WindowsIdentity.GetRoles () icall to coop.

* [runtime] Replace some Buffer icalls with Unsafe methods.

* Fix the windows build.

Commit migrated from https://github.com/mono/mono/commit/9f253249364fa7cfd158647525850c393acc9ec3

5 years ago[netcore] Fix building of nupkg (mono/mono#15855)
Alexander Köplinger [Fri, 26 Jul 2019 22:17:31 +0000 (00:17 +0200)]
[netcore] Fix building of nupkg (mono/mono#15855)

When https://github.com/mono/mono/commit/mono/mono@9010d2f290d28dc97ac276e0c0d32a2932b7550f was merged we stopped including mcs/build/config.make.
However, that file set the VERSION variable which wasn't migrated to the new netcore/config.make so the nuget package missed the version.

Additionally, System.Private.CoreLib sources were moved into the netcore folder and we now seemingly need to pass `-p:IsPackable=true` for dotnet pack to build the nuget package.

Commit migrated from https://github.com/mono/mono/commit/ae488c93e94e326fde066d78fb4311b149f30825

5 years ago[netcore] Implement AssemblyLoadContext.GetLoadedAssemblies() (mono/mono#15832)
Ryan Lucia [Fri, 26 Jul 2019 16:23:43 +0000 (12:23 -0400)]
[netcore] Implement AssemblyLoadContext.GetLoadedAssemblies() (mono/mono#15832)

* [netcore] Implement AssemblyLoadContext.GetLoadedAssemblies()

* No refonly on netcore

* Ifdef out AppDomain.GetAssemblies() on netcore

* Don't init the error

* Unnecessary ifdef

Commit migrated from https://github.com/mono/mono/commit/29428550c22384cfba20a0d2ab3f420caf082b73

5 years ago[netcore] Add a missing make dependency.
Zoltan Varga [Fri, 26 Jul 2019 02:58:39 +0000 (22:58 -0400)]
[netcore] Add a missing make dependency.

Commit migrated from https://github.com/mono/mono/commit/390353d48b802cdec1052bf85c71c538e578403f

5 years ago[metadata] Fields whose types are gparams with a reference type constraint aren't...
Aleksey Kliger (λgeek) [Thu, 25 Jul 2019 21:31:48 +0000 (17:31 -0400)]
[metadata] Fields whose types are gparams with a reference type constraint aren't blittlable. (mono/mono#15761)

* [metadata] Fields whose types are gparams with a reference type constraint
aren't blittlable.
Don't try to layout the field to find out if it's blittable.
For gshared gparams, follow the blittability of the constraint.

Fixes certain recursive examples.

```
using System;

namespace TestRecursiveType
{
    class Program
    {
        static void Main(string[] args)
        {
            SubClass subC = new SubClass();
            Console.WriteLine(subC.GetTest());
        }
    }

    public struct ValueTest<U>
    {
        // When U is instantiated with T, from BaseClass, we know it'll be a
// reference field, so we know the instantiation ValueTest<T> won't
// be blittable.
        public readonly U value;
    }

    public abstract class BaseClass<T> where T : BaseClass<T>
    {
        public ValueTest<T> valueTest = default(ValueTest<T>);
    }

    public class SubClass : BaseClass<SubClass>
    {
        private String test = "test";

        public string GetTest()
        {
            return test;
        }
    }
}
```

Fixes https://github.com/mono/mono/issues/15760

---

The failure is happening when we are doing mono_class_setup_fields ("BaseClass<T>") which needs to decide for each field whether it is blittable or not. So therefore we are trying to decide if ValueTest<T> (that is: the ValueTest<U> field inside BaseClass<T>) is blittable or not.

So we instantiate U with T.
Now to decide whether VaueTest<T> is blittable or not, we look at every field.
So then we look at T value.
To decide if T is blittable we first check if it's a reference type.

That check is currently inadequate for generic parameters - what the PR adds is the ability to see if theres a T : class constraint or a T : C constraint - where C is some class. As soon as we know that T's constraint will force it to be a reference type we can definitely say that T won't be blittable without having to initialize C, at all.

Previously, Mono would see that T is some kind of type for which it couldn't definitively decide that it's a reference type and it would call: mono_class_setup_fields (field_class) which would then try to setup the fields of the parent class BaseClass<T>. And that would hit the recursion check.

Commit migrated from https://github.com/mono/mono/commit/04517d3a3955c5a4a899d88c4af7987b2b277101

5 years ago[tests] Return non-zero exit code from MERP crash test on failure (mono/mono#15804)
Aleksey Kliger (λgeek) [Thu, 25 Jul 2019 15:20:12 +0000 (11:20 -0400)]
[tests] Return non-zero exit code from MERP crash test on failure (mono/mono#15804)

If any of the stress tests fail, return a non-zero exit code from the
supervising process.

Fixes mono/mono#15781

Commit migrated from https://github.com/mono/mono/commit/090dffb9a09f26dc250d8d09a46819d192290b0b

5 years ago[jit] [x86] Cleanup "_body" and finish conversion to x86_byte. (mono/mono#15628)
Jay Krell [Thu, 25 Jul 2019 13:18:20 +0000 (06:18 -0700)]
[jit] [x86] Cleanup "_body" and finish conversion to x86_byte. (mono/mono#15628)

Commit migrated from https://github.com/mono/mono/commit/ee34e2b1223c461c3d55e6f5a031cdfdaa18cd4a