platform/upstream/dotnet/runtime.git
5 years ago[netcore] Fix CI build script (mono/mono#15130)
Egor Bogatov [Sat, 15 Jun 2019 07:27:15 +0000 (10:27 +0300)]
[netcore] Fix CI build script (mono/mono#15130)

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

5 years agoRead only interp callbacks, option 4, without ordering sensitivity.
Jay Krell [Tue, 11 Jun 2019 07:21:35 +0000 (00:21 -0700)]
Read only interp callbacks, option 4, without ordering sensitivity.

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

5 years agoCleanup AIX code a little.
Jay Krell [Sat, 8 Jun 2019 01:06:22 +0000 (18:06 -0700)]
Cleanup AIX code a little.

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

5 years ago[netcore] Arcade does not yet have CLSCompliant support, revert to manual settings
Marek Safar [Fri, 14 Jun 2019 19:18:21 +0000 (21:18 +0200)]
[netcore] Arcade does not yet have CLSCompliant support, revert to manual settings

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

5 years agoImplementing reabstraction of default interface methods. (mono/mono#14790)
Thays Grazia [Fri, 14 Jun 2019 19:15:38 +0000 (16:15 -0300)]
Implementing reabstraction of default interface methods. (mono/mono#14790)

Implementing reabstraction of default interface methods.
Fix mono/mono#14495

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

5 years ago[netcore] Add more Arcade magic for signing
Marek Safar [Fri, 14 Jun 2019 17:52:02 +0000 (19:52 +0200)]
[netcore] Add more Arcade magic for signing

Commit migrated from https://github.com/mono/mono/commit/49dc99be58d66f53809b5cda2c7b8e2b9aeaaf96

5 years ago[metadata] Move problematic image out-param usage (mono/mono#15131)
Alexander Kyte [Fri, 14 Jun 2019 18:38:09 +0000 (14:38 -0400)]
[metadata] Move problematic image out-param usage (mono/mono#15131)

Commit migrated from https://github.com/mono/mono/commit/877a2b65488199dd3e1802e44a5eef3bf932ba4f

5 years ago[mini] Move some MONO_API functions to public header (mono/mono#15105)
Aleksey Kliger (λgeek) [Fri, 14 Jun 2019 15:33:11 +0000 (11:33 -0400)]
[mini] Move some MONO_API functions to public header (mono/mono#15105)

* [mini] Move some MONO_API functions to public header

And mark them all MONO_RT_EXTERNAL_ONLY.

mono_set_use_llvm is new - Xamarin.Android previously assigned to mono_use_llvm
directly.

Commit migrated from https://github.com/mono/mono/commit/0e0f1b9be08ff14b192fdadc66efb6bb763867a4

5 years agoFix csproj
Egor Bogatov [Fri, 14 Jun 2019 10:15:02 +0000 (13:15 +0300)]
Fix csproj

Commit migrated from https://github.com/mono/mono/commit/4212270b231bcc158f75fd19a4503eac979032ec

5 years agoDeadlock in loader when using bundling. (mono/mono#15061)
Johan Lorensson [Fri, 14 Jun 2019 09:20:28 +0000 (11:20 +0200)]
Deadlock in loader when using bundling. (mono/mono#15061)

We can hit the following deadlock when loading assemblies (using reflection)
together with bundling:

One thread calls mono_assembly_open_from_bundle, that will take assemblies lock
and then try to load assembly. If this race with a different load of the
same assemblies, one will lose, and that method will call mono_image_close that
in turn will call unload hook (mono_class_unregister_image_generic_subclasses)
that will take loader lock.

If we at the same time have a different thread that calls mono_class_create_from_typedef
, it will take loader lock and then it might end up calling mono_assembly_load_reference
that will take assemblies lock, but since that thread takes the locks
in different order compare to first thread, they could deadlock.

Looking into the use of assemblies lock in mono_assembly_open_from_bundle it
uses a static variable, bundles, that is not protected in other scenarios
and only set by mono_register_bundled_assemblies, normally called during
boot. The method called in the loop mono_image_open_from_data_internal is called
at several places without locks (and looks internal using image lock), so that
doesn't need to be protected. The rest is local data access and the only thing the
lock could do is serialize the whole loop between threads (but that shouldn't be needed).

Fix will remove the locking and also eliminating the incorrect lock order
causing the deadlock.

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

5 years ago[netcore] Clean up netcore build
Marek Safar [Thu, 13 Jun 2019 10:03:42 +0000 (12:03 +0200)]
[netcore] Clean up netcore build

Commit migrated from https://github.com/mono/mono/commit/9010d2f290d28dc97ac276e0c0d32a2932b7550f

5 years agoFix S390x compile since mono/mono#14870 and a warning. (mono/mono#15056)
Jay Krell [Fri, 14 Jun 2019 05:37:06 +0000 (22:37 -0700)]
Fix S390x compile since mono/mono#14870 and a warning. (mono/mono#15056)

Commit migrated from https://github.com/mono/mono/commit/467fd6516bc964d4076702c90203ff31dddc848e

5 years ago[wasm] fix most cases of numeric debugging for wasm
Larry Ewing [Fri, 24 May 2019 04:42:26 +0000 (23:42 -0500)]
[wasm] fix most cases of numeric debugging for wasm

Fix the signededness of numeric types and use double
for the display of everthing since we are stuck with that
on the js side.

Commit migrated from https://github.com/mono/mono/commit/56e27ca309f45a4baf5e18632bc28b2abf9f7f9f

5 years agoDon't create a cycle when translating IL `break` to IR. (mono/mono#14980)
imhameed [Thu, 13 Jun 2019 17:56:07 +0000 (10:56 -0700)]
Don't create a cycle when translating IL `break` to IR. (mono/mono#14980)

Don't create a cycle when translating IL `break` to IR.

`mono_emit_jit_icall` adds the instruction it generates to the current
basic block, and the redundant use of `MONO_ADD_INS` on an instruction
that has already been added to a BB will create a cycle in the `prev`
link chain.

Fixes mono/mono#9706.

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

5 years agoPropagate error in mono_unicode_to_external (mono/mono#14879)
Ryan Lucia [Thu, 13 Jun 2019 15:03:35 +0000 (11:03 -0400)]
Propagate error in mono_unicode_to_external (mono/mono#14879)

* Add internal version of mono_unicode_to_external to propagate error

* Migrate things to _error version where sensible

* Remove redundant goto

* Print input string when conversion fails

* Remove todos

* Switch everything to MonoError

* Naming: err -> error

* Actually print out *filename correctly

Commit migrated from https://github.com/mono/mono/commit/20d83c24d6fe412a6afe62652b671526ab7d12cf

5 years ago[netcore] Bump roslyn version
Marek Safar [Thu, 13 Jun 2019 07:42:00 +0000 (09:42 +0200)]
[netcore] Bump roslyn version

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

5 years ago[crash] Print native module name when crash privacy disabled (mono/mono#14986)
Alexander Kyte [Thu, 13 Jun 2019 07:07:10 +0000 (03:07 -0400)]
[crash] Print native module name when crash privacy disabled (mono/mono#14986)

This makes it so that disabling crash privacy ensures we get the full native symbols printed regardless of allow and deny lists.

Before: https://gist.github.com/alexanderkyte/2b1f38a880c61ea15aa4c851e44af578

After: https://gist.github.com/alexanderkyte/ce80788a51761d91890d812874fa2da2

Commit migrated from https://github.com/mono/mono/commit/4ba594ad2550192936a1f8a8cf2d0976fc775660

5 years ago[netcore] Enable CoreFX tests on CI for Linux (mono/mono#15015)
Egor Bogatov [Wed, 12 Jun 2019 16:55:45 +0000 (19:55 +0300)]
[netcore] Enable CoreFX tests on CI for Linux (mono/mono#15015)

* Enable CoreFX tests on CI for Linux

* implement NativeLibrary.Unix.cs

* add missing libc

* add few -nonamespace

* more flaky tests

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

5 years agoEnable the compiler server by default
Larry Ewing [Thu, 6 Jun 2019 18:41:45 +0000 (13:41 -0500)]
Enable the compiler server by default

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

5 years ago[runtime] Fix gshared support for BeginInvoke ()/EndInvoke () wrappers. (mono/mono...
Zoltan Varga [Wed, 12 Jun 2019 13:18:14 +0000 (09:18 -0400)]
[runtime] Fix gshared support for BeginInvoke ()/EndInvoke () wrappers. (mono/mono#14985)

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

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

5 years ago[jit] Fix interface cast (mono/mono#14978)
Vlad Brezae [Wed, 12 Jun 2019 12:42:46 +0000 (15:42 +0300)]
[jit] Fix interface cast (mono/mono#14978)

* [jit] Throw exception if casting fails for special array interface

After the standard interface check (mini_emit_iface_cast), for special interfaces we need to do additional checks. We were skipping these checks if the object was not an array, without throwing a cast exception. This code path is reached for configurations where remoting is disabled.

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

* [tests] Add test for interface casting case

This test would have failed on fullaot lane for example.

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

5 years agoPlug leak of ppdb_filename
Marius Ungureanu [Mon, 20 May 2019 22:32:31 +0000 (01:32 +0300)]
Plug leak of ppdb_filename

mono_image_open_metadata_only and its callees all dupe the filename string, so free the string after mono_image_open_metadata_only is done with it:

```
      1 (128 bytes) ROOT LEAK: 0x7fb07f086c80 [128]  length: 105  "/Users/therzok/Work/md/md-addins/external-addins/MonoDevelop.MonoDroid/build/Xamarin.Installer.Common.pdb"
```

Commit migrated from https://github.com/mono/mono/commit/669629330f9fe5b8cf9426bd34afb52d55404070

5 years ago[runtime] Switch to GC Unsafe for all GC external API functions
Aleksey Kliger [Tue, 11 Jun 2019 14:55:58 +0000 (10:55 -0400)]
[runtime] Switch to GC Unsafe for all GC external API functions

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

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

5 years ago[netcore] Run CoreFX tests on CI (macOS) (mono/mono#14849)
Egor Bogatov [Wed, 12 Jun 2019 07:40:15 +0000 (10:40 +0300)]
[netcore] Run CoreFX tests on CI (macOS) (mono/mono#14849)

Commit migrated from https://github.com/mono/mono/commit/56398813ae5dd9b363888bc1d221b75035051afc

5 years ago[aot] Open AOT profile files using "rb" so it works on windows.
Zoltan Varga [Wed, 12 Jun 2019 00:13:34 +0000 (20:13 -0400)]
[aot] Open AOT profile files using "rb" so it works on windows.

Fixes https://github.com/xamarin/xamarin-android/issues/3168.

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

5 years ago[llvm] Fix disabling direct calls and inlining (mono/mono#14880)
Alexander Kyte [Tue, 11 Jun 2019 16:30:05 +0000 (12:30 -0400)]
[llvm] Fix disabling direct calls and inlining (mono/mono#14880)

* [llvm] Enable disabling inlining on llvm

* [llvm] Fix disabling direct calls on llvm

* [llvm] Rename mono_inited even when doing self_init (generated init functions refer to it)

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

5 years ago[install] Include .exe extension when symlinking the mono binary (mono/mono#14958)
Aleksey Kliger (λgeek) [Tue, 11 Jun 2019 13:42:24 +0000 (09:42 -0400)]
[install] Include .exe extension when symlinking the mono binary (mono/mono#14958)

Prevent the SDKs from making dangling symlinks when packaging the MXE
cross-compilers: should hav

    mono.exe -> mono-sgen.exe

rather than

    mono -> mono-sgen (dangling).

Commit migrated from https://github.com/mono/mono/commit/5440491ae8b4b65a4e2010f86e425b265e825250

5 years agoMerge pull request mono/mono#14811 from lateralusX/lateralusX/fix-lmf-with-ctx-window...
Johan Lorensson [Tue, 11 Jun 2019 11:22:18 +0000 (13:22 +0200)]
Merge pull request mono/mono#14811 from lateralusX/lateralusX/fix-lmf-with-ctx-windows-msvc

Fix interpreter failure in install_eh_callback.exe under Windows x64 MSVC.

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

5 years agoRemove JIT icall hashing by address. (mono/mono#14870)
Jay Krell [Tue, 11 Jun 2019 04:40:39 +0000 (21:40 -0700)]
Remove JIT icall hashing by address. (mono/mono#14870)

* Work toward removing JIT icall hashing by address.

* Remove JIT icall hashing by address.

* Cleanup amd64 emit_call use.

* Move MonoJumpInfoTarget to among types, not functions.
If mini.h includes mini-runtime.h, then can move it nearer MonoJumpInfo.
Or if returned by out parameter (pointer) instead of struct by value.
Or pair of out parameters instead of struct.

* Closer to historical semantics, at least to avoid assertion failure, will try to refine in a later PR.

* Remove new comments about partial barriers, I think the comments are wrong and the code is correct (except that lock/unlock probably need to be full barriers, if they are not.)

* PR: Don't worry about size of MonoCallInst.jit_icall_id. Let it be 32 or 64 bits instead of 9.

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

5 years ago[wasm] Prototype for collecting aot profile data. (mono/mono#14865)
Zoltan Varga [Sun, 9 Jun 2019 03:16:18 +0000 (23:16 -0400)]
[wasm] Prototype for collecting aot profile data. (mono/mono#14865)

* [runtime] Add some options to the aot profiler:
- write-at-method=<METHOD> Write the data when <METHOD> is compiled.
- send-to-method=<METHOD> Call <METHOD> with the collected data.

* [wasm] Fix profiler support in the packager.

* [wasm] Add prototype for generating aot profile data.

* Fix indentation.

Commit migrated from https://github.com/mono/mono/commit/23a928826cd88cf45fe2e3af1e2ef5a60ef88d34

5 years agoCleanup amd64 emit_call / emit_call_body -- last parameter always FALSE. (mono/mono...
Jay Krell [Sat, 8 Jun 2019 17:38:01 +0000 (10:38 -0700)]
Cleanup amd64 emit_call / emit_call_body -- last parameter always FALSE. (mono/mono#14897)

And it is reasonable to expect that to remain the case, as C compilers
do not generate code as would occur with the last parameter = TRUE.

They allocate the room for their maximum outgoing parameters at function entry,
and keep a constant stack, except for functions that call _alloca,
and this code risks but not necessarily breaks ABI compliance.

In particular, the rsp adjustment either needs unwind codes, or needs
to only occur in a function with a frame pointer other than RSP.

And the uwind codes for adding to RSP are very tricky to impossible.
Normally you only ever subtract from RSP. There is an unwind code for that.
But there isn't really for add.
You might be able to simulate it with chained unwind, making these
regions look kinda like end of function.
But this is all most unlikely.

Commit migrated from https://github.com/mono/mono/commit/63f17d2f553083cde0a9afdab5e4c4bbff944f29

5 years ago[wasm] Switch to the LLVM wasm backend. (mono/mono#14734)
Zoltan Varga [Sat, 8 Jun 2019 04:46:56 +0000 (00:46 -0400)]
[wasm] Switch to the LLVM wasm backend. (mono/mono#14734)

* [wasm] Switch to the llvm wasm backend.

* [wasm] Packager changes for the wasm backend.

* -s EMULATED_FUNCTION_POINTERS=1 no longer needed.
* Run wasm-strip on the final binary.
* Run opt during AOT.
* Disable the dynamic build for now, it doesn't seem to work with the wasm backend.

* [wasm] Use STACK_MAX instead of STACK_BASE for the bottom limit of the stack.

* [aot] Handle llvmopts= in llvmonly mode as well.

* [wasm] Disable an assertion which is no longer true with the wasm backend.

* [wasm] Disable computed gotos in the interpreter, the wasm backend doesn't support it.

Fix llvm target layout so its compatible with clang compiled code.

* [wasm] Pass llvm-path to the cross compiler.

* [wasm] Fix some problems with the dynamic build, still doesn't work. Fix packaging.

* [wasm] Pass -s DISABLE_EXCEPTION_CATCHING=0 to the runtime build, otherwise catch clauses are not generated in llvm-runtime.cpp.

* [aot] Allow llvmopts= argument multiple times.

* Bump emscripten version to 1.38.34.

* [wasm] Add https://github.com/emscripten-core/emscripten/pull/8457 as a patch.

* [wasm] Compile the aot .bc files to .o in a separate step using emcc, this will help with incremental compilation later.

* [wasm] Source emsdk_set_env.sh instead of emsdk_env.sh the latter calls emsdk construct_env to construct emsdk_set_env.sh which is racy.

Commit migrated from https://github.com/mono/mono/commit/16532397c362cf66da55be388dc84bb7b3ad6ad1

5 years ago[crash] Move /proc/self/maps crash collection to created JSON blob (mono/mono#14704)
Alexander Kyte [Fri, 7 Jun 2019 19:18:57 +0000 (15:18 -0400)]
[crash] Move /proc/self/maps crash collection to created JSON blob (mono/mono#14704)

* [runtime] Don't print /proc/self/maps on Android

* [runtime] Add proc mapping to crash JSON output

* [runtime] Zero initialize locals in threading macros

* [crash] Filter out illegal characters from process_maps

* [crash] Prevent concurrent reads from /proc/self/maps

* [crash] Clean up memset in g_async_safe_fgets

* [crash] Remove stack staging array in async_safe_fgets

* Revert "[crash] Prevent concurrent reads from /proc/self/maps"

This reverts commit mono/mono@f65166559ad24ad65c530f7abbc096e4d4634878.

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

5 years agoAIX/PASE integration improvements (mono/mono#14652)
Calvin Buckley [Fri, 7 Jun 2019 18:02:44 +0000 (11:02 -0700)]
AIX/PASE integration improvements (mono/mono#14652)

* Allow using SysV-style sonames on AIX/PASE

This uses a far saner naming convention with libtool, and is
consistent with the official PASE RPM repository. However, some
loader changes are required to make it "just work" and workaround
some real dumb behaviour on AIX's part.

Note that while Mono works when built without the different soname
tweak, it won't when installed, because the convention is strange
and the libtool .la archives won't be installed. It's recommended
as such that installation of Mono keeps the libtool files or just
uses SVR4 sonames like the rest of the world, even if they're made
strange like AIX.

* Specify a specific version of unixODBC, make an include

A workaround against PASE RPMs of unixODBC not including the just
"libodbc.so" except in the development version. If a platform needs
a specific version (the macOS reference not changed in the DllMap)
then it can be specified in the configure script.

AIX doesn't need a special name because both AIX Toolbox and Perzl
include non-archive libraries in /opt/freeware/lib - unexpected.

* Don't try to use shm_open on PASE due to it not being implemented

All this will do is cause a coredump if running the script on PASE,
and write an entry to the SLIC diagnostic logs. This test could be
re-enabled if i 7.4 supports it properly.

* fix ODBC include

* Check for what library to use for libintl when dlopenning on AIX

These checks are for the benefit of the DllMap. The construct used
is kinda hacky, IMHO, but it resolves the concerns of hardcoding.
In the event that this doesn't work (it does for me), it falls back
to what the IBM RPMs seem to use for linking gettext et al.

Not sure of the utility for other platforms, since they usually
use sane soname conventions and the one-liner here depends heavily
on an AIX developer tool and its output format.

The use of cut/awk should work with the stock AIX utils, no GNU
necessarily needed.

Commit migrated from https://github.com/mono/mono/commit/18e0ebfe89be0a175d2f904b9bb1ec6816daa318

5 years agoBump CoreFX to pickup https://github.com/mono/corefx/pull/298. (mono/mono#14851)
Martin Baulig [Fri, 7 Jun 2019 17:14:21 +0000 (13:14 -0400)]
Bump CoreFX to pickup https://github.com/mono/corefx/pull/298. (mono/mono#14851)

Commit migrated from https://github.com/mono/mono/commit/96125c693c5164347da9fba14a3c936d16fef86e

5 years ago[runtime] Make cross-appdomain wrappers throw NIE for methods with ref struct args...
Aleksey Kliger (λgeek) [Fri, 7 Jun 2019 11:06:32 +0000 (07:06 -0400)]
[runtime] Make cross-appdomain wrappers throw NIE for methods with ref struct args (mono/mono#14863)

* [AppDomain] Cross-appdomain wrapper throws NIE for methods with ref struct arguments

If we have a ref struct and a method that takes it as an argument:

```
[Serializable]
public ref struct R {
  public int i;
}

public interface I {
  public void M1 (R r, SomeClass o);
}

public class M : MarshalByRefObject, I {
  public void M1 (R r, SomeClass o) { ... }
}
```

If we create an instance of M in another domain and try to call it:
```
  I obj = (I)otherDomain.CreateInstanceAndUnwrap (typeof(M).Assembly.FullName,
  nameof(M));
  R r;
  r.i = 42;
  SomeClass o = ...;
  obj.M1 (r, o);
```

Mono will need to create a wrapper that can invoke M.M1 in the other domain.
The way the wrapper works in `mono_marshal_get_xappdomain_invoke` is by
creating an array of all the arguments that need to be serialized (see
`mono_get_xdomain_marshal_type`) and then serializing the whole array (by
calling out to `System.Runtime.Remoting.RemotingServices.SerializeCallData`).
In the example it would make a two element array and try to serialize `r` and
`o` into it. For valuetypes it normally does this by boxing the argument.
However since `R` is a ref-struct, boxing it is not allowed.

This works on .NET Framework.

However for Mono we would need to serilize `R` without boxing it, which seems
challenging with our current setup.

So for now we generate a wrapper that just throws a NotImplementedException if
it is ever called.

This fixes https://github.com/mono/mono/issues/14809 (in that marshalling a
TextWriter across domains works again) but in an unsatisfactory way (because
you can't call any of the ReadOnlySpan<char> overloads on the transparent proxy
object).

* [corlib] Add back Serializable attribute on some reflection classes

Tests that use https://www.nuget.org/packages/NUnit.ApplicationDomain/
need to serialize MethodInfo (and hence MethodBase).

* [corlib] Add test for transparent proxies for classes with methods that take
ref struct args

Regression test for https://github.com/mono/mono/issues/14809

* Bump API snapshot submodule

Commit migrated from https://github.com/mono/mono/commit/277bbdaada789bb9b61a71aa45475d914b457494

5 years agoRemove exclusions for resolved issue
Ryan Lucia [Thu, 6 Jun 2019 20:42:03 +0000 (16:42 -0400)]
Remove exclusions for resolved issue

Commit migrated from https://github.com/mono/mono/commit/65608fe3f412a08289239e6146f0dc21f71ce1c9

5 years agoAdd logic to object array typecheck to handle arrays of unmanaged pointers (mono...
Ryan Lucia [Thu, 6 Jun 2019 19:38:57 +0000 (15:38 -0400)]
Add logic to object array typecheck to handle arrays of unmanaged pointers (mono/mono#14733)

Fixes mono/mono#14555

The NULL check alone is not enough, because interfaces are also parented to NULL for some reason, and so I've moved `class_kind` out from the bitfield section to make it accessible from IR. The beginning of the struct is going to be padded to 32 bits anyway at the least, so this move should save space if anything.

Our type checking overall is not very robust, and in particular the supertype comparison doesn't work well for anything that isn't an object, so it's possible there are some other weird corner cases. As far as I can tell looking through the array of objects stuff though, we should have reasonable coverage with the existing tests + the stuff I added.

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

5 years agoSwitch supported runtimes storage from an array to a list (mono/mono#14777)
Ryan Lucia [Thu, 6 Jun 2019 19:02:57 +0000 (15:02 -0400)]
Switch supported runtimes storage from an array to a list (mono/mono#14777)

Fixes mono/mono#12141

Switched to a list because in theory any number of tags can be present. Old behavior was to put them into an array of size 3 and zero the byte following them, which was causing the crash with more than two tags. There's no null check for the default runtime because that should never happen, and the list is reversed to preserve the order from the XML. Changing the signature of `get_runtimes_from_exe` should be fine because it's static and only called in the one place.

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

5 years ago[mach] cast objc_msgSend{,Super} usages (mono/mono#14836)
Bernhard Urban [Thu, 6 Jun 2019 18:14:59 +0000 (20:14 +0200)]
[mach] cast objc_msgSend{,Super} usages (mono/mono#14836)

Fixes mono/mono#14792

Commit migrated from https://github.com/mono/mono/commit/812357ec51f771c69f54694e9fa88ee49180eb62

5 years ago[llvm] emit call to mini_llvmonly_throw_nullref_exception without exceptions in mind...
Bernhard Urban [Thu, 6 Jun 2019 17:24:20 +0000 (19:24 +0200)]
[llvm] emit call to mini_llvmonly_throw_nullref_exception without exceptions in mind (mono/mono#14840)

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

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

5 years ago[runtime] Gracefully skip AOTing problematic assemblies (mono/mono#14232)
Alexander Kyte [Thu, 6 Jun 2019 16:07:31 +0000 (12:07 -0400)]
[runtime] Gracefully skip AOTing problematic assemblies (mono/mono#14232)

Commit migrated from https://github.com/mono/mono/commit/364a8423e3e64cc199a8f43c6e0738118fb10f8a

5 years ago[netcore] Improve netcore/build.sh script (mono/mono#14835)
Egor Bogatov [Thu, 6 Jun 2019 15:43:58 +0000 (18:43 +0300)]
[netcore] Improve netcore/build.sh script (mono/mono#14835)

* Improve netcore/build.sh

* bump corefx tests version

* ignore StringTests failures

* Ignore more tests for xtestall

* Implement Environment.TickCount64

* cleanup

* Add two debug-* rules

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

5 years ago[thread] Print function name when asserting MonoThreadInfo is non-NULL (mono/mono...
Jay Krell [Thu, 6 Jun 2019 07:40:39 +0000 (00:40 -0700)]
[thread] Print function name when asserting MonoThreadInfo is non-NULL (mono/mono#13814)

https://github.com/mono/mono/issues/13813.

Commit migrated from https://github.com/mono/mono/commit/515234a128318cc199df0cca9cccdbf06fe72fdb

5 years ago[wasm][bcl] Use zlib for DeflateStream on WASM profile (mono/mono#14308)
Kenneth Pouncey [Thu, 6 Jun 2019 03:07:56 +0000 (05:07 +0200)]
[wasm][bcl] Use zlib for DeflateStream on WASM profile (mono/mono#14308)

* [wasm][bcl] Use zlib for DeflateStream on WASM profile

- Add `-s USE-ZLIB=1` flag for the emscripten build of `mono.js`
- Add new `zlib-helper` module build that is included in the `mono` wasm build.
- This adds roughly 300 kb to the size.

* Add zlib calls to `icall` for `WASM` profile

* Address comments use `TARGET_WASM` instead of `HOST_WASM`

* Hack around JS exception: RuntimeError: indirect call signature mismatch

- Instead of using the function pointer from DeflateStream (Marshal.GetFunctionPointerForDelegate) obtain the callback functions from the object itself.

* Update error messages and add exception parameter to `mono_runtime_invoke`.

* Add `mono/support` zlib include sources files to make `package` target.

* Add `zlib-helper` build to packager.

- Note: Right now only supports zlib build from mono tree build.
- Add `zlibtest.cs` scenario to compress and uncompress using DeflateStream and GZip.
- Add test to make file to build and run aot version of ziplibtest.

* Add copy of zlib header support files to `package-wasm-runtime`

- The support library is not built for wasm but the zlib include files are needed to build support during wasm build.
- See mono.js build and the use of the `-s USE_ZLIB=1` flag.
- The include files will be used in packager.exe to build zlib support for wasm.

* Use the zlib includes from support to build the zlib support.

* Setup base tests for testing System.IO.Compression integration

* Formatting

* Add more ziparchive tests

* Formatting and indentation

* Add more Zip tests

* Add more tests.

- Add more tests for ZipArchive.
- Add tests for Deflate - small, large and very large strings.
- Add tests for GZipStream - small, large and very large strings.

* Fix merge of EMCC_FLAGS

* Add new option to packager to enable the use of zlib

-   --enable-zlib (enable the use of zlib for System.IO.Compression support)
        type: bool  default: false

- update packager doc

* Address review comments

- Change `enable-zlib` to `zlib`

Commit migrated from https://github.com/mono/mono/commit/0562fde077f11bfd81ae0c2ce5c467ae2928c259

5 years agoFix build on macOS 10.15 Catalina + xcode 11 (mono/mono#14820)
Egor Bogatov [Wed, 5 Jun 2019 22:39:05 +0000 (01:39 +0300)]
Fix build on macOS 10.15 Catalina + xcode 11 (mono/mono#14820)

1) CC_MD5_Init, CC_MD5_Update and CC_MD5_Final are deprecated.

```c
mono-md5.c:45:2: error: 'CC_MD5_Init' is deprecated: first deprecated in macOS 10.15 - This function is
      cryptographically broken and should not be used in security contexts. Clients should migrate to SHA256
      (or stronger). [-Werror,-Wdeprecated-declarations]
        CC_MD5_Init (ctx);
        ^
```

2) objc_msgSend is deprecated
```
mono-threads-mach-helper.c:95:17: error: too many arguments to function call, expected 0, have 2
                objc_msgSend (value, release);
                ~~~~~~~~~~~~  ^~~~~~~~~~~~~~
```
XCode has a special switch `Enable Strict Checking of objc_msgSend Calls` which is now `true` by default. It's fixed by `-DOBJC_OLD_DISPATCH_PROTOTYPES=1` flag to clang or the corresponding define in the source file.

3) Fixes https://github.com/mono/mono/issues/14793

It worked on pre 10.15 without `-framework GSS`, because it got pulled in through the dependencies. You can see it by running DYLD_PRINT_LIBRARIES=1 csharp and then trace it back. On Mojave /System/Library/Frameworks/GSS.framework/Versions/A/GSS got loaded as dependency of /usr/lib/libcups.2.dylib and so on. Unlike Windows, macOS will resolve the symbols to whatever is already available so it was just happy that someone loaded GSS before libmono-native[-compat/-unified].

Commit migrated from https://github.com/mono/mono/commit/181a602acee3bcc1ac529ff41c254f794052ca71

5 years ago[interp] Inline more methods (mono/mono#14755)
Vlad Brezae [Wed, 5 Jun 2019 20:05:30 +0000 (23:05 +0300)]
[interp] Inline more methods (mono/mono#14755)

* [interp] Add support for inlining methods with locals

For each local in the inlined method we allocate a new local in the parent method.

* [interp] Enable inlining of methods using ldarga opcode

* [interp] Don't inline methods that do localloc

Inlining localloc in a loop leads to stack overflows. JIT has same behavior.

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

5 years agoReflect recent NS2.1 changes (mono/mono#14679)
Egor Bogatov [Wed, 5 Jun 2019 18:44:47 +0000 (21:44 +0300)]
Reflect recent NS2.1 changes (mono/mono#14679)

Due to few recent updates to dotnet/standard (NETStandard 2.1) we had 40 apicompat issues.
Mostly copy-pasted from dotnet/corefx.
Didn't implement Cryptography stuff yet.
Checked all profiles.

Implements mono/mono#14609

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

5 years ago[jit] Treat ternary operations as non-constant during constant evaluation and propaga...
imhameed [Wed, 5 Jun 2019 15:42:18 +0000 (08:42 -0700)]
[jit] Treat ternary operations as non-constant during constant evaluation and propagation (mono/mono#14782)

* Treat ternary operations as non-constant... (mono/mono#13873)

...during constant evaluation and propagation.

* Move ternary SSA cfold test from basic.cs to objects.cs.

Commit migrated from https://github.com/mono/mono/commit/993d4842854c1a5cfd4f50f880c1e5b4067479ee

5 years ago[arm64] Correct exception filter stack frame size (mono/mono#14757)
Brendan Zagaeski [Wed, 5 Jun 2019 15:38:07 +0000 (08:38 -0700)]
[arm64] Correct exception filter stack frame size (mono/mono#14757)

* [arm64] Correct exception filter stack frame size

Fixes: https://github.com/mono/mono/issues/14170
Fixes: https://github.com/xamarin/xamarin-android/issues/3112

The `call_filter()` function generated by `mono_arch_get_call_filter()`
was overwriting a part of the previous stack frame because it was not
creating a large enough new stack frame for itself.  This had been
working by luck before the switch to building the runtime with Android
NDK r19.

I used a local build of [xamarin/xamarin-android/d16-1@87a80b][0] to
verify that this change resolved both of the issues linked above.  I
also confirmed that I was able to reintroduce the issues in my local
environment by removing the change and rebuilding.

After this change, the generated `call_filter()` function now starts by
reserving sufficient space on the stack to hold a 64-bit value at the
`ctx_offset` location.  The 64-bit `ctx` value is saved to the
`ctx_offset` location (offset 344 in the new stack frame) shortly
afterwards:

    stp x29, x30, [sp,#-352]!
    mov x29, sp
    str x0, [x29,mono/mono#344]

As expected, the invocation of `call_filter()` now no longer modifies
the top of the previous stack frame.

Top of the stack before `call_filter()`:

    (gdb) x/8x $sp
    0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
    0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071

Top of the stack after `call_filter()` (unchanged):

    (gdb) x/8x $sp
    0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
    0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071

Additional background information
=================================

The original lucky, "good" behavior worked as follows for
[mono/mono/2018-08@725ba2a built with Android NDK r14][1]:

 1. The `resume` parameter for `mono_handle_exception_internal()` is
    held in register `w23`.

 2. That register is saved into the current stack frame at offset 20 by
    a `str` instruction:

           0x00000000000bc1bc <+3012>: str w23, [sp,mono/mono#20]

 3. `handle_exception_first_pass()` invokes `call_filter()` via a `blr`
    instruction:

        2279 filtered = call_filter (ctx, ei->data.filter);
           0x00000000000bc60c <+4116>: add x9, x22, x24, lsl mono/mono#6
           0x00000000000bc610 <+4120>: ldr x8, [x8,mono/mono#3120]
           0x00000000000bc614 <+4124>: ldr x1, [x9,mono/mono#112]
           0x00000000000bc618 <+4128>: add x0, sp, mono/mono#0x110
           0x00000000000bc61c <+4132>: blr x8

    Before the `blr` instruction, the top of the stack looks like this:

        (gdb) x/8x $sp
        0x7fcd2774a0: 0x7144d250 0x00000000 0x0a8b31d8 0x00000071
        0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071

 4. `call_filter()` runs.  This function is generated by
    `mono_arch_get_call_filter()` and starts with:

           stp x29, x30, [sp,#-336]!
           mov x29, sp
           str x0, [x29,mono/mono#344]

    Note in particular how the first line subtracts 336 from `sp` to
    start a new stack frame, but the third line writes to a position
    that is 344 bytes beyond that, back within the *previous* stack
    frame.

 5. After the invocations of `call_filter()` and
    `handle_exception_first_pass()`, `w23` is restored from the stack:

           0x00000000000bc820 <+4648>: ldr w23, [sp,mono/mono#20]

    At this step, the top of the stack looks like this:

        (gdb) x/8x $sp
        0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
        0x7fcd2774b0: 0x00000000 0x00000000 0x1ef51980 0x00000071

    Notice how `call_filter()` has overwritten bytes 8 through 15 of the
    stack frame.  In this original lucky scenario, this does not affect
    the value restored into register `w23` because that value starts at
    byte 20.

 6. `mono_handle_exception_internal()` tests the value of `w23` to
    decide how to set the `ji` local variable:

        2574 if (resume) {
           0x00000000000bb960 <+872>: cbz w23, 0xbb9c4 <mono_handle_exception_internal+972>

    Since `w23` is `0`, `mono_handle_exception_internal()` correctly
    continues into the `else` branch.

The bad behavior for
[mono/mono/2018-08@725ba2a built with Android NDK r19][2]
works just slightly differently:

 1. As before, the local `resume` parameter starts in register `w23`.
 2. This time, the register is saved into the stack frame at offset 12
    (instead of 20):

           0x00000000000bed7c <+3200>: str w23, [sp,mono/mono#12]

 3. As before, `handle_exception_first_pass()` invokes `call_filter()`
    via a `blr` instruction.

    At this step, the top of the stack looks like this:

        (gdb) x/8x $sp
        0x7fcd2774a0: 0x7144d250 0x00000000 0x2724b700 0x00000000
        0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071

 4. `call_filter()` runs as before.  And the first few instructions of
    that function are the same as before:

        stp x29, x30, [sp,#-336]!
        mov x29, sp
        str x0, [x29,mono/mono#344]

 5. `w23` is again restored from the stack, but this time from offset 12:

           0x00000000000bf2c0 <+4548>: ldr w23, [sp,mono/mono#12]

    The problem is that `call_filter()` has again overwritten bytes 8
    through 15 of the stack frame:

        (gdb) x/8x $sp
        0x7fcd2774a0: 0x7144d250 0x00000000 0xcd2775b0 0x0000007f
        0x7fcd2774b0: 0x1ee19ff0 0x00000071 0x0cc00300 0x00000071

    So after the `ldr` instruction, `w23` has an incorrect value of
    `0x7f` rather than the correct value `0`.

 6. As before, `mono_handle_exception_internal()` tests the value of `w23` to
    decide how to set the `ji` local variable:

        2574 if (resume) {
           0x00000000000be430 <+820>: cbz w23, 0xbe834 <mono_handle_exception_internal+1848>

    But this time because `w23` is *not* zero, execution continues
    *incorrectly* into the `if` branch rather than the `else` branch.
    The result is that `ji` is set to `0` rather than a valid
    `(MonoJitInfo *)` value.  This incorrect value for `ji` leads to a
    null pointer dereference, as seen in the bug reports.

[0]: https://github.com/xamarin/xamarin-android/tree/xamarin-android-9.3.0.22
[1]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1432/Azure/
[2]: https://jenkins.xamarin.com/view/Xamarin.Android/job/xamarin-android-freestyle/1436/Azure/

* reduce frame size

Commit migrated from https://github.com/mono/mono/commit/888a8d44f6d6e6934b9f105d4e0b0432edf72ba4

5 years agoFix interpreter failure in install_eh_callback.exe under Windows MSVC.
lateralusX [Wed, 5 Jun 2019 15:19:18 +0000 (17:19 +0200)]
Fix interpreter failure in install_eh_callback.exe under Windows MSVC.

INTERP_PUSH_LMF_WITH_CTX_BODY is not fully supported under Windows MSVC
since that compiler doesn't support taking address from a label, needed
by current implementation to correctly resume after unwinding exceptions
happening in native frames as tested by install_eh_callback.exe.

This fix add support to restore to a known location and use a flag
indicating if we have been resumed to the location or just passing by
for the first time. If we resume it will transfer control to specified label.
This will mimic the behavior of taking the address of a label and use that
address as the restore point and works like how setjmp/longjmp work.

I also considered switching to setjmp/longjmp but that would have had a bigger
impact on all platforms and needed changes into the resume context
machinery as well.

While doing the implementation I also found an interesting issue with
MONO_CONTEXT_GET_CURRENT under Windows x64. On most other platforms it is
implemented as inline assembler, but on MSVC x64 inline assembler is not
supported so it is implemented as a function. Problem with that is how IP
was resolved, since it won't be resolved to the last instruction in the
expanded macro, but to the IP within the mono_context_get_current. This has
not had any visible effects in the past since it will just do the ret and get
back to the call site, but when this was used in INTERP_PUSH_LMF_WITH_CTX_BODY
it caused some issues. This was fixed to make sure rsp and rip reflect location
in caller frame and not within mono_context_get_current, similar to how
it works on all platforms with inline assembler support.

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

5 years agoMerge pull request mono/mono#14760 from lateralusX/lateralusX/increase-windows-main...
Johan Lorensson [Wed, 5 Jun 2019 10:26:50 +0000 (12:26 +0200)]
Merge pull request mono/mono#14760 from lateralusX/lateralusX/increase-windows-main-thread-stack-size

Increase main thread stack size on Windows.

Commit migrated from https://github.com/mono/mono/commit/644bfc93d4bec824d38f83850746a2a3132a6200

5 years ago[netcore] Download and use local .NET Core SDK (mono/mono#14696)
Egor Bogatov [Wed, 5 Jun 2019 09:52:01 +0000 (12:52 +0300)]
[netcore] Download and use local .NET Core SDK (mono/mono#14696)

* Download and use local .NET Core SDK

* depend on 'all' rule in nupkg

* fix build error

* Windows support

* use InitializeToolset function

* ouput full path of dotnet in init-tools.sh

* remove init-tools

* Add init-tools.ps1 (Windows)

* fix / issue on cygwin

* address Jo's feedback

* add powershell to PATH for make nupkg

* add netcore/build.sh

* handle pack and test commands

* Update tools.ps1

* Update tools.ps1

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

5 years ago[runtime] Autoconf check for pthread_mutexattr_setprotocol
Aleksey Kliger [Tue, 4 Jun 2019 22:22:10 +0000 (18:22 -0400)]
[runtime] Autoconf check for pthread_mutexattr_setprotocol

Android doesn't always declare that function.

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

5 years agoMerge pull request mono/mono#14694 from lateralusX/lateralusX/fix-llvm-build-path...
Johan Lorensson [Tue, 4 Jun 2019 09:16:49 +0000 (11:16 +0200)]
Merge pull request mono/mono#14694 from lateralusX/lateralusX/fix-llvm-build-path-msvc

Fix LLVM build break on Windows MSVC.

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

5 years agoIncrease main thread stack size on Windows.
lateralusX [Mon, 3 Jun 2019 09:43:16 +0000 (11:43 +0200)]
Increase main thread stack size on Windows.

On Windows default thread stack size has been 1MB for a long time
(both 32/64-bit). When starting to use interpreter some of the tests
include deep recursions that will hit stackoverflow on Windows
(ackermann.exe as one example). This commit adjust the default reserved
stack size to 8MB for debug builds and 1.5MB (same as coreclr), for main
thread only. All other threads will still default to 1MB stack size
(both debug/release).

Commit migrated from https://github.com/mono/mono/commit/29a2383333fdd4d49101d37ea61571747454aae9

5 years agoUpdate license to match directory
Rich Lander [Tue, 4 Jun 2019 04:25:16 +0000 (21:25 -0700)]
Update license to match directory

Commit migrated from https://github.com/mono/mono/commit/697c1402ea978a80ff071c4e8ad4a37dce6cae2d

5 years agoUpdate license to match directory
Rich Lander [Tue, 4 Jun 2019 04:23:38 +0000 (21:23 -0700)]
Update license to match directory

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

5 years agoMerge pull request mono/mono#14766 from lateralusX/lateralusX/fix-win-32-createproces...
Johan Lorensson [Tue, 4 Jun 2019 06:49:02 +0000 (08:49 +0200)]
Merge pull request mono/mono#14766 from lateralusX/lateralusX/fix-win-32-createprocess-error

Change in process_complete_path exposed uninitialized variable error.

Commit migrated from https://github.com/mono/mono/commit/0fa59f11ea2bd6ae81cf09f17dd44df7d9d78d89

5 years agoBump roslyn to release 3.1.0 (mono/mono#14778)
monojenkins [Mon, 3 Jun 2019 20:41:42 +0000 (16:41 -0400)]
Bump roslyn to release 3.1.0 (mono/mono#14778)

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

5 years agoChange in process_complete_path exposed uninitialized variable error.
lateralusX [Mon, 3 Jun 2019 14:04:32 +0000 (16:04 +0200)]
Change in process_complete_path exposed uninitialized variable error.

https://github.com/mono/mono/commit/mono/mono@5d088cf0de7f3e50e3547dba361af4401e938dd4
exposed a problem with an uninitialized variable, only exposed on some
build configurations, 32-bit Windows release builds.

Commit migrated from https://github.com/mono/mono/commit/85bdaee7a540f6b3af83ae5046cd08d4bcbdf068

5 years agoRemove W32_UPDATE_LAST_ERROR_RESTORE_POINT that is not used and does not make sense...
Jay Krell [Thu, 30 May 2019 16:15:26 +0000 (09:15 -0700)]
Remove W32_UPDATE_LAST_ERROR_RESTORE_POINT that is not used and does not make sense to me, as to when it would be useful, having preserved LastError around many code paths through the years.

Commit migrated from https://github.com/mono/mono/commit/018940f1bc126298771ed8d3855cf228382f44f3

5 years agoDo not change Win32 lasterror in the first MONO_EXIT_GC_SAFE.
Jay Krell [Wed, 29 May 2019 23:29:48 +0000 (16:29 -0700)]
Do not change Win32 lasterror in the first MONO_EXIT_GC_SAFE.

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

5 years agoUpdate THIRD-PARTY-NOTICES.TXT
Rich Lander [Sat, 1 Jun 2019 17:57:49 +0000 (10:57 -0700)]
Update THIRD-PARTY-NOTICES.TXT

Add entry for https://github.com/mono/mono/blob/mono/mono@a34c9c79c07156797499b6ed2ce43c5897263b57/mono/benchmark/logic.cs

Commit migrated from https://github.com/mono/mono/commit/72dfea91df90020e5ca3cf7e5bbfd9a22e390fe3

5 years ago[arm64] Set a llvm target layout. Assert in llvm if the target layout is not set...
Zoltan Varga [Sat, 1 Jun 2019 05:33:57 +0000 (01:33 -0400)]
[arm64] Set a llvm target layout. Assert in llvm if the target layout is not set, the defaults used by 'opt' are not correct. (mono/mono#14714)

* [arm64] Set a llvm target layout. Assert in llvm if the target layout is not set, the defaults used by 'opt' are not correct.

* Add a llvm target layout for amd64.

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

5 years agoPropagate error in mono_file_map_error on posix (mono/mono#14710)
Ryan Lucia [Fri, 31 May 2019 21:19:32 +0000 (17:19 -0400)]
Propagate error in mono_file_map_error on posix (mono/mono#14710)

Commit migrated from https://github.com/mono/mono/commit/43aeac9e1e4ca32e10e476a07b38dde08c56beac

5 years ago[coop] Add GC safe transitions around blocking OS API calls (mono/mono#14612)
Ryan Lucia [Fri, 31 May 2019 18:39:22 +0000 (14:39 -0400)]
[coop] Add GC safe transitions around blocking OS API calls (mono/mono#14612)

If this was not possible due to them being called during runtime initialization, a short comment was left noting the specific reason why.

Fixes mono/mono#14377

This includes a couple other random fixes I noticed on the way, most notably replacing SEE_MASK_FLAG_DDEWAIT with SEE_MASK_FLAG_NOASYNC as the former is deprecated.

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

5 years agoBump version to 6.5.0 (mono/mono#14728)
Jo Shields [Fri, 31 May 2019 16:59:57 +0000 (12:59 -0400)]
Bump version to 6.5.0 (mono/mono#14728)

Commit migrated from https://github.com/mono/mono/commit/0f4ac3f13e9a858074469795b146018d60c6783c

5 years ago[metadata] Mark mono_type_is_generic_parameter as a MONO_API
Aleksey Kliger [Fri, 12 Apr 2019 15:44:32 +0000 (11:44 -0400)]
[metadata] Mark mono_type_is_generic_parameter as a MONO_API

Used by the MONO_CLASS_IS_INTERFACE macro.

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

Commit migrated from https://github.com/mono/mono/commit/8004791be87eba589ead449de129744c297f6ebd

5 years ago[marshal] Fix race between delegate marshaling and finalization
Vlad Brezae [Thu, 2 May 2019 13:09:31 +0000 (16:09 +0300)]
[marshal] Fix race between delegate marshaling and finalization

When passing a delegate to native code, we pass the delegate_trampoline which can be used to invoke the delegate from native code and we store this mapping (delegate_trampoline->delegate) in a hashtable so we can get a delegate for the delegate_trampoline, when marshalling the opposite way. If we are trying to marshal a ftnptr (for managed code) to a delegate and we don't find this mapping we can crash. This could happen if the finalization for some other delegate that uses the same ftnptr removes this entry from the table. We solve this by never freeing these entries. The first delegate-ftnptr pair will always be alive. This is easier, faster and potentially uses less memory than tracking in the hashtable every pair. There should be a small and limited set of methods marshalled to native.

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

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

5 years agoMerge pull request mono/mono#14325 from HebaruSan/fix/listviewgroup-forecolor
Steve Pfister [Fri, 31 May 2019 02:05:37 +0000 (22:05 -0400)]
Merge pull request mono/mono#14325 from HebaruSan/fix/listviewgroup-forecolor

Fix light on light ListViewGroup headers on dark theme

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

5 years agoBatch of runtime warning fixes on Darwin (mono/mono#14713)
Ryan Lucia [Thu, 30 May 2019 20:35:48 +0000 (16:35 -0400)]
Batch of runtime warning fixes on Darwin (mono/mono#14713)

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

5 years agoRemove JIT icall hashing by name and AOT JIT icall hashing. (mono/mono#14644)
Jay Krell [Thu, 30 May 2019 10:39:56 +0000 (03:39 -0700)]
Remove JIT icall hashing by name and AOT JIT icall hashing. (mono/mono#14644)

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

5 years ago[netcore] Add a metapackage for all supported runtimes
Jo Shields [Wed, 29 May 2019 15:58:57 +0000 (11:58 -0400)]
[netcore] Add a metapackage for all supported runtimes

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

5 years agomono_mempool_alloc0: Don't give up the rest of the chunk (mono/mono#14671)
Jay Krell [Wed, 29 May 2019 23:11:46 +0000 (16:11 -0700)]
mono_mempool_alloc0: Don't give up the rest of the chunk (mono/mono#14671)

when the allocation does not fit, i.e. when it is >= MONO_MEMPOOL_PREFER_INDIVIDUAL_ALLOCATION_SIZE.

Or at least make the code clearer and smaller.

"fixes" https://github.com/mono/mono/issues/14669.

Commit migrated from https://github.com/mono/mono/commit/815cb9da1aae89abc421adc05917deb6b409e5ff

5 years agoFix LLVM build break on Windows MSVC.
lateralusX [Wed, 29 May 2019 10:09:59 +0000 (12:09 +0200)]
Fix LLVM build break on Windows MSVC.

https://github.com/mono/mono/pull/14607 broke LLVM build on Windows MSVC.
This is just a quick fix falling back to old behavior on Windows MSVC. Since
all LLVM tools will be available in the same folder as mono runtime binary
there is no specific need to point out other build folders hosting LLVM tooling.

Commit migrated from https://github.com/mono/mono/commit/0a6b13f83a7699f29224b9e5202dfc3351f3c8de

5 years agobump roslyn
Egor Bogatov [Wed, 29 May 2019 08:04:22 +0000 (11:04 +0300)]
bump roslyn

Commit migrated from https://github.com/mono/mono/commit/472465d6ba26d5cb9f98b2cad4b929e23adf2239

5 years agoUpdate THIRD-PARTY-NOTICES.TXT
Rich Lander [Fri, 24 May 2019 20:30:52 +0000 (13:30 -0700)]
Update THIRD-PARTY-NOTICES.TXT

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

5 years agoCreate THIRD-PARTY-NOTICES.TXT
Rich Lander [Fri, 24 May 2019 20:30:28 +0000 (13:30 -0700)]
Create THIRD-PARTY-NOTICES.TXT

TPN for https://github.com/mono/mono/blob/mono/mono@23e6f6f4b58d72800f4e27fa29a6b58806ff475f/mono/mini/bench.cs#L65

Commit migrated from https://github.com/mono/mono/commit/51d58cf80c555531ed979745a464bd6d5a7df9dc

5 years agoCreate THIRD-PARTY-NOTICES.TXT
Rich Lander [Fri, 24 May 2019 15:40:59 +0000 (08:40 -0700)]
Create THIRD-PARTY-NOTICES.TXT

TPN for https://github.com/mono/mono/blob/mono/mono@29ee4e15806848ff5131c4bdd23ded786f5bc186/mono/benchmark/zipmark.cs

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

5 years ago[interp] Make --interp= not override last set execution mode (mono/mono#14683)
Vlad Brezae [Wed, 29 May 2019 07:02:23 +0000 (10:02 +0300)]
[interp] Make --interp= not override last set execution mode (mono/mono#14683)

It makes sense to pass --interp (--interp=-inline) while having another execution mode previously set up (like --full-aot-interp).

Cleanup code a little bit by killing mono_enable_interp which doesn't do much.

Commit migrated from https://github.com/mono/mono/commit/04f4db7b87c8f0c2c1987e007b458849d5d46238

5 years agoInfrastructure support / fixes for making compiler server the default (mono/mono...
Katelyn Gadd [Wed, 29 May 2019 06:54:44 +0000 (23:54 -0700)]
Infrastructure support / fixes for making compiler server the default (mono/mono#14279)

* Fix enabling the compiler server using autogen, and force it off if mcs is being used

* autogen updates

* Formatting fixes

* Fix vbcs getting turned on if unspecified even if mcs was selected

* Dynamically evaluate ENABLE_COMPILER_SERVER each time we compile instead of evaluating it once at some arbitrary point during makefile evaluation

* More detailed comment based on testing

* Handle the /shared option in genproj so it doesn't fail

* Raise basic profile check requirement to 6.2 and hopefully assert that named pipes work

* Default compiler server to off for now.

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

5 years ago[interp] Share more wrappers for different interp in signatures (mono/mono#14596)
Vlad Brezae [Tue, 28 May 2019 15:46:49 +0000 (18:46 +0300)]
[interp] Share more wrappers for different interp in signatures (mono/mono#14596)

[interp] Share more wrappers for different interp in signatures

The passed arguments are already considered to be gpointer in interp_entry and the real value is obtained using stackval_from_data. For types that are passed by value in a register the wrappers will be identical and we can share them.

This commit reduces the size used by interp_in wrappers (in fullaot-interp) by half. These wrappers still take a fair amount of size, which comes mainly from signatures including value types, which aren't shared.

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

5 years ago[sdks] Build static binaries for Android SDK and LLVM with MXE (mono/mono#14283)
Aleksey Kliger (λgeek) [Tue, 28 May 2019 12:56:51 +0000 (08:56 -0400)]
[sdks] Build static binaries for Android SDK and LLVM with MXE (mono/mono#14283)

We used to use the static MXE toolchain, but after switching to Homebrew, we
have to explicitly pass flags to build binaries that don't depend on the
MinGW32 GCC support libraries (libstdc++-6.dll, libwinpthread-1.dll and others)
when building the LLVM and Mono binaries.

The simplest approach is just to pass CMAKE_EXE_LINKER_FLAGS=-static to cmake
and LDFLAGS=-all-static to libtool.  The rest of the changes are just to make
it easier to do that by adding a configure flag and updating the SDKs
infrastructure.

We will also need an LLVM bump to actually build a new llvm archive with the
new build flags; until then, building Mono will provision an old build of LLVM
with the old build flags that still depends on libstdc++-6.dll.

---

An alternative approach instead of passing -all-static and -static would be to
probe for the assorted -static-libXYZ flags to GCC at configure time.  (For the
LLVM build we would need to hardcode them as that build doesn't go through
autoconf).  Right now Mono doesn't have any other DLL dependencies (other than
the core windows DLLs), so -all-static works just as well and is simpler.

Commit migrated from https://github.com/mono/mono/commit/83f17b4cf9e29b2951ad78e949ba7544a53de22d

5 years agoReduce stack size used by interpreter frame on Windows MSVC. (mono/mono#14659)
Johan Lorensson [Mon, 27 May 2019 21:55:52 +0000 (23:55 +0200)]
Reduce stack size used by interpreter frame on Windows MSVC. (mono/mono#14659)

Reduce stack size used by interpreter frame on Windows MSVC.

Interpreter frame was 1248 bytes in size under Windows MSVC. This was almost double the size of other platforms ~670 bytes. After investigating different constructs in interpreter switch statement in interp_exec_method_full, it turns out that local declared errors couldn't be reused over different case statements and added ~100 bytes each. Switching local declared errors to shared one, reduce the stack size down to ~670 bytes under Windows MSVC.

Commit migrated from https://github.com/mono/mono/commit/8d0ad4c81634643f8903c58ba4f11e462a2e26a6

5 years agoIntroduce g_static_assert. (mono/mono#14651)
Jay Krell [Mon, 27 May 2019 19:33:46 +0000 (12:33 -0700)]
Introduce g_static_assert. (mono/mono#14651)

ifdef __cplusplus
define g_static_assert(x) static_assert (x, "")
else
define g_static_assert(x) g_assert (x)
endif

It is, granted, C++11, not C++98, and some C variations.

Commit migrated from https://github.com/mono/mono/commit/07c5ecdf7ba1987dc181d9b31ecbadd95224de91

5 years agowarning: 'emit_load' defined but not used [-Wunused-function] (mono/mono#14646)
Jay Krell [Mon, 27 May 2019 18:18:57 +0000 (11:18 -0700)]
warning: 'emit_load' defined but not used [-Wunused-function] (mono/mono#14646)

Rename emit_load_general to emit_load

Commit migrated from https://github.com/mono/mono/commit/15eb9f7ba1b7de945e78c8f35a89eb98b947c428

5 years agoMerge pull request mono/mono#14628 from lateralusX/lateralusX/interpreter-windows...
Johan Lorensson [Mon, 27 May 2019 15:00:06 +0000 (17:00 +0200)]
Merge pull request mono/mono#14628 from lateralusX/lateralusX/interpreter-windows-x64-mini-regression-support

Fix interpreter mini regression test on Windows x64.

Commit migrated from https://github.com/mono/mono/commit/164c257bb97c56bb89ea0d2c8b0eee3a44d99c0a

5 years agoBump roslyn dependency
Marek Safar [Mon, 27 May 2019 10:29:41 +0000 (12:29 +0200)]
Bump roslyn dependency

Commit migrated from https://github.com/mono/mono/commit/0f4dd6bc49ed750e90d202e52052ef2d0f82487e

5 years agoAdd missing new files to Makefile.am, fix tarball build (mono/mono#14656)
Alexander Köplinger [Mon, 27 May 2019 13:21:26 +0000 (15:21 +0200)]
Add missing new files to Makefile.am, fix tarball build (mono/mono#14656)

They were added in https://github.com/mono/mono/pull/14427

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

5 years agoReview feedback.
lateralusX [Mon, 27 May 2019 07:23:02 +0000 (09:23 +0200)]
Review feedback.

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

5 years agoWiden MonoJumpInfo union to pointer-sized so mono_add_patch_info can just use target...
Jay Krell [Sun, 26 May 2019 16:30:18 +0000 (09:30 -0700)]
Widen MonoJumpInfo union to pointer-sized so mono_add_patch_info can just use target field blindly. (mono/mono#14642)

just use target field blindly.

Commit migrated from https://github.com/mono/mono/commit/393d7ef616dcabab70df06dda9efa8e2e9493321

5 years agoRemove MONO_PATCH_INFO_METHOD_REL. (mono/mono#14643)
Jay Krell [Sat, 25 May 2019 14:30:53 +0000 (07:30 -0700)]
Remove MONO_PATCH_INFO_METHOD_REL. (mono/mono#14643)

It is not used, and it had a larger than pointer field
where a pointer was required, at least for 32bit hosted cross builds.

Commit migrated from https://github.com/mono/mono/commit/489c40a548c656e83e36daab5f17c4128fa21f1c

5 years ago[jit] Also allow System.Runtime.CompilerServices.Unsafe intrinsics from the System...
Zoltan Varga [Sat, 25 May 2019 14:30:04 +0000 (10:30 -0400)]
[jit] Also allow System.Runtime.CompilerServices.Unsafe intrinsics from the System.Runtime.CompilerServices assembly, not just corlib. (mono/mono#14618)

* [jit] Also allow System.Runtime.CompilerServices.Unsafe intrinsics from the System.Runtime.CompilerServices assembly, not just corlib.

* [jit] Fix Unsafe.RefIsAddressLessThan()/RefIsAddressGreaterThan().

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

5 years ago[build] Provide in-tree llvm to mono correctly (mono/mono#14607)
Alexander Kyte [Sat, 25 May 2019 08:10:22 +0000 (04:10 -0400)]
[build] Provide in-tree llvm to mono correctly (mono/mono#14607)

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

5 years ago[coop] Transition various public APIs into an external/internal form to avoid unneces...
Ryan Lucia [Fri, 24 May 2019 23:09:00 +0000 (19:09 -0400)]
[coop] Transition various public APIs into an external/internal form to avoid unnecessary GC-unsafe calls (mono/mono#14427)

Relevant issue: mono/mono#14376

There are potentially more functions this can apply to, but this covers the ones listed in the issue and an extra one I found in the process.

Functions were either broken off into an external-only and internal version, or such a pair already existed and the internal version was moved from the source file to a separate `-internals` header, similarly to in mono/mono@3c74df566776f468366d96dd164dd1a6b3d780cc.

This gets slightly complicated with `mono_domain_set` and `mono_domain_set_internal`, both of which are currently public (thanks to mono/mono@4beada28924879ede55f3bf8b3f5b798d0f4637e) and have different signatures. Additionally, the latter does not actually include the gc-unsafe transition despite being public.
I've opted to introduce `mono_domain_set_fast` as the 'internal' version of `mono_domain_set`, to add the proper gc-unsafe transition to `mono_domain_set_internal`, and then to migrate internal usage to `mono_domain_set_internal_with_options`. As part of that I've marked `mono_domain_set_internal` as external only, which is unfortunate naming-wise but I believe the best option here without introducing API breakage.

Commit migrated from https://github.com/mono/mono/commit/96b1fd837d6caf1be1b657c0726af3b8caae7060

5 years ago[llvm] Use CoreCLR GC interop configuration (mono/mono#14598)
Alexander Kyte [Fri, 24 May 2019 20:55:50 +0000 (16:55 -0400)]
[llvm] Use CoreCLR GC interop configuration (mono/mono#14598)

[llvm] Use CoreCLR GC interop configuration

Since they're identical right now, we can use the coreclr configuration
to make our IR more easily analyzed by tools built around LLVM.

```
class CoreCLRGC : public GCStrategy {
public:
  CoreCLRGC() {
    UseStatepoints = true;
    // These options are all gc.root specific, we specify them so that the
    // gc.root lowering code doesn't run.
    InitRoots = false;
    NeededSafePoints = 0;
    UsesMetadata = false;
    CustomRoots = false;
  }

  Optional<bool> isGCManagedPointer(const Type *Ty) const override {
    // Method is only valid on pointer typed values.
    const PointerType *PT = cast<PointerType>(Ty);
    // We pick addrspace(1) as our GC managed heap.
    return (1 == PT->getAddressSpace());
  }
};

/// A GCStrategy for the Mono Runtime.
class MonoGC : public GCStrategy {
public:
  MonoGC() {
    UseStatepoints = true;
    // These options are all gc.root specific, we specify them so that the
    // gc.root lowering code doesn't run.
    InitRoots = false;
    NeededSafePoints = 0;
    UsesMetadata = false;
    CustomRoots = false;
  }
};
```

Source: https://github.com/mono/llvm/blob/mono/mono@64c0343537016c153894dc60316bd7b316b812c8/lib/CodeGen/BuiltinGCs.cpp#L105-L137

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

5 years agoCleanup: load_function_full -- avoid a string alloc/copy and cast. (mono/mono#14625)
Jay Krell [Fri, 24 May 2019 20:36:00 +0000 (13:36 -0700)]
Cleanup: load_function_full -- avoid a string alloc/copy and cast. (mono/mono#14625)

Cleanup: load_function_full -- avoid a string alloc/copy and cast.

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

5 years agoFix build warning for orig_method (mono/mono#14603)
Ryan Lucia [Fri, 24 May 2019 19:34:23 +0000 (15:34 -0400)]
Fix build warning for orig_method (mono/mono#14603)

Variable is only used here: https://github.com/mono/mono/blob/mono/mono@82a993124888d470d1057eae9546e5be76524dad/mono/mini/mini-trampolines.c#L743

Commit migrated from https://github.com/mono/mono/commit/76c45bc2cbbcbc3a6beafaeb477c7c42c1069af9

5 years ago[llvm] Remove JIT support for older llvm versions. (mono/mono#14605)
Zoltan Varga [Fri, 24 May 2019 18:56:01 +0000 (14:56 -0400)]
[llvm] Remove JIT support for older llvm versions. (mono/mono#14605)

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