Ryan Lucia [Wed, 8 Jan 2020 20:57:16 +0000 (15:57 -0500)]
[metadata] Propagate error in mono_runtime_try_invoke_array (mono/mono#18382)
This was prompted by https://github.com/mono/mono/issues/18339, which seems to be failing to locate a native library and then hitting an assertion. We should propagate the error instead, so that if others run into something similar they can see what's actually going wrong instead of just getting a runtime crash.
Commit migrated from https://github.com/mono/mono/commit/
1178ab3a1a48dbc831ecd905a7d88bfd417e0d73
Jay Krell [Wed, 8 Jan 2020 18:34:11 +0000 (10:34 -0800)]
[Coop] Remove handles from Mono.Interop.ComInteropProxy. (mono/mono#16993)
Commit migrated from https://github.com/mono/mono/commit/
e8d38961eedfc4d5575ec264483bbe9dbdd59282
Zoltan Varga [Wed, 8 Jan 2020 15:39:39 +0000 (16:39 +0100)]
[runtime] Initialize field info before accessing it in ves_icall_System_RuntimeFieldHandle_SetValueDirect (). (mono/mono#18378)
Fixes https://github.com/mono/mono/issues/18364.
Commit migrated from https://github.com/mono/mono/commit/
34dee0ea4e969d6d5b37cb842fc3b9f73f2dc2ae
Zoltan Varga [Wed, 8 Jan 2020 12:32:52 +0000 (13:32 +0100)]
[jit] Implement fast TLS access in gshared methods. (mono/mono#18377)
Fixes https://github.com/mono/mono/issues/18370.
Commit migrated from https://github.com/mono/mono/commit/
e999846088bb4b05b2fa22234bd70fb42fd02a80
Bernhard Urban-Forster [Tue, 7 Jan 2020 18:35:54 +0000 (19:35 +0100)]
[interp] run regression with all combinations of available optimizations (mono/mono#17644)
[interp] run regression with all combinations of available optimizations
Like we do for the JIT.
Commit migrated from https://github.com/mono/mono/commit/
6481e8f7a3f2ff1b23310446711179bc31789d7d
Calvin Buckley [Tue, 7 Jan 2020 16:28:06 +0000 (12:28 -0400)]
Force Python 3.x from env in shebang lines (mono/mono#18285)
* Fix byte/string incompatiblity in Python 3
Commit migrated from https://github.com/mono/mono/commit/
524a8298d0c8cda332c17a743eaed69ce78f392d
Zoltan Varga [Tue, 7 Jan 2020 16:12:34 +0000 (17:12 +0100)]
[netcore] Remap String ctors to the String:Ctor () methods. (mono/mono#18357)
Commit migrated from https://github.com/mono/mono/commit/
ec7f4c68f989d6ce037f7b03094826a131e40f46
Calvin Buckley [Tue, 7 Jan 2020 14:44:03 +0000 (10:44 -0400)]
More disambiguation of Python in makefiles (mono/mono#18284)
Commit migrated from https://github.com/mono/mono/commit/
b3ce5bfa887e4542b5360e51f2a8ae483b58e07a
Vlad Brezae [Tue, 7 Jan 2020 14:31:49 +0000 (16:31 +0200)]
[sgen] Fix xref computation with tarjan bridge (mono/mono#18239)
* [sgen] Include also derived classes as bridges
When using `MONO_GC_DEBUG=bridge=` debug option
* [sgen] Fix xref computation with tarjan bridge
Between C# and java (on android) there are objects that live on both worlds. This means that there exists a C# object with a corresponding java object. The relationship between them is strong, meaning if C# object is alive then java object must stay alive, and vice-versa. We keep java bridge objects always alive through a GCHandle (on the java gc). When doing a C# collection we select all bridge objects that appear to be dead on the C# side. These objects are candidates for collection, assuming the java side has nothing against it. Before triggering a collection on the java side (following the mono gc) we switch all the strong gchandles to the java objects to be weak (for these objects that are candidate to be collected) and we recreate the reference graph from the C# side to the java side (if C# Bridge1 can reference C# Bridge2 then, on the java side, we add a reference from Java Bridge1 to Java Bridge2; this is done by adding to an array of references inside Java Bridge1). In order to minimize the amount of work that needs to be done on the java side, we compute the minimal amount of references that need to be added, by computing the strongly connected components of the object graph.
An optimized way to construct the SCCs and the xrefs is by using the tarjan algorithm (https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm). Our algorithm is non recursive (scan_stack emulates the recursive order of traversal in a dfs algorithm, while loop_stack is the stack used by the algorithm). A color represents an SCC. We have some optimizations in place where we might merge colors if they don't contain bridges, since the client only cares about SCCs containing bridge objects and the links between them. color_merge_array is used to keep track of all neighbors of a node until we are creating the scc for that node. It is populated when scanning all the refs inside an object (compute_low). All the colors in the color_merge_array will be cross references with that scc.
Before this commit we were only clearing the color_merge_array when creating an SCC. This is problematic because we could end up with xrefs inside of an SCC that belong to another SCC. Consider the simple graph of nodes 0,1,2,3 where 0 <=> 2, 0->1, 2->3. Assume we start scanning with node 0. When creating the SCC for node 3 the followed path is 0 -> 2 -> 3, while the loop stack will contain (0,1,2,3). After creating SCC for node 3, we will finish scanning node 2 which would detect the xref to Bridge3, which would have been added to the color_merge_array. Because node 2 is not the root of the SCC it belongs to (its lowlink points towards node 0 which has a lower index), we are not creating an SCC with it, and the link to node 3 remains in color_merge_array. Because the next node from the scan_stack is node 1, which is also the root of the SCC that it belongs to, we will create an SCC for it and wrongly add the node 3 reference from color_merge_array to it. In order to fix this issue, we will always clear the color_merge_array once we finished scanning the xrefs for a node. If the node in question is not the root of an scc, then we will remember them as xrefs pointing out from this object. When we finally reach node 0 (which will be the root of the SCC containing nodes 0 and 2), we will then know that all xrefs for this color are the union of the xrefs of all objects belonging to this color (which represents the objects that we are popping from the loop_stack until we encounter the root node).
Even though this change adds required bookeeping for xrefs, I didn't notice any change in performance on the bridge tests that we have in mono/tests.
* [sgen] Some logging improvements in tarjan bridge
* [sgen] Disable optimization when comparing bridge outputs
When this optimization is enabled, the tarjan bridge will create more SCCs in order to reduce amount of xrefs in the graph. This would render the `bridge-compare-to` debug flag unusable with tarjan bridge.
Commit migrated from https://github.com/mono/mono/commit/
376c46bcf3bc101fba85a402914d60c6bda70e75
Jay Krell [Tue, 7 Jan 2020 14:01:22 +0000 (06:01 -0800)]
Set thread pool thread name just based on string pointer check. (mono/mono#16637)
* Set thread pool thread name just based on string pointer check.
When the generation-based solution went in, there were not
yet constant thread names, so a pointer based approach could fail
due to reuse. We can do slightly simpler now.
* Remove the generation field which is no longer needed.
Remove the duplicated knowledge of how to set a constant and put
it behind a funny sounding but perhaps reasonable flag.
Revise corlib version.
Commit migrated from https://github.com/mono/mono/commit/
2129ac6c282560e3039a38de9ebbebcdfab6f149
Marek Safar [Tue, 7 Jan 2020 10:17:06 +0000 (11:17 +0100)]
[System.Private.CoreLib] Cleanup intrinsic tracking (mono/mono#17884)
* [System.Private.CoreLib] Cleanup intrinsic tracking
1. Removed icalls where intrinsic version for the method exists
2. Add [Intrinsic] attribute to methods which have runtime intrinsic
to make them easier to track and to tell linker not to analyze them
3. Use recursive syntax for any intrinsic which can be called via
reflection to correctly apply the intrinsic when invoked.
```c#
public static bool IsSupported { get => IsSupported; }
```
When one calls X86.IsSupported, the call gets replaced by an
intrinsics. When one calls it with an Invoke, the body of IsSupported
gets replaced by intrinsics. It's just a hack to get Invoke support for free.
* [interp] implement System.Type::op_Equality
* Undo changes which are not yet supported by interpreter
* [interp] Implement System.Runtime.CompilerServices.RuntimeHelpers::OffsetToStringData
Co-authored-by: Bernhard Urban-Forster <bernhard.urban@xamarin.com>
Commit migrated from https://github.com/mono/mono/commit/
adcd62248d8956ab4d512c5b970c867b7432887f
Zoltan Varga [Tue, 7 Jan 2020 01:57:10 +0000 (02:57 +0100)]
[jit] Avoid passing a vtable argument to DIM methods when making calls out of gsharedvt methods. (mono/mono#18334)
* [jit] Avoid passing a vtable argument to DIM methods when making calls out of gsharedvt methods.
Fixes https://github.com/mono/mono/issues/18276.
* Fix compilation with mcs.
Commit migrated from https://github.com/mono/mono/commit/
487dacce79f0191dd7275c40756e9ccb42fa7ff0
Jay Krell [Mon, 6 Jan 2020 21:11:21 +0000 (13:11 -0800)]
Do not depend on gboolean to have multiple bits. (mono/mono#17825)
Commit migrated from https://github.com/mono/mono/commit/
6a8ca2252b9e140949a73614d78ea327b111130e
Zoltan Varga [Mon, 6 Jan 2020 15:36:59 +0000 (16:36 +0100)]
[netcore] Optimize RuntimeType::IsSZArray. (mono/mono#18347)
Commit migrated from https://github.com/mono/mono/commit/
384db9e89053822a2d51cc19d7084ce75a636b37
Zoltan Varga [Mon, 6 Jan 2020 13:48:50 +0000 (14:48 +0100)]
[netcore] Mark SRE types with required=false so they are only retained when they are actually used.
Commit migrated from https://github.com/mono/mono/commit/
7236dadd32a6d36910051e21478f9281cca64ad8
Jo Shields [Mon, 6 Jan 2020 14:20:46 +0000 (09:20 -0500)]
Don't run `make install` in boehm submodule (mono/mono#17907)
Don't run `make install` in boehm submodule
Commit migrated from https://github.com/mono/mono/commit/
4c9e28b80afb29af526fd698b9922ed0a13531fb
Aleksey Kliger (λgeek) [Fri, 3 Jan 2020 15:42:44 +0000 (10:42 -0500)]
[metadata] Size 0 Blob heap is ok when resolving assembly refs (mono/mono#18313)
* [metadata] Size 0 Blob heap is ok when resolving assembly refs
Sometimes ILasm can produce images with a Blob heap of size 0. In cases where
we're loading assembly references from such an image, the hash (which is
optional) can be at index = 0 and the Blob heap size is also 0.
Also: add the hash value to the output of `monodis --assemblyref`
* [metadata] Add a separate assertion for the index == size == 0 case
And a comment explaining how it is likely to be triggered. If the assembly is
reasonable the caller of mono_metadata_blob_heap should be updated to use
mono_metadata_blob_heap_null_ok instead
* [bcl] Allow Mono's ILASM to produce a size 0 Blob heap
ECMA 335 II.24.2.4 says that the user string and blob heaps should have an
entry at index 0 consisting of the single byte 0. However .NET Framework (and
.NET Core) ilasm will entirely omit the Blob heap (that is, create a blob heap
entry of size 0) if it is not needed. This PR changes Mono's ILASM to emit the
initial byte on demand only if one of the MetaDataStream.Add() methods is
called. Otherwise we will also emit a stream of size 0.
This is needed to compile some test cases.
* [tests] Add regression test for loading assemblies with size 0 Blob heap
Depends on ILASM that can emit a size 0 Blob heap
Commit migrated from https://github.com/mono/mono/commit/
07fee8a91dbc172bacded9d2c7f7d158eb7c50f1
Zoltan Varga [Fri, 3 Jan 2020 08:53:09 +0000 (09:53 +0100)]
[netcore] Add some linker exclusions.
Commit migrated from https://github.com/mono/mono/commit/
22afdb80e1b1921a66cb30c2a885bf0041cf67f1
Marek Safar [Sun, 29 Dec 2019 13:14:31 +0000 (14:14 +0100)]
Cleanup a few dependencies to reduce wasm bcl size
Commit migrated from https://github.com/mono/mono/commit/
c9036e755580c96a984daad55ff8dec11ff46b44
Ryan Lucia [Thu, 2 Jan 2020 20:21:45 +0000 (15:21 -0500)]
[loader] Add assembly name matching on netcore to fix DefaultContext test (mono/mono#18272)
* [loader] Rename assembly name check strictness flag
* [loader] Add predicate for assembly name matching on netcore
* [loader] Enable LoadInDefaultContext test
* Make mono_assembly_names_equal external, change flags in domain search
* Move ifdef inside mono_loader_get_strict_assembly_name_check
* Fix pedump
* No reason to make this external
* Feedback
Commit migrated from https://github.com/mono/mono/commit/
33ca3d33e1994cabf9f9b19034624a3495bbc9cb
Egor Bogatov [Thu, 2 Jan 2020 19:45:40 +0000 (22:45 +0300)]
Add !align 8 to all managed allocators (calls) (mono/mono#18283)
Commit migrated from https://github.com/mono/mono/commit/
458d80002db5fadd8349eac0e9724ceec097d003
Ryan Lucia [Thu, 2 Jan 2020 16:58:15 +0000 (11:58 -0500)]
[reflection] Convert internal GetCustomAttributes calls to Attribute[] (mono/mono#18176)
* [reflection] Avoid creating object[] in GetCustomAttributesBase
* [reflection] Migrate Attribute type checking to CustomAttribute.cs
Commit migrated from https://github.com/mono/mono/commit/
ff6294d2311932902a9e790bbcc79f109a602d0c
Ryan Lucia [Thu, 2 Jan 2020 16:56:50 +0000 (11:56 -0500)]
[eglib] Fix whitespace in memory.c (mono/mono#18320)
Commit migrated from https://github.com/mono/mono/commit/
675f1eb32141fb0904b1499382ccca4b38c1e46a
Thays Grazia [Thu, 2 Jan 2020 14:26:14 +0000 (11:26 -0300)]
The behaviour expected of filter exceptions is: (mono/mono#18309)
-> throw in a async task with a try catch in the caller -> don't stop
-> throw in a new thread with a try catch in the caller -> stop
-> throw in the main thread without any try catch -> stop
Including a new test to test the fix of mono/mono#17601.
Fixing mono/mono#16588, create a while 1 to stops the program execution when an exception is thrown and no try catch is found and MONO_DEBUG=suspend-on-unhandled.
Fixes mono/mono#17601
Fixes mono/mono#16588
Commit migrated from https://github.com/mono/mono/commit/
e20956305e0b9fabade97f31e1712ea920381d3f
Aleksey Kliger (λgeek) [Mon, 30 Dec 2019 14:54:57 +0000 (09:54 -0500)]
[eglib] Don't define _FORTIFY_SOURCE on Cygwin builds (mono/mono#18308)
See https://github.com/msys2/MINGW-packages/issues/5803
Without -lssp (or -fstack-protector), -D_FORTIFY_SOURCE=2 leads to linker
errors.
Commit migrated from https://github.com/mono/mono/commit/
61eb2be2e10c228c5915d90a90b52e7d410c0f25
imhameed [Thu, 26 Dec 2019 19:34:02 +0000 (13:34 -0600)]
Use byte-aligned LLVM loads and stores for unaligned mini IR loads and stores. (mono/mono#18296)
Should fix https://github.com/mono/mono/issues/18221.
Commit migrated from https://github.com/mono/mono/commit/
9719635e5896b1c929cb5310f400b713a8ddfac8
Aleksey Kliger (λgeek) [Mon, 23 Dec 2019 15:44:32 +0000 (10:44 -0500)]
[domain] Don't add NULL runtime to runtimes list (mono/mono#18260)
Also when iterating over the runtimes, actually look at the current element,
not the first element.
Also mention the unsupported runtime version in the warning message when it is
passed to mono_init_internal.
Fixes https://github.com/mono/mono/issues/17916
Commit migrated from https://github.com/mono/mono/commit/
ffdffa54f2494cfdf390fabfc76e353fbe59405a
Fan Yang [Mon, 23 Dec 2019 13:38:36 +0000 (08:38 -0500)]
Fix llvm jit assertion (mono/mono#18280)
* Fix assertion when Alignment is greater than 32
Commit migrated from https://github.com/mono/mono/commit/
a1a4bcc49d9d4880f135a17fa3c6ad36b72e5483
Fan Yang [Mon, 23 Dec 2019 13:34:37 +0000 (08:34 -0500)]
Add cast to ((align) - 1) for Alignment macros (mono/mono#18255)
* Add cast to ((align) - 1) for Alignment macros
* Add test for Alignment macro change
Commit migrated from https://github.com/mono/mono/commit/
7ffcaaf59a9826a68233fa9671548c2ca492806a
Ryan Lucia [Fri, 20 Dec 2019 17:37:07 +0000 (12:37 -0500)]
[loader] Check AppContext.BaseDirectory on netcore in preload hook
Commit migrated from https://github.com/mono/mono/commit/
0f8aac3c62db53dc7073c6136664da7f5e184c8b
Ryan Lucia [Fri, 20 Dec 2019 17:21:46 +0000 (12:21 -0500)]
[loader] Remove unnecessary newlines in tracing
Commit migrated from https://github.com/mono/mono/commit/
57b6c8775b97f7a6996b608d2f8db8f808cd6062
Ryan Lucia [Sat, 21 Dec 2019 00:52:53 +0000 (19:52 -0500)]
[netcore] Re-enable some BinaryFormatter tests (mono/mono#18277)
Commit migrated from https://github.com/mono/mono/commit/
5c87445310d2acd5dd35584d123daa8ad20fa317
Aleksey Kliger (λgeek) [Fri, 20 Dec 2019 10:11:26 +0000 (05:11 -0500)]
[tests] Add test files to tarball (mono/mono#18261)
Some test sources weren't included.
Fixes https://github.com/mono/mono/issues/18202
Commit migrated from https://github.com/mono/mono/commit/
d6f3de3c4c8639b5052ffeed483b79193fb76a07
Bernhard Urban-Forster [Thu, 19 Dec 2019 01:05:57 +0000 (02:05 +0100)]
[interp] add guard that a local hasn't been modified for stlocfld fusion (mono/mono#18129)
[interp] add guard that a local hasn't been modified for stlocfld fusion
Fixes https://github.com/mono/mono/issues/18120
Commit migrated from https://github.com/mono/mono/commit/
e7b98d3587fddd51db69baddb370321cca521d60
Nathan Ricci [Wed, 18 Dec 2019 02:35:56 +0000 (21:35 -0500)]
Change ICONST to I8CONST when propagating constants through sign extension. (mono/mono#18222)
Change ICONST to I8CONST when propagating constants through sign extension.
Commit migrated from https://github.com/mono/mono/commit/
ed7432d98844f5638c4e381e2bd0ec5f0787b9dc
Evgenii Stepanov [Tue, 17 Dec 2019 00:18:53 +0000 (16:18 -0800)]
Relax assert in mono_arch_build_imt_trampoline. (mono/mono#18195)
This assert fails when the trampoline code size worst case is realized.
Observed on a Android device with HWASan [1] enabled, where heap
addresses have a non-zero tag in the most significant byte, and thus
require 4 instructions to materialize in emit_imm64.
[1] https://source.android.com/devices/tech/debug/hwasan
Commit migrated from https://github.com/mono/mono/commit/
06673e723ec3d59b071a1b763680f252b71c5de4
Zoltan Varga [Mon, 16 Dec 2019 23:52:02 +0000 (00:52 +0100)]
[llvm] Generate correct LLVM IR for OP_XEQUAL. (mono/mono#18217)
Commit migrated from https://github.com/mono/mono/commit/
aa9227f7c8af76105ded6dbd62c1cf5ae76bc54b
Zoltan Varga [Mon, 16 Dec 2019 23:09:24 +0000 (00:09 +0100)]
[netcore] Add AssemblyLoadContext:OnAssemblyLoad() to linker descriptor. (mono/mono#18219)
Commit migrated from https://github.com/mono/mono/commit/
9f5e38229e2a89baf129c072a21d516d598e510d
Jay Krell [Mon, 16 Dec 2019 22:06:11 +0000 (14:06 -0800)]
Remove handles/MonoError from some marshal icalls. (mono/mono#18036)
Remove handles/MonoError from some marshal icall functions.
This does some small other things.
In particular, if a function is not static for some platforms, make it not static for all.
static historically was valuable, because of default linker semantics around visibility.
I believe it is less important now, since visibility is default constrained.
Also being consistent across platforms seems good.
Maybe split off a separate PR for that.
Commit migrated from https://github.com/mono/mono/commit/
de359d493081350aff7234ef8c3d507b75ef11a5
Ryan Lucia [Mon, 16 Dec 2019 19:17:44 +0000 (14:17 -0500)]
[metadata] Check for GTDs in setup_generic_array_ifaces (mono/mono#18101)
Judging by https://github.com/mono/mono/blob/mono/mono@
4cefdcb7ce2d939ee78fb45d1b4913eb3bc064fd/mono/metadata/metadata.c#L3515 the cached_class is sometimes intentionally a GTD, which can get passed all the way down to setup_generic_array_ifaces and cause a crash.
Commit migrated from https://github.com/mono/mono/commit/
e19914fe6991a93af3f4c0730f1399d7bb5f1f66
Zoltan Varga [Mon, 16 Dec 2019 17:54:54 +0000 (18:54 +0100)]
[wasm] Regen wasm_m2n_invoke.g.h. (mono/mono#18212)
Commit migrated from https://github.com/mono/mono/commit/
ac1a12f9971fc7ba4f8f675af020dc18fd9d35ee
Calvin Buckley [Mon, 16 Dec 2019 10:06:00 +0000 (06:06 -0400)]
Fix locating Python interpreter when it isn't "python" (mono/mono#18197)
Fix locating Python interpreter when it isn't "python"
The "python" interpreter is specified by PEP-394. In it, an OS
can decide not to ship a "python" executable, and instead only
ship python2/3, providing some ambiguity for scripts that are
version-neutral, like the one Mono uses.
This uses an automake macro to locate a suitable Python, and
changes the makefile to use the located Python, whatever it may be.
Commit migrated from https://github.com/mono/mono/commit/
84221f04b5ff1f5f6de69100494ae7cb3ba94975
Jay Krell [Fri, 13 Dec 2019 21:49:15 +0000 (13:49 -0800)]
Add full compiler barriers to any fence that lacked a compiler barrier. (mono/mono#18177)
A compiler barrier generates no code.
It "only" inhibits certain compiler optimizations, which I do not consider
particularly worrisome, as most code is "fully" optimized, and
compiler barriers are relatively rare.
It could be a concern in code paths that greatly benefit
from compiler optimizations and for which barriers greatly
inhibits the compiler.
I would further suggest, though it is not here, that any compiler
half barrier (read, write) be a compiler full barrier instead,
as they sound pretty cheap, so simplify.
Similar cannot be said about CPU barriers.
They do not always generate code, but when they do, it can cost.
This is follow-up from https://github.com/mono/mono/pull/17849#issuecomment-
556273801
https://github.com/mono/mono/pull/17849#issuecomment-
557661604.
Commit migrated from https://github.com/mono/mono/commit/
e76fb5dbf92c34a944f6e3d5654a51661acbf6d8
Aleksey Kliger (λgeek) [Fri, 13 Dec 2019 20:32:06 +0000 (15:32 -0500)]
[cominterop] Attach to runtime from IUnknown and IDispatch methods (mono/mono#18175)
* [cominterop][test] Calling QueryInterface from an unattached thread asserts
If we pass a managed COM object to native code and the native code calls one of
the IUnknown methods, we assert because the thread is not attached but we want
to enter GC Unsafe mode.
* [cominterop] Attach to runtime from IUnkown and IDispatch methods
If the COM objects for a managed object is passed to a thread that hasn't
interacted with Mono before, we need to attach before doing GC thread state
transitions.
Addresses https://github.com/mono/mono/issues/18137
* [test] Call managed method through COM wrapper from unattached thread
This works, but I don't think we had a test previously. Call a managed method
via a COM interface from a thread that is not attached to the runtime, to
ensure that it is attached.
Commit migrated from https://github.com/mono/mono/commit/
d0f27ce4feb07bdcf7958272e6e943eb2a2f0f7b
Ankit Jain [Fri, 13 Dec 2019 19:06:16 +0000 (14:06 -0500)]
Bump msbuild to track xplat-master (mono/mono#18183)
- bump roslyn to 3.5.0-beta1-19606-04, to match msbuild
- bump nuget.exe to 5.5.0.6319 (5.5.0-preview1), to match msbuild
Commit migrated from https://github.com/mono/mono/commit/
ea50ca48ba6194daab46f45346567a733b602585
Jay Krell [Fri, 13 Dec 2019 18:57:33 +0000 (10:57 -0800)]
Fix on-demand initialization race conditions [threads.c]. (mono/mono#18166)
Commit migrated from https://github.com/mono/mono/commit/
13100439539433458675fabc37dda7e2feca55aa
Jay Krell [Fri, 13 Dec 2019 18:57:17 +0000 (10:57 -0800)]
Fix on-demand initialization race conditions [marshal.c]. (mono/mono#18169)
* Fix on-demand initialization race conditions [marshal.c].
* PR feedback: fix incorrect merge
Commit migrated from https://github.com/mono/mono/commit/
2eca6a1e37b7a802630bf77ba592321dddf82c72
Ryan Lucia [Fri, 13 Dec 2019 16:36:08 +0000 (11:36 -0500)]
[netcore] Implement AppDomain.AssemblyLoad (mono/mono#18143)
Commit migrated from https://github.com/mono/mono/commit/
7bc25cef6d4ec4b5bb443cc7e20259c4fea1e354
Jay Krell [Fri, 13 Dec 2019 16:29:30 +0000 (08:29 -0800)]
Fix on-demand initialization race conditions [marshal-ilgen.c] (mono/mono#18160)
* Fix on-demand initialization race conditions [marshal-ilgen.c]
* PR: Feedback more MONO_STATIC_POINTER_INIT instead of manual mono_atomic_store_seq.
* PR feedback: Narrow scope of from_oadate.
* One more MONO_STATIC_POINTER_INIT vs. mono_atomic_store_seq post-review.
* Repair whitespace.
* Alternate formating.
Commit migrated from https://github.com/mono/mono/commit/
b637c1db670c0d7355ae4f43f2e4ea1d0b162434
Jay Krell [Fri, 13 Dec 2019 11:28:34 +0000 (03:28 -0800)]
Fix on-demand initialize race conditions [cominterop.c] (mono/mono#18158)
Commit migrated from https://github.com/mono/mono/commit/
57c6b81b969d099953f77365dd566b9405f16887
Jay Krell [Fri, 13 Dec 2019 11:27:39 +0000 (03:27 -0800)]
Fix on-demand initialize race conditions [custom-attrs.c] (mono/mono#18159)
Commit migrated from https://github.com/mono/mono/commit/
64ad6460664615586883ac9ea5eb2ec478e85f18
Jay Krell [Fri, 13 Dec 2019 08:25:56 +0000 (00:25 -0800)]
Fix on-demand initialization race conditions [object.c]. (mono/mono#18163)
Fix on-demand initialization race conditions [object.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
0dc19600d120a5ea2731bbdbb82b067e87de65e7
Jay Krell [Fri, 13 Dec 2019 03:55:58 +0000 (19:55 -0800)]
Fix on-demand initialization race conditions [sgen]. (mono/mono#18170)
Fix on-demand initialization race conditions [sgen].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
9cefdf59adc59b085ff8cf187fabb17aa9a40737
Jay Krell [Fri, 13 Dec 2019 00:46:07 +0000 (16:46 -0800)]
Fix on-demand initialization race conditions [remoting.c]. (mono/mono#18168)
Fix on-demand initialization race conditions [remoting.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
a93e4712ecdc3f35306c53377dbb5d22a80ae201
Jay Krell [Fri, 13 Dec 2019 00:26:07 +0000 (16:26 -0800)]
Fix on-demand initialization race conditions [native-library.c]. (mono/mono#18162)
Fix on-demand initialization race conditions [native-library.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
943a2760ec6fafadd73cc59e1f4f40d5959842d7
Jay Krell [Thu, 12 Dec 2019 23:45:36 +0000 (15:45 -0800)]
Fix on-demand initialization race conditions [reflection.c]. (mono/mono#18167)
Fix on-demand initialization race conditions [reflection.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
1fe3d7eda6e7eaacd3b742823c97b04a13c37720
Jay Krell [Thu, 12 Dec 2019 23:36:19 +0000 (15:36 -0800)]
Fix on-demand initialization race conditions [mini] (mono/mono#18161)
Fix on-demand initialization race conditions [mini].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
51bc81919fea20c0a253d9c7f5d67ce4972bfeee
Jay Krell [Thu, 12 Dec 2019 22:55:33 +0000 (14:55 -0800)]
Fix on-demand initialization race conditions [sre.c]. (mono/mono#18164)
Fix on-demand initialization race conditions [sre.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
620d7cf84d026417c0390bcef0b50acda6e0f40d
Jay Krell [Thu, 12 Dec 2019 22:46:06 +0000 (14:46 -0800)]
Fix on-demand initialization race conditions [threadpool.c]. (mono/mono#18165)
Fix on-demand initialization race conditions [threadpool.c].
Extracted from https://github.com/mono/mono/pull/18150 which reviewer said was too big.
Commit migrated from https://github.com/mono/mono/commit/
f96ba075a1f1712c1c34e126870f9df89852ce3c
Ryan Lucia [Thu, 12 Dec 2019 20:00:28 +0000 (15:00 -0500)]
[netcore] Implement AppDomain.TypeResolve (mono/mono#18141)
Commit migrated from https://github.com/mono/mono/commit/
88dde8b7634094bd24c9f32ac894912e4d073b9f
Jay Krell [Thu, 12 Dec 2019 18:32:14 +0000 (10:32 -0800)]
Remove handles/MonoError from 12 easy socket icalls. (mono/mono#18035)
Also put _icall back on ends so the search coincides between managed and native.
Commit migrated from https://github.com/mono/mono/commit/
a1e16d32734eadfc9beddf77e522e80cf5276a43
Ryan Lucia [Thu, 12 Dec 2019 17:27:51 +0000 (12:27 -0500)]
[netcore] Enable AppDomainTests.AssemblyResolveInvalidAssemblyName (mono/mono#18157)
I don't remember why this wasn't enabled originally, but it seems to be passing now. I probably accidentally fixed it back when I made changes to our assembly name parsing.
Commit migrated from https://github.com/mono/mono/commit/
7d88d4d5024869b8c66fee2836551513a85ad281
Ryan Lucia [Thu, 12 Dec 2019 02:19:45 +0000 (21:19 -0500)]
[netcore] Enable AppDomainTests.MonitoringIsEnabled (mono/mono#18142)
Commit migrated from https://github.com/mono/mono/commit/
3ddcbda8b665fce86e8a18be5d30a39029c01cf9
Ryan Lucia [Wed, 11 Dec 2019 23:16:50 +0000 (18:16 -0500)]
[netcore] Remove MonoDomain.DoAssemblyResolve (mono/mono#18139)
This is no longer called in netcore builds as of a while ago, so get rid of it and the corresponding linker exclusion.
Commit migrated from https://github.com/mono/mono/commit/
acc8c0c696a9a9eea9f68d9f78fdd7f5b39526c9
Jay Krell [Wed, 11 Dec 2019 19:40:27 +0000 (11:40 -0800)]
Make Socket.Socket_icall static, as most icalls are, removing the first, unused parameter. (mono/mono#18130)
Also partial undo recent and append _icall to end.
This is verbose, but maybe worthwhile to aid search.
This is extracted from https://github.com/mono/mono/pull/17978.
Commit migrated from https://github.com/mono/mono/commit/
256eda8c7f1d4d18578388284aa224c7b22df75a
Ryan Lucia [Wed, 11 Dec 2019 15:42:10 +0000 (10:42 -0500)]
[utils] Correctly convert MONO_DL_LOCAL to RTLD_LOCAL (mono/mono#18121)
On Linux, neither flag being specified will result in a default of RTLD_LOCAL. Unfortunately, on MacOS it's the opposite - the default is RTLD_GLOBAL. This means currently there is no way to set RTLD_LOCAL on Macs, so despite the potential for this to break someone it directly contradicts our documentation and needs to be changed.
Commit migrated from https://github.com/mono/mono/commit/
0e05bda2356e453e6ab5ae8745c86bddf82b9ce6
Jay Krell [Wed, 11 Dec 2019 09:40:00 +0000 (01:40 -0800)]
Sockets: Foo_internal to Foo_icall and ves_icall_Foo_internal to ves_icall_Foo. (mono/mono#18017)
The first is to avoid requiring the signature matching in icall resolution.
The second is just to shorten names.
Commit migrated from https://github.com/mono/mono/commit/
97dd6cf04c2dd62b7cdce2a96c8824b5f3e7280a
Bernhard Urban-Forster [Tue, 10 Dec 2019 21:06:48 +0000 (22:06 +0100)]
[interp] relop result is always int (mono/mono#18114)
This can lead to problems on big endian.
```
result.i = (int) 1;
--> 0x0000_0001_XXXX_XXXX;
result.l = (long) 1;
--> 0x0000_0000_0000_0001;
```
On little endian it's always `0x0000_0000_0000_0001`, so it doesn't matter.
Commit migrated from https://github.com/mono/mono/commit/
a65b7af6d5abf00d7be1f0e85c219657686e33c3
Ryan Lucia [Tue, 10 Dec 2019 19:58:58 +0000 (14:58 -0500)]
[utils] Make mono_dl_open default to RTLD_LOCAL on netcore (mono/mono#17912)
* [utils] Make mono_dl_open default to RTLD_LOCAL
The exception is for fallback handlers added via the embedding API, in which case we convert the flags over to preserve legacy behavior
* Convert flags properly for embedding API use
* Changes
* Turn off -fvisibility=hidden temporarily
TESTING
* Undo some previous crimes, maybe fix failure
* Leave legacy mono unchanged, defaulting to RTLD_GLOBAL
Commit migrated from https://github.com/mono/mono/commit/
a778c46362503e44d7bea84543e4351462d335c5
Bernhard Urban-Forster [Tue, 10 Dec 2019 17:55:09 +0000 (18:55 +0100)]
[interp] fix build when DEBUG_INTERP is enabled (mono/mono#18112)
broke with mono/mono@
c4136ebd94567bb29557c94e7480e24fe72ffdac
Commit migrated from https://github.com/mono/mono/commit/
ef422d9cb7bccd90b19f2cf22a7a4d34e26b79bb
Bernhard Urban-Forster [Tue, 10 Dec 2019 11:16:05 +0000 (12:16 +0100)]
[debugger] skip suspend for unattached threads (mono/mono#18105)
When the debugger tries to suspend all the VM threads, it can happen with cooperative-suspend that it tries to suspend a thread that has previously been attached, but then did a "light" detach (that only unsets the domain). With the domain set to `NULL`, looking up a JitInfo for a given `ip` will result into a crash, but it isn't even necessarily needed for the purpose of suspending a thread.
More details: Consider the following:
```
(lldb) c
error: Process is running. Use 'process interrupt' to pause execution.
Process 12832 stopped
* thread mono/mono#9, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
frame mono/mono#0: 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6
2713 MonoDomain *domain = (MonoDomain *) mono_thread_info_get_suspend_state (info)->unwind_data [MONO_UNWIND_DATA_DOMAIN];
2714 if (!domain) {
2715 /* not attached */
-> 2716 ji = NULL;
2717 } else {
2718 ji = mono_jit_info_table_find_internal ( domain, MONO_CONTEXT_GET_IP (&mono_thread_info_get_suspend_state (info)->ctx), TRUE, TRUE);
2719 }
Target 0: (WatchWCSessionAppWatchOSExtension) stopped.
(lldb) bt
* thread mono/mono#9, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
* frame mono/mono#0: 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6
frame mono/mono#1: 0x004e177b WatchWCSessionAppWatchOSExtension`mono_thread_info_safe_suspend_and_run(id=0xb0767000, interrupt_kernel=0, callback=(WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical at debugger-agent.c:2708), user_data=0xb04dc718) at mono-threads.c:1358:19
frame mono/mono#2: 0x00222799 WatchWCSessionAppWatchOSExtension`notify_thread(key=0x03994508, value=0x81378c00, user_data=0x00000000) at debugger-agent.c:2747:2
frame mono/mono#3: 0x00355bd8 WatchWCSessionAppWatchOSExtension`mono_g_hash_table_foreach(hash=0x8007b4e0, func=(WatchWCSessionAppWatchOSExtension`notify_thread at debugger-agent.c:2733), user_data=0x00000000) at mono-hash.c:310:4
frame mono/mono#4: 0x0021e955 WatchWCSessionAppWatchOSExtension`suspend_vm at debugger-agent.c:2844:3
frame mono/mono#5: 0x00225ff0 WatchWCSessionAppWatchOSExtension`process_event(event=EVENT_KIND_THREAD_START, arg=0x039945d0, il_offset=0, ctx=0x00000000, events=0x805b28e0, suspend_policy=2) at debugger-agent.c:4012:3
frame mono/mono#6: 0x00227c7c WatchWCSessionAppWatchOSExtension`process_profiler_event(event=EVENT_KIND_THREAD_START, arg=0x039945d0) at debugger-agent.c:4072:2
frame mono/mono#7: 0x0021b174 WatchWCSessionAppWatchOSExtension`thread_startup(prof=0x00000000, tid=
2957889536) at debugger-agent.c:4149:2
frame mono/mono#8: 0x0037912d WatchWCSessionAppWatchOSExtension`mono_profiler_raise_thread_started(tid=
2957889536) at profiler-events.h:103:1
frame mono/mono#9: 0x003d53da WatchWCSessionAppWatchOSExtension`fire_attach_profiler_events(tid=0xb04dd000) at threads.c:1120:2
frame mono/mono#10: 0x003d4d83 WatchWCSessionAppWatchOSExtension`mono_thread_attach(domain=0x801750a0) at threads.c:1547:2
frame mono/mono#11: 0x003df1a1 WatchWCSessionAppWatchOSExtension`mono_threads_attach_coop_internal(domain=0x801750a0, cookie=0xb04dcc0c, stackdata=0xb04dcba8) at threads.c:6008:3
frame mono/mono#12: 0x003df287 WatchWCSessionAppWatchOSExtension`mono_threads_attach_coop(domain=0x00000000, dummy=0xb04dcc0c) at threads.c:6045:9
frame mono/mono#13: 0x005034b8 WatchWCSessionAppWatchOSExtension`::xamarin_switch_gchandle(self=0x80762c20, to_weak=false) at runtime.m:1805:2
frame mono/mono#14: 0x005065c1 WatchWCSessionAppWatchOSExtension`::xamarin_retain_trampoline(self=0x80762c20, sel="retain") at trampolines.m:693:2
frame mono/mono#15: 0x657ea520 libobjc.A.dylib`objc_retain + 64
frame mono/mono#16: 0x4b4d9caa WatchConnectivity`__66-[WCSession onqueue_handleDictionaryMessageRequest:withPairingID:]_block_invoke + 279
frame mono/mono#17: 0x453c7df7 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame mono/mono#18: 0x453c7cf4 Foundation`-[NSBlockOperation main] + 88
frame mono/mono#19: 0x453cacee Foundation`__NSOPERATION_IS_INVOKING_MAIN__ + 27
frame mono/mono#20: 0x453c6ebd Foundation`-[NSOperation start] + 835
frame mono/mono#21: 0x453cb606 Foundation`__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 27
frame mono/mono#22: 0x453cb12e Foundation`__NSOQSchedule_f + 194
frame mono/mono#23: 0x453cb26e Foundation`____addOperations_block_invoke_4 + 20
frame mono/mono#24: 0x65de007b libdispatch.dylib`_dispatch_call_block_and_release + 15
frame mono/mono#25: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
frame mono/mono#26: 0x65de3788 libdispatch.dylib`_dispatch_continuation_pop + 421
frame mono/mono#27: 0x65de2ee3 libdispatch.dylib`_dispatch_async_redirect_invoke + 818
frame mono/mono#28: 0x65df087d libdispatch.dylib`_dispatch_root_queue_drain + 354
frame mono/mono#29: 0x65df0ff3 libdispatch.dylib`_dispatch_worker_thread2 + 109
frame mono/mono#30: 0x66024fa0 libsystem_pthread.dylib`_pthread_wqthread + 208
frame mono/mono#31: 0x66024e44 libsystem_pthread.dylib`start_wqthread + 36
```
Going further, `info` is about this thread:
```
(lldb) p/x *(int *)(((char *) info->node.key) + 0xa0)
(int) $2 = 0x01243f93
(lldb) thread list
Process 12832 stopped
thread mono/mono#1: tid = 0x1243ee1, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'tid_303', queue = 'com.apple.main-thread'
thread mono/mono#2: tid = 0x1243ee6, 0x65f816e2 libsystem_kernel.dylib`__recvfrom + 10
thread mono/mono#3: tid = 0x1243ee7, 0x65f81aea libsystem_kernel.dylib`__psynch_cvwait + 10, name = 'SGen worker'
thread mono/mono#4: tid = 0x1243ee9, 0x65f7e3d2 libsystem_kernel.dylib`semaphore_wait_trap + 10, name = 'Finalizer'
thread mono/mono#5: tid = 0x1243eea, 0x65f816e2 libsystem_kernel.dylib`__recvfrom + 10, name = 'Debugger agent'
thread mono/mono#6: tid = 0x1243f1d, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'com.apple.uikit.eventfetch-thread'
thread mono/mono#8: tid = 0x1243f93, 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
* thread mono/mono#9: tid = 0x12443a9, 0x00222870 WatchWCSessionAppWatchOSExtension`debugger_interrupt_critical(info=0x81365400, user_data=0xb04dc718) at debugger-agent.c:2716:6, name = 'tid_a31f', queue = 'NSOperationQueue 0x8069b670 (QOS: UTILITY)', stop reason = breakpoint 1.1
thread mono/mono#10: tid = 0x1244581, 0x65f7fd32 libsystem_kernel.dylib`__workq_kernreturn + 10
(lldb) thread select 8
* thread mono/mono#8, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
frame mono/mono#0: 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10
libsystem_kernel.dylib`mach_msg_trap:
-> 0x65f7e396 <+10>: retl
0x65f7e397 <+11>: nop
libsystem_kernel.dylib`mach_msg_overwrite_trap:
0x65f7e398 <+0>: movl $0xffffffe0, %eax ; imm = 0xFFFFFFE0
0x65f7e39d <+5>: calll 0x65f85f44 ; _sysenter_trap
(lldb) bt
* thread mono/mono#8, name = 'tid_6d0f', queue = 'NSOperationQueue 0x8069b300 (QOS: UTILITY)'
* frame mono/mono#0: 0x65f7e396 libsystem_kernel.dylib`mach_msg_trap + 10
frame mono/mono#1: 0x65f7e8ff libsystem_kernel.dylib`mach_msg + 47
frame mono/mono#2: 0x66079679 libxpc.dylib`_xpc_send_serializer + 104
frame mono/mono#3: 0x660794da libxpc.dylib`_xpc_pipe_simpleroutine + 80
frame mono/mono#4: 0x66079852 libxpc.dylib`xpc_pipe_simpleroutine + 43
frame mono/mono#5: 0x66043a8f libsystem_trace.dylib`___os_activity_stream_reflect_block_invoke_2 + 30
frame mono/mono#6: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
frame mono/mono#7: 0x65de3d71 libdispatch.dylib`_dispatch_block_invoke_direct + 257
frame mono/mono#8: 0x65de3c62 libdispatch.dylib`dispatch_block_perform + 112
frame mono/mono#9: 0x6604349a libsystem_trace.dylib`_os_activity_stream_reflect + 725
frame mono/mono#10: 0x6604ef19 libsystem_trace.dylib`_os_log_impl_stream + 468
frame mono/mono#11: 0x6604e44d libsystem_trace.dylib`_os_log_impl_flatten_and_send + 6410
frame mono/mono#12: 0x6604cb3b libsystem_trace.dylib`_os_log + 137
frame mono/mono#13: 0x6604f4aa libsystem_trace.dylib`_os_log_impl + 31
frame mono/mono#14: 0x4b4eb4e9 WatchConnectivity`WCSerializePayloadDictionary + 393
frame mono/mono#15: 0x4b4d7c4d WatchConnectivity`-[WCSession onqueue_sendResponseDictionary:identifier:] + 195
frame mono/mono#16: 0x4b4da435 WatchConnectivity`__66-[WCSession onqueue_handleDictionaryMessageRequest:withPairingID:]_block_invoke.411 + 35
frame mono/mono#17: 0x453c7df7 Foundation`__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 12
frame mono/mono#18: 0x453c7cf4 Foundation`-[NSBlockOperation main] + 88
frame mono/mono#19: 0x453cacee Foundation`__NSOPERATION_IS_INVOKING_MAIN__ + 27
frame mono/mono#20: 0x453c6ebd Foundation`-[NSOperation start] + 835
frame mono/mono#21: 0x453cb606 Foundation`__NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 27
frame mono/mono#22: 0x453cb12e Foundation`__NSOQSchedule_f + 194
frame mono/mono#23: 0x453cb067 Foundation`____addOperations_block_invoke_2 + 20
frame mono/mono#24: 0x65dedf49 libdispatch.dylib`_dispatch_block_async_invoke2 + 77
frame mono/mono#25: 0x65de4461 libdispatch.dylib`_dispatch_block_async_invoke_and_release + 17
frame mono/mono#26: 0x65de126f libdispatch.dylib`_dispatch_client_callout + 14
frame mono/mono#27: 0x65de3788 libdispatch.dylib`_dispatch_continuation_pop + 421
frame mono/mono#28: 0x65de2ee3 libdispatch.dylib`_dispatch_async_redirect_invoke + 818
frame mono/mono#29: 0x65df087d libdispatch.dylib`_dispatch_root_queue_drain + 354
frame mono/mono#30: 0x65df0ff3 libdispatch.dylib`_dispatch_worker_thread2 + 109
frame mono/mono#31: 0x66024fa0 libsystem_pthread.dylib`_pthread_wqthread + 208
frame mono/mono#32: 0x66024e44 libsystem_pthread.dylib`start_wqthread + 36
```
which is a thread in a "light" detach state (aka. coop detach), where we only unset the domain:
https://github.com/mono/mono/blob/mono/mono@
4cefdcb7ce2d939ee78fb45d1b4913eb3bc064fd/mono/metadata/threads.c#L6084-L6111
Fixes https://github.com/mono/mono/issues/17926
Commit migrated from https://github.com/mono/mono/commit/
80b1e103cbb30be9a206ccaa012d68a3d0bc0ca4
Aleksey Kliger (λgeek) [Tue, 10 Dec 2019 11:12:50 +0000 (06:12 -0500)]
[mini] Fix delegate trampoline virtual call via delgate Invoke (mono/mono#18073)
* [mini] Fix delegate trampoline virtual call via delgate Invoke
If we need to jit the Invoke method of a delegate, we get tramp_info with a
NULL method.
Background: normally when we create a delegate around a virtual method,
handle_delegate_ctor will just create a virtual invoke trampoline with
mono_arch_get_delegate_virtual_invoke_impl which doesn't get here. But if
we're asked to compile the delegate's Invoke method, then compile_special ()
will create a tramp_info with a null method, and return a delegate trampoline.
That's the case here - we had
var del = SomeDelegate(obj.VirtualMethod);
var invoke_method = del.GetType().GetMethod ("Invoke");
invoke_method.Invoke (del, args);
or
var del = SomeDelegate(obj.VirtualMethod);
var another_del = OtherDelegate (del.Invoke);
another_del (args);
in both cases, we end up in mono_delegate_trampoline with tramp_info->method ==
NULL.
in the second case the IL is like this:
newobj instance void Derived::'.ctor'
ldvirtftn instance void class Base::VirtualMethod()
newobj instance void class SomeDelegate::'.ctor'(object, native int)
So delegate->target is a derived instance but delegate->method is some base
class method.
Addresses https://github.com/mono/mono/issues/17718
* [tests] Add tests for compiling delegate's Invoke method
Where the delegate calls a virtual method
Commit migrated from https://github.com/mono/mono/commit/
7704bd1b9260d0f6434ca02a2e7341f7c94113d8
Bernhard Urban-Forster [Tue, 10 Dec 2019 07:25:31 +0000 (08:25 +0100)]
[debugger] remove unused thread suspend count (mono/mono#18102)
Commit migrated from https://github.com/mono/mono/commit/
fd44435a84a1a963cbda97e1ff0fdb6e35e7d01a
Jay Krell [Mon, 9 Dec 2019 17:59:10 +0000 (09:59 -0800)]
[cxx] Fix mono-boehm to compile as C++. (mono/mono#18086)
https://jenkins.mono-project.com/job/test-mono-pull-request-i386/32263/consoleText
```
~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
boehm-gc.c: In function 'void mono_gc_base_init()':
boehm-gc.c:202:42: error: invalid conversion from
'void (*)(size_t) {aka void (*)(unsigned int)}' to
GC_on_heap_resize_proc {aka void (*)(long unsigned int)}' [-fpermissive]
GC_set_on_heap_resize (on_gc_heap_resize);
^
In file included from ../../mono/utils/gc_wrapper.h:44:0,
from ../../mono/metadata/gc-internals.h:16,
from boehm-gc.c:16:
../../external/bdwgc/include/gc.h:132:21: note:
initializing argument 1 of 'void GC_set_on_heap_resize(GC_on_heap_resize_proc)'
GC_API void GC_CALL GC_set_on_heap_resize(GC_on_heap_resize_proc);
```
Commit migrated from https://github.com/mono/mono/commit/
5cbb1f4be8a0434ad92c39dfcece15f51f920e5b
Egor Bogatov [Mon, 9 Dec 2019 13:55:44 +0000 (16:55 +0300)]
[netcore] Enable more tests for interpreter and llvm on CI (mono/mono#17957)
* Enable more tests
* fix build?
* forward XUNIT_MONO_ENV_OPTIONS
* increase timeout
* ignore some tests for interpreter
* ignore more tests
* move interp specific issues to a separate rsp
* fix CI
* fix CI
* undo build.sh chmod
* revert chmod for xunit-summary-py
* improve xunit summary
* Ignore the whole System.Net.Tests namespace
* Ignore System.Text.Json
* disable the whole BinaryFormatterTests
* Disable System.Net.Http.Functional.Tests
Commit migrated from https://github.com/mono/mono/commit/
2befdcfa52c76584d750092ced62c1ea8bc570f8
Jay Krell [Mon, 9 Dec 2019 07:17:54 +0000 (23:17 -0800)]
fix warning: threadpool-worker-default.c: In function 'worker_try_create': 'now' may be used uninitialized (mono/mono#18056)
https://jenkins.mono-project.com/job/build-source-tarball-mono-pullrequest/854/console
Commit migrated from https://github.com/mono/mono/commit/
ed6b8024b0eb933d78ecc2e54bc8a798f868cf7e
Jay Krell [Sun, 8 Dec 2019 14:30:48 +0000 (06:30 -0800)]
Add some missing barriers when dealing with global caches (mono/mono#18032)
* Add some missing barriers when dealing with global caches
accessed from multiple threads without locks.
This is based on earlier PR https://github.com/mono/mono/pull/17849.
Read-side barriers are removed.
More analysis is needed to determine if they are needed (which pointer
read vs. written).
Write-side barriers are compiler barrier + store-release instead of full barrier.
Note all candidates are converted to new form yet.
Cases that do motivate read-wide barriers are skipped.
e.g.
`mono_arch_start_dyn_call`
`get_agent_domain_info`
`init_jit_info_dbg_attrs`
* PR: Remove 'Try one more time..'
Commit migrated from https://github.com/mono/mono/commit/
a6c4eafee8a264ce786d00c6035b0acc7fa97a8b
Sam Patel [Sat, 7 Dec 2019 06:11:59 +0000 (01:11 -0500)]
Update glib-remap.h to include g_module_address (mono/mono#18076)
Commit migrated from https://github.com/mono/mono/commit/
74567a0a347c8c2dc91e2ca65defb5f50bed24e3
Ankit Jain [Fri, 6 Dec 2019 15:55:44 +0000 (10:55 -0500)]
Bump msbuild to track xplat-master (mono/mono#18050)
.. to get changes from https://github.com/mono/msbuild/pull/162 .
And bump roslyn to 3.4.0-beta4-19569-03 to match msbuild.
Commit migrated from https://github.com/mono/mono/commit/
d1db937e78834aac251ed78cb5d44e2d62c7df2a
Aleksey Kliger (λgeek) [Fri, 6 Dec 2019 15:50:34 +0000 (10:50 -0500)]
[threads] Add back mono_threads_attach_tools_thread as a public API (mono/mono#18048)
* [utils] Add back mono_threads_attach_tools_thread
In https://github.com/mono/mono/commit/mono/mono@
a5da7b21f4b6dbc5eaa09c2addee91b84dc1dbd5
we got rid of "tools" threads internally to the runtime.
However since the API was previously marked with MONO_API it was an internal
API that some embedders depended on.
This PR adds back an (external-only) limited form of tools thread.
The runtime is aware of the Tools thread in that FOREACH_THREAD_* macros will
iterate over them, and the thread has a coop thread state machine. (That is,
mono_thread_info_current() and GC Safe and GC Unsafe transitions all work.)
However the thread is:
1. Not stopped by the GC
2. Is not interrupted by profiler sampling.
3. Does not have a "current domain"
4. (As a consequence of the above) cannot call managed methods or touch managed
objects.
Such threads are useful for low-level interaction with the runtime such as
querying metadata, the JIT state and other coordination.
mono_threads_attach_tools_thread should be called no more than once. It should
not be called on a thread that is already attached with mono_thread_atach, and
vice versa.
Addresses https://github.com/mono/mono/issues/18011
* [threads] Make mono_threads_attach_tools_thread into a public API
Commit migrated from https://github.com/mono/mono/commit/
3dabeddfc65e11ece3a4d089a2796f8da850c881
Bernhard Urban-Forster [Fri, 6 Dec 2019 10:35:11 +0000 (11:35 +0100)]
[ppc32] delete leftover code from pre-monoctx area (mono/mono#18072)
Also update assert which doesn't make sense since we have moved over to MonoContext
Some context: mono/mono@
e7011c780f676914f559f14f25e76c192bb2b0b2
Fixes: https://github.com/mono/mono/issues/18064
Commit migrated from https://github.com/mono/mono/commit/
121928d29ac1e0aebb80531b3ebcca1a9ffcd618
Jay Krell [Fri, 6 Dec 2019 02:55:56 +0000 (18:55 -0800)]
[cxx] Remove use of register keyword. (mono/mono#18057)
[cxx] Remove use of register keyword.
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm/19408/parsed_console/log_content.html
```
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/utils/mono-md5.c:259:2: warning: 'register' storage class specifier is deprecated and incompatible with C++17 [-Wdeprecated-register]
register guint32 a, b, c, d;
^~~~~~~~~
4 warnings generated.
```
Commit migrated from https://github.com/mono/mono/commit/
12bc4717fd0885888f0b3d8795f56309ad0952e3
Jay Krell [Thu, 5 Dec 2019 21:41:09 +0000 (13:41 -0800)]
[cxx][netcore] Fix goto around init. (mono/mono#18058)
https://jenkins.mono-project.com/job/test-mono-pull-request-wasm/19408/parsed_console/log_content.html
```
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/metadata/icall.c:882:1: error: jump to label 'exit' [-fpermissive]
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/metadata/icall.c:882:1: error: jump to label 'exit' [-fpermissive]
/mnt/jenkins/workspace/test-mono-pull-request-wasm/mono/metadata/icall.c:882:1: error: jump to label 'exit' [-fpermissive]
```
Commit migrated from https://github.com/mono/mono/commit/
a131e9bbb0ad41921bae42f1a44e7b4d2c337ba2
Egor Bogatov [Thu, 5 Dec 2019 19:44:05 +0000 (22:44 +0300)]
Let user overwrite opt -Ox level (mono/mono#18012)
Commit migrated from https://github.com/mono/mono/commit/
63f155ac46b1502280ce7c286d360e2a43b5798f
Jay Krell [Thu, 5 Dec 2019 18:36:11 +0000 (10:36 -0800)]
Remove handles/MonoError from two socket icalls. (mono/mono#17977)
Remove handles/MonoError from two socket icalls.
Ongoing removal of handles() icalls.
This is small, to pause and remove `mono_class_get_field_from_name_full` from w32socket.c.
Commit migrated from https://github.com/mono/mono/commit/
b99ea70e431abec1d0832a849a36cb93202307b7
Egor Bogatov [Thu, 5 Dec 2019 18:13:11 +0000 (21:13 +0300)]
Merge pull request mono/mono#18053 from EgorBo/fix-fneg-llvm
LLVM: use fneg instead of fsub for `-x`
Commit migrated from https://github.com/mono/mono/commit/
84839ab297e0e5e2e51744933e7e5d71bfa53db6
Jay Krell [Thu, 5 Dec 2019 18:10:29 +0000 (10:10 -0800)]
[netcore] Remove approx. 10 icalls. (mono/mono#18018)
* [netcore] Remove ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni and _len icalls.
They are implemented in C#.
The C# is equivalent to the C, and could be used for classic runtime, except for the treatment of large/negative lengths.
* Remove a few more icalls.
Instead of ifdef and leaving them uncompiled when compiling netcore,
declare them and put asserts in them.
Commit migrated from https://github.com/mono/mono/commit/
ae9192f96febdb5ceea3b73d6aa226d601006371
Zoltan Varga [Thu, 5 Dec 2019 15:02:43 +0000 (16:02 +0100)]
[llvm] Avoid decomposing OP_STOREV_MEMBASE early for types which contains no references. (mono/mono#18041)
Commit migrated from https://github.com/mono/mono/commit/
e67673fac85d13882256893d1b61c08ca0fc13c6
Jay Krell [Thu, 5 Dec 2019 09:19:24 +0000 (01:19 -0800)]
Fix ifndef include guard in icall-decl.h. (mono/mono#18055)
There was no clash so ok either way, but this is more like intended.
Commit migrated from https://github.com/mono/mono/commit/
5a5e092a53111153b50742f1d021da45c09288b3
Egor Bogatov [Thu, 5 Dec 2019 01:38:34 +0000 (04:38 +0300)]
Convert to 0/1 in OP_XEQUAL (mono/mono#18038)
Commit migrated from https://github.com/mono/mono/commit/
a3fbb644938bdfe008796f281e958f7707069dfe
EgorBo [Wed, 4 Dec 2019 23:09:11 +0000 (02:09 +0300)]
remove some items from rsp
Commit migrated from https://github.com/mono/mono/commit/
55a3c10e7235e2ace77a6dc502e9349568a68b7f
EgorBo [Wed, 4 Dec 2019 23:03:24 +0000 (02:03 +0300)]
use fneg instead of fsub
Commit migrated from https://github.com/mono/mono/commit/
92047c453ffe89dc8283c0705ddc8a7f457371b3
Bernhard Urban-Forster [Wed, 4 Dec 2019 21:23:19 +0000 (22:23 +0100)]
[amd64] align application stack pointer in signal handler (mono/mono#18021)
* [amd64] align application stack pointer in signal handler
16byte stack pointer alignment is only required in certain places by the ABI, so the assumption that it holds all the time is wrong (though, it passed CI 😅). We have to setup the frame properly, i.e. we have to ensure the stack pointer is properly aligned. That's what we have done previously too.
Regression of https://github.com/mono/mono/pull/17922
Fixes https://github.com/mono/mono/issues/18006
* add ALIGN_DOWN_TO macro
* remove unnecessary ifndefs
Commit migrated from https://github.com/mono/mono/commit/
9d58bc1d12085f19ac2ba198c2bc4f9798810532
Alexander Köplinger [Wed, 4 Dec 2019 21:16:21 +0000 (22:16 +0100)]
Update submodules before running external/bdwgc/autogen.sh (mono/mono#18042)
Otherwise we'll run into issues because in configure.ac we update submodules _after_ we try to call external/bdwgc/configure (which won't be there if autogen.sh didn't run).
This would manifest itself as `*** No rule to make target 'all'.` in external/bdwgc when you build as there's no Makefile.
Commit migrated from https://github.com/mono/mono/commit/
59554712cc1e385dc73eb309cc810c08e28ef23f
Alexander Köplinger [Wed, 4 Dec 2019 18:55:22 +0000 (19:55 +0100)]
Remove mk/ folder (mono/mono#18039)
The plan to put additional helpers into this directory didn't materialize and we can just inline the one thing we have in common.mk where needed.
Commit migrated from https://github.com/mono/mono/commit/
4e8ead7caf330dcc271fac38cdbf5b0ef90e2361
Jonathan Peppers [Wed, 4 Dec 2019 10:50:59 +0000 (04:50 -0600)]
[android] don't probe directories for .config files (mono/mono#18024)
* [android] don't probe directories for .config files
In Xamarin.Android, on startup we see logging like this for every .NET
assembly:
12-03 14:27:42.104 26842 26842 D Mono : Prepared to set up assembly 'FormsViewGroup' (/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll)
12-03 14:27:42.104 26842 26842 D Mono : Assembly FormsViewGroup[0xebcee9c0] added to domain RootDomain, ref_count=1
12-03 14:27:42.104 26842 26842 D Mono : Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll'.
12-03 14:27:42.104 26842 26842 D Mono : Config attempting to parse: '/storage/emulated/0/Android/data/Xamarin.Forms_Performance_Integration/files/.__override__/FormsViewGroup.dll.config'.
12-03 14:27:42.104 26842 26842 D Mono : Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/sdks/out/android-x86-release/etc/mono/assemblies/FormsViewGroup/FormsViewGroup.config'.
In most cases, no `.dll.config` file exists and so it probes this
macOS-looking path:
/Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/sdks/out/android-x86-release/etc/mono/assemblies/FormsViewGroup/FormsViewGroup.config
It looks like this is happening because nothing in Xamarin.Android
calls `mono_set_dirs` or `mono_set_config_dir` and so it falls back to
using `MONO_CFG_DIR`. `MONO_CFG_DIR` is set to a path on the build
machine.
Even if Xamarin.Android *did* call `mono_set_config_dir`, the code
appends `mono/assemblies`:
cfg = g_build_filename (cfg_dir, "mono", "assemblies", aname, cfg_name, (const char*)NULL);
So it doesn't seem useful to use this fallback at all, there would
never be a file found.
I wrapped the appropriate code in `#ifndef TARGET_ANDROID` blocks.
I was able to see a minor *maybe* ~20ms performance improvement on
startup:
Before:
12-03 14:27:48.494 26903 26903 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:601::443900
12-03 14:27:54.356 26963 26963 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:587::495400
12-03 14:28:00.263 27021 27021 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:586::147100
12-03 14:28:06.135 27074 27074 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:593::639100
12-03 14:28:11.988 27129 27129 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:571::194900
After:
12-03 14:46:50.590 27737 27737 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:503::918700
12-03 14:46:56.517 27794 27794 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:570::533600
12-03 14:47:02.368 27850 27850 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:537::435000
12-03 14:47:08.289 27904 27904 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:587::830900
12-03 14:47:14.130 27965 27965 I monodroid-timing: Runtime.init: end, total time; elapsed: 0s:555::593400
This was the Xamarin.Forms integration project in xamarin-android.
Running a `Debug` build on a HAXM x86 emulator on Windows.
https://github.com/xamarin/xamarin-android/tree/master/tests/Xamarin.Forms-Performance-Integration
* Add --enable-minimal=cfgdir_config
* This also defines `DISABLE_CFGDIR_CONFIG`
* Used this setting for android
Commit migrated from https://github.com/mono/mono/commit/
b816189b947ab590e82509f6eb6130546927c988
Aleksey Kliger (λgeek) [Wed, 4 Dec 2019 00:56:30 +0000 (19:56 -0500)]
[configure.ac] Build on FreeBSD/PowerPC64 (mono/mono#18015)
Community contribution from https://github.com/mono/mono/issues/18009
from @igorzigorz
Commit migrated from https://github.com/mono/mono/commit/
467d46f8abbd55c242b267771aa7575730a2a72c
Egor Bogatov [Tue, 3 Dec 2019 23:19:32 +0000 (02:19 +0300)]
Merge pull request mono/mono#18013 from EgorBo/intrin-string-memcpy
[netcore] Improve jitdiff tool
Commit migrated from https://github.com/mono/mono/commit/
85826e5c2771d9b30dabde51f6fcce83988f4b7f
EgorBo [Tue, 3 Dec 2019 15:13:48 +0000 (18:13 +0300)]
Improve TryParseFunctionName in jitdiff
Commit migrated from https://github.com/mono/mono/commit/
5f58bb0959d6a50f8577e52b715f46185ab8e429
EgorBo [Tue, 3 Dec 2019 15:11:42 +0000 (18:11 +0300)]
Remove dead docs
Commit migrated from https://github.com/mono/mono/commit/
ea0824cb2276ca756f667219ce44a135a0ff4318