platform/upstream/dotnet/runtime.git
4 years agoSockets: Foo_internal to Foo_icall and ves_icall_Foo_internal to ves_icall_Foo. ...
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

4 years ago[interp] relop result is always int (mono/mono#18114)
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

4 years ago[utils] Make mono_dl_open default to RTLD_LOCAL on netcore (mono/mono#17912)
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

4 years ago[interp] fix build when DEBUG_INTERP is enabled (mono/mono#18112)
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

4 years ago[debugger] skip suspend for unattached threads (mono/mono#18105)
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

4 years ago[mini] Fix delegate trampoline virtual call via delgate Invoke (mono/mono#18073)
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

4 years ago[debugger] remove unused thread suspend count (mono/mono#18102)
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

4 years ago[cxx] Fix mono-boehm to compile as C++. (mono/mono#18086)
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

4 years ago[netcore] Enable more tests for interpreter and llvm on CI (mono/mono#17957)
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

4 years agofix warning: threadpool-worker-default.c: In function 'worker_try_create': 'now'...
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

4 years agoAdd some missing barriers when dealing with global caches (mono/mono#18032)
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

4 years agoUpdate glib-remap.h to include g_module_address (mono/mono#18076)
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

4 years agoBump msbuild to track xplat-master (mono/mono#18050)
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

4 years ago[threads] Add back mono_threads_attach_tools_thread as a public API (mono/mono#18048)
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

4 years ago[ppc32] delete leftover code from pre-monoctx area (mono/mono#18072)
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

4 years ago[cxx] Remove use of register keyword. (mono/mono#18057)
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

4 years ago[cxx][netcore] Fix goto around init. (mono/mono#18058)
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

4 years agoLet user overwrite opt -Ox level (mono/mono#18012)
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

4 years agoRemove handles/MonoError from two socket icalls. (mono/mono#17977)
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

4 years agoMerge pull request mono/mono#18053 from EgorBo/fix-fneg-llvm
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

4 years ago[netcore] Remove approx. 10 icalls. (mono/mono#18018)
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

4 years ago[llvm] Avoid decomposing OP_STOREV_MEMBASE early for types which contains no referenc...
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

4 years agoFix ifndef include guard in icall-decl.h. (mono/mono#18055)
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

4 years agoConvert to 0/1 in OP_XEQUAL (mono/mono#18038)
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

4 years agoremove some items from rsp
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

4 years agouse fneg instead of fsub
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

4 years ago[amd64] align application stack pointer in signal handler (mono/mono#18021)
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

4 years agoUpdate submodules before running external/bdwgc/autogen.sh (mono/mono#18042)
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

4 years agoRemove mk/ folder (mono/mono#18039)
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

4 years ago[android] don't probe directories for .config files (mono/mono#18024)
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

4 years ago[configure.ac] Build on FreeBSD/PowerPC64 (mono/mono#18015)
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

4 years agoMerge pull request mono/mono#18013 from EgorBo/intrin-string-memcpy
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

4 years agoImprove TryParseFunctionName in jitdiff
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

4 years agoRemove dead docs
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

4 years agoDon't throw NRE when len == 0 in Buffer.Memmove (mono/mono#18004)
Egor Bogatov [Tue, 3 Dec 2019 14:21:41 +0000 (17:21 +0300)]
Don't throw NRE when len == 0 in Buffer.Memmove (mono/mono#18004)

Commit migrated from https://github.com/mono/mono/commit/8150a38dae6fbf60a8a5ffc20a1d07b911fbc31b

4 years agoBump version to 6.11 (mono/mono#17990)
Jo Shields [Mon, 2 Dec 2019 20:58:38 +0000 (15:58 -0500)]
Bump version to 6.11 (mono/mono#17990)

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

4 years agoRemove handles/MonoError from Mono.RuntimeClassHandle. (mono/mono#17805)
Jay Krell [Mon, 2 Dec 2019 18:18:03 +0000 (10:18 -0800)]
Remove handles/MonoError from Mono.RuntimeClassHandle. (mono/mono#17805)

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

4 years ago[profiler] disable inlining when coverage profiler is used and fix allocation sizes...
Bernhard Urban-Forster [Mon, 2 Dec 2019 18:04:13 +0000 (19:04 +0100)]
[profiler] disable inlining when coverage profiler is used and fix allocation sizes (mono/mono#17986)

* [profiler] let compiler decide about the size of an entry

* [profiler] disable inlining when coverage profiler is used

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

4 years ago[sgen] Don't trigger collections during allocation of thread objects (mono/mono#17970)
Vlad Brezae [Mon, 2 Dec 2019 17:54:21 +0000 (19:54 +0200)]
[sgen] Don't trigger collections during allocation of thread objects (mono/mono#17970)

Allocation of thread objects usese the mono_object_new_mature API. These objects are allocated before the thread is finished attaching to the runtime. This means that a collection can happen on an unattached thread as well as all its callbacks, which is a counter-intuitive behavior.

On android this is problematic because at the end of the SGen collection we need to call the java collection, which needs to have the thread attached. This could probably be fixed instead from the Xamarin.Android side, but this approach seems simpler and saner.

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

Commit migrated from https://github.com/mono/mono/commit/640ffa7a62a861b048fb311c0bdcb0a500336ad2

4 years agoRemove handles/MonoError from Mono.Security.Cryptography.KeyPairPersistence icalls...
Jay Krell [Mon, 2 Dec 2019 17:51:16 +0000 (09:51 -0800)]
Remove handles/MonoError from Mono.Security.Cryptography.KeyPairPersistence icalls. (mono/mono#17967)

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

4 years ago[DIM] Fix behavior when there is an override of a method in a generic interface....
Thays Grazia [Mon, 2 Dec 2019 16:20:00 +0000 (13:20 -0300)]
[DIM] Fix behavior when there is an override of a method in a generic interface.  (mono/mono#17963)

* Fix behavior when there is an override of a method in a generic interface.
Fixes mono/mono#17869

Commit migrated from https://github.com/mono/mono/commit/3834be3d2242312a6284f89ed77b60ff8b2327ab

4 years agoRefactor Monitor to eliminate near identical duplicated code. (mono/mono#17964)
Jay Krell [Mon, 2 Dec 2019 16:06:11 +0000 (08:06 -0800)]
Refactor Monitor to eliminate near identical duplicated code. (mono/mono#17964)

The only difference in the copies, was that one had an infinite timeout
so implied TRUE result unless interrupted.

Where the other copy had a timeout and could return FALSE as a result.

They both used the same underlying, with timeout, so it wasn't really an optimization,
just duplicated code.

Also there is subtelty around having a return value or an out parameter.
That is carefully preserved.

Also, coop is fixed, by creating a frame only in a slow path.
Presumably creating a thread is quick and stateless enough such that this
is not too late.

Commit migrated from https://github.com/mono/mono/commit/7356aedc77020cca65af4948dda3859cdb72b6e6

4 years ago[wasm] Add beginnings of SIMD support in AOT mode. (mono/mono#17971)
Zoltan Varga [Mon, 2 Dec 2019 06:21:17 +0000 (07:21 +0100)]
[wasm] Add beginnings of SIMD support in AOT mode. (mono/mono#17971)

* [jit] Implement beginnings of SIMD support for WASM.

* [wasm] Add a DISABLE_WASM_NO_NETCORE Make.local conditional to disable non-netcore builds during development.

* [wasm] Add a --simd argument to the packager.

* Remove some duplicate defines.

* Fix an windows assertion.

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

4 years agoenable only for netcore
EgorBo [Tue, 26 Nov 2019 19:26:45 +0000 (22:26 +0300)]
enable only for netcore

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

4 years agofix failing tests
EgorBo [Mon, 25 Nov 2019 17:50:24 +0000 (20:50 +0300)]
fix failing tests

Commit migrated from https://github.com/mono/mono/commit/376d3acb292ca878cb2bde8993b5ba4ddaaecc14

4 years agofix build
EgorBo [Fri, 22 Nov 2019 22:32:03 +0000 (01:32 +0300)]
fix build

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

4 years agoAddress feedback and fix C++ warnings
EgorBo [Fri, 22 Nov 2019 21:49:49 +0000 (00:49 +0300)]
Address feedback and fix C++ warnings

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

4 years agoOptimize box(X) == null to false
EgorBo [Fri, 22 Nov 2019 21:26:12 +0000 (00:26 +0300)]
Optimize box(X) == null to false

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

4 years agosockets: Remove piecemeal ifndef ENABLE_NETCORE since the file has it broadly.
Jay Krell [Sun, 1 Dec 2019 10:23:52 +0000 (02:23 -0800)]
sockets: Remove piecemeal ifndef ENABLE_NETCORE since the file has it broadly.

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

4 years ago[interp] track valuetype stack for CEE_RET too (mono/mono#17968)
Bernhard Urban-Forster [Fri, 29 Nov 2019 23:06:06 +0000 (00:06 +0100)]
[interp] track valuetype stack for CEE_RET too (mono/mono#17968)

[interp] track valuetype stack for CEE_RET too

Usually the stack depth is determined via basic block predecessors, but  that only works for forward branches.

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

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

4 years ago[wasm] Add more netcore test suites. (mono/mono#17965)
Zoltan Varga [Fri, 29 Nov 2019 17:17:40 +0000 (18:17 +0100)]
[wasm] Add more netcore test suites. (mono/mono#17965)

* [wasm] Handle more exceptions in the xunit runner.

* [wasm] Add more corefx test suites.

* Add more icall signatures.

* Add support for running the System.Compression test suites.

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

4 years agoInterpreter fixes. (mono/mono#17966)
Zoltan Varga [Fri, 29 Nov 2019 15:26:05 +0000 (16:26 +0100)]
Interpreter fixes. (mono/mono#17966)

Interpreter fixes.

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

4 years ago[netcore] Improve Jitdiff tool (mono/mono#17960)
Egor Bogatov [Fri, 29 Nov 2019 10:54:01 +0000 (13:54 +0300)]
[netcore] Improve Jitdiff tool (mono/mono#17960)

use `objdump` arguments to reduce verbosity (no raw bytes, etc) and make the dasm more diff-friendly.
On Linux all functions have a random prefix (address) - replace it with `0xD1FFAB1E` constant). On macOS it's fine by default.

Also, allow to generate diffs for a single assembly via `dump-asm-lib` rule.

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

4 years agoRevert "Use range metadata (mono/mono#17956)" (mono/mono#17958)
Zoltan Varga [Thu, 28 Nov 2019 20:52:01 +0000 (21:52 +0100)]
Revert "Use range metadata (mono/mono#17956)" (mono/mono#17958)

This reverts commit mono/mono@fde058518d4741f2db2aca3e01f0513fd151961f.

Commit migrated from https://github.com/mono/mono/commit/59a9af6d7ce3ff7785e9038e3902fc77291475b8

4 years agoUse range metadata (mono/mono#17956)
Egor Bogatov [Thu, 28 Nov 2019 13:26:35 +0000 (16:26 +0300)]
Use range metadata (mono/mono#17956)

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

4 years ago[interp] Make calli non recursive as well. (mono/mono#17953)
Zoltan Varga [Thu, 28 Nov 2019 05:26:36 +0000 (06:26 +0100)]
[interp] Make calli non recursive as well. (mono/mono#17953)

Commit migrated from https://github.com/mono/mono/commit/79db9b2a8776c5a19ab79b713726577c3d8bea16

4 years agoAdd quick diff
EgorBo [Wed, 27 Nov 2019 15:29:25 +0000 (18:29 +0300)]
Add quick diff

Commit migrated from https://github.com/mono/mono/commit/6360ccbfe31ebacdfb9e65ab05f8758513bb19be

4 years agoAdd jit-diff tools
EgorBo [Wed, 27 Nov 2019 14:45:20 +0000 (17:45 +0300)]
Add jit-diff tools

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

4 years agoChange signature, add cast
Ryan Lucia [Mon, 25 Nov 2019 19:01:16 +0000 (14:01 -0500)]
Change signature, add cast

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

4 years ago[mini] Move bundled native library loading into the runtime
Ryan Lucia [Mon, 25 Nov 2019 16:55:39 +0000 (11:55 -0500)]
[mini] Move bundled native library loading into the runtime

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

4 years ago[cxx] MonoJitICallId same between C and C++.
Jay Krell [Fri, 25 Oct 2019 02:51:33 +0000 (19:51 -0700)]
[cxx] MonoJitICallId same between C and C++.
This is optional.
The real problem was -enable-cxx not actually compiling some files as C++.
This is still reasonable, to ward off the danger of that occuring again.

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

4 years agoUpdate netcore.
Jay Krell [Sat, 23 Nov 2019 10:11:46 +0000 (02:11 -0800)]
Update netcore.

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

4 years agoRemove handles/MonoError from Mono.RuntimeMarshal and Mono.SafeStringMarshal.
Jay Krell [Fri, 15 Nov 2019 05:47:47 +0000 (21:47 -0800)]
Remove handles/MonoError from Mono.RuntimeMarshal and Mono.SafeStringMarshal.

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

4 years ago[threadpool] Decrement max_working when worker times out (mono/mono#17927)
Aleksey Kliger (λgeek) [Wed, 27 Nov 2019 21:06:17 +0000 (16:06 -0500)]
[threadpool] Decrement max_working when worker times out (mono/mono#17927)

[threadpool] Decrement max_working when worker times out

The corresponding code in CoreCLR:
https://github.com/dotnet/runtime/blob/mono/mono@bf88f146412d1e2d41779422337184a802f186c9/src/coreclr/src/vm/win32threadpool.cpp#L2156-L2164

The issue is that counter._.max_working is only ever changed by:
1. the monitor_thread when it detects starvation (increment by 1).
2. the hill climbing algorithm (increment or decrement).

Creating a periodic load of creating many workers at once followed by a minute
or more of quiescence increases the variable worker.counters._.max_working in
monitor_thread(). Once that counter matches worker.limit_worker_max,
monitor_thread() keeps looping without unparking or creating a thread, even
though the actual number of threads/workers is small. If the existing threads
are all waiting on work that needs a new thread, then a deadlock occurs.

With this change, when a parked worker times out, it will lower max_working to
the number of active (working + parked + starting) threads minus itself (but no
less than limit_worker_min). As a result, monitor_thread will only increment
max_working as long as none of the already running workers are timing out.

Attempt to address https://github.com/mono/mono/issues/17833

---

Also allow monitor_thread to start workers if there aren't enough active, even if the max worker limit has been reached.

Work around a pathological condition where the work_item_count is non-zero, and
the max_working limit has been reached, but the number of active threads is
still below the max.  In that case, unpark some workers and start some new
threads.

May address http://work.azdo.io/827206

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

4 years agoCleanup initialize_object_slots, remove unused GetHashCode (ghc) handling. (mono...
Jay Krell [Wed, 27 Nov 2019 19:25:14 +0000 (11:25 -0800)]
Cleanup initialize_object_slots, remove unused GetHashCode (ghc) handling. (mono/mono#17834)

Fix possible race conditions involving multiple writes to globals, by
removing one of the two globals involved in finalize.

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

4 years ago[sdks] Add netcore option for iOS SDK
Alexander Köplinger [Mon, 25 Nov 2019 17:12:47 +0000 (18:12 +0100)]
[sdks] Add netcore option for iOS SDK

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

4 years ago[merp] Use timeline (and generate timeline breadcrumbs) for SendExceptionToTelemetry...
Alexis Christoforides [Wed, 27 Nov 2019 16:56:12 +0000 (11:56 -0500)]
[merp] Use timeline (and generate timeline breadcrumbs) for SendExceptionToTelemetry() (mono/mono#17913)

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

Commit migrated from https://github.com/mono/mono/commit/167913524fd5029a4762d0b497a84739d7227fb3

4 years ago[arm] if mtriple is provided, do not set -march (mono/mono#17937)
Bernhard Urban-Forster [Wed, 27 Nov 2019 16:36:03 +0000 (17:36 +0100)]
[arm] if mtriple is provided, do not set -march (mono/mono#17937)

[arm] if mtriple is provided, do not set -march

E.g. when passing `-march=arm -mtriple=armv7s-ios`, `-march` will win and thus ignore `armv7s`.

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

* Caused by mono/mono@5e318afd2e1d5f9ef0fd692abbceadcf615389a5
* Related with mono/mono@4cd506823079bc15c9ee72da4f94a653f237a5e5
* Almost fixed by mono/mono@e431093f73360b5726e5256fd0de3108ec21b38a

Hopefully we are done with it.

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

4 years ago[amd64] do not stack allocate on the application stack for the transtion from alstack...
Bernhard Urban-Forster [Wed, 27 Nov 2019 11:20:47 +0000 (12:20 +0100)]
[amd64] do not stack allocate on the application stack for the transtion from alstack handling (mono/mono#17922)

### Backstory
This test is failing in the interpreter (ONLY on Debian9/amd64. Not Ubuntu/amd64. Not macOS/amd64):
https://github.com/mono/mono/blob/mono/mono@0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mcs/class/Mono.Debugger.Soft/Test/dtest.cs#L2484-L2499
Where the debuggee is just some unsafe code that tries to read from unmapped memory, thus causing a segfault.

So the test expects the runtime to send a CRASH event via the managed debugger interface. This happens very late in the crash handling machinery:
https://github.com/mono/mono/blob/mono/mono@0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mono/mini/mini-posix.c#L1105

However, the runtime would never reach that, because it silently crashes when calling `backtrace`:
https://github.com/mono/mono/blob/mono/mono@0fed03ed63ed4ea742c4511d8edc3bc1c6f4044f/mono/mini/mini-posix.c#L939

At the point where the SIGSEGV happens, the native stack trace looks like this:
```
Thread 1 "mono-sgen" received signal SIGSEGV, Segmentation fault.
interp_exec_method_full (frame=0x555555c51f18, context=0x555555c38350, clause_args=clause_args@entry=0x0, error=0x555555c53f18, error@entry=0x7fffffffd8b0) at interp/interp.c:4463
4463                            sp[-1].data.i = *(gint32*)sp[-1].data.p;
(gdb) bt
%0  interp_exec_method_full (frame=0x555555c51f18, context=0x555555c38350, clause_args=clause_args@entry=0x0, error=0x555555c53f18, error@entry=0x7fffffffd8b0) at interp/interp.c:4463
%1  0x000055555569237a in interp_runtime_invoke (method=<optimized out>, obj=<optimized out>, params=<optimized out>, exc=0x0, error=0x7fffffffd8b0) at interp/interp.c:1900
%2  0x0000555555590745 in mono_jit_runtime_invoke (method=0x555555bfdc38, obj=<optimized out>, params=0x7fffffffd858, exc=0x0, error=0x7fffffffd8b0) at mini-runtime.c:3001
%3  0x0000555555778c4c in do_runtime_invoke (method=0x555555bfdc38, obj=<optimized out>, params=<optimized out>, exc=<optimized out>, error=0x7fffffffd8b0) at object.c:3052
%4  0x000055555577b7d0 in do_exec_main_checked (method=0x555555bfdc38, args=<optimized out>, error=0x7fffffffd8b0) at object.c:5184
%5  0x000055555559a2aa in mono_jit_exec_internal (argv=0x7fffffffdcb8, argc=1, assembly=0x0, domain=0x555555bf9d40) at driver.c:1320
%6  mono_jit_exec (domain=domain@entry=0x555555bf9d40, assembly=assembly@entry=0x555555c66ae0, argc=argc@entry=1, argv=argv@entry=0x7fffffffdcb8) at driver.c:1265
%7  0x000055555559b8e2 in main_thread_handler (user_data=<synthetic pointer>) at driver.c:1402
%8  mono_main (argc=<optimized out>, argv=<optimized out>) at driver.c:2622
%9  0x000055555558b757 in mono_main_with_options (argv=<optimized out>, argc=<optimized out>) at main.c:52
%10 main (argc=<optimized out>, argv=<optimized out>) at main.c:434
```
Stepping into the crash handling machinery, the picture looks a bit different:
```
Thread 1 "mono-sgen" hit Breakpoint 1, altstack_handle_and_restore (ctx=0x7fffffffd2d0, obj=0x0, flags=0) at exceptions-amd64.c:871
871     {
(gdb) bt
%0  altstack_handle_and_restore (ctx=0x7fffffffd2d0, obj=0x0, flags=0) at exceptions-amd64.c:871
%1  0x00005555556957de in interp_exec_method_full (frame=0x555555c53f08, context=0x555555c38350, clause_args=0x0, error=0x555555c53f18) at interp/interp.c:4461
%2  0x0000000000000000 in ?? ()
```
So it looks like we messed up in the transition from altstack back to the program stack.

 ### The fix

The problem is that `backtrace` consults the unwind information emitted at the point where SIGSEGV happens in `interp_exec_method_full ()`. However at that given program code, there is no function call that allocates space to pass arguments on the stack. Still, we massage the stack to do that in the signal handler, which does not add up with the emitted unwind information by the C compiler.

Note that without the fix, crashing in `backtrace` is the worst case. In other cases we might (1) get still a correct stack trace, or (2) we get a wrong stack trace, and `backtrace` will not crash. So this PR might improve the crash experience overall.

This also reverts commit mono/mono@cff400f3fae9775ac734f8a691339e59a272872c.

Commit migrated from https://github.com/mono/mono/commit/690af29ad904c2005f3d9387d7f875571fcf0fcd

4 years ago[interp] Non-recursive interpreter (mono/mono#16461)
Zoltan Varga [Tue, 26 Nov 2019 03:31:32 +0000 (04:31 +0100)]
[interp] Non-recursive interpreter (mono/mono#16461)

* Aling alloca_size to 8.

* Prevent some false pinning in the monitor-resurrection.cs test when using the non-recursive interpreter.

* [runtime] Add a mono_compiler_barrier () function.

* Add a MONO_GET_SP opcode to pass to enter/exit_gc_safe_region, ldloca might not return a native stack address with the interpreter.

* Add an interpreter/gc callback to mark the interpreter stack.

* Copy only an integer in ENDFILTER.

* Add a native_stack_addr field to InterpFrame so the EH code has something to compare against native stack addresses.

* Add a FrameStack structure to allow allocation of InterpFrame structures and stack data outside the native stack.

* Allocate InterpFrames/stack data from a frame stack instead of the native stack.

* Make some calls non-recursive.

* Remove an assert.

* Use non-recursive calls in CALLVIRT_FAST as well.

* Fix stack size allocation for vararg calls.

* Add some micro optimizations to the calling code.

* Add more micro optimizations.

* [dtest] disable Crash test on interpreter

* Add some implicit conversions to STSFLD to fix a corefx test failure.

* Disable the new test.

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

4 years agoWASM + Netcore. (mono/mono#17915)
Zoltan Varga [Tue, 26 Nov 2019 01:59:31 +0000 (02:59 +0100)]
WASM + Netcore. (mono/mono#17915)

* [runtime] Throw an exception from Thread::StartInternal () if threads are disabled.

* Add more test suites and a corefx exclusions file.

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

4 years agoRemove mkinstalldirs invocation from two places (mono/mono#17910)
Alexander Köplinger [Mon, 25 Nov 2019 20:10:26 +0000 (21:10 +0100)]
Remove mkinstalldirs invocation from two places (mono/mono#17910)

These can be easily replaced so we don't need to mirror over the mkinstalldirs file to the new repo

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

4 years ago[configure.ac] Don't run compiler server check in netcore mode (mono/mono#17911)
Alexander Köplinger [Mon, 25 Nov 2019 20:10:08 +0000 (21:10 +0100)]
[configure.ac] Don't run compiler server check in netcore mode (mono/mono#17911)

We don't need it there.

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

4 years agoFix boehm on Windows i386 builds (mono/mono#17901)
Alexander Köplinger [Mon, 25 Nov 2019 17:58:42 +0000 (18:58 +0100)]
Fix boehm on Windows i386 builds (mono/mono#17901)

After https://github.com/mono/mono/pull/16832 was merged the run-msbuild.bat
script has an additional required parameter for specifying the GC.

However the script only passed the MONO_TARGET_GC property to msbuild
if the script had no additional parameters which doesn't make sense.

Always pass the parameter, this should fix the boehm build on Windows i386.

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

4 years ago[WIP] Make debugger agent startup faster (mono/mono#17898)
Marek Habersack [Mon, 25 Nov 2019 16:52:58 +0000 (16:52 +0000)]
[WIP] Make debugger agent startup faster (mono/mono#17898)

Mono SDB's debugger agent takes a `host:port` parameter to specify the host and
port on which to listen for debugger connection. `host` is passed, via
`mono_get_address_info`, to the `getaddrinfo(3)` standard library call which
does the job of translating the name to the IP address. However, there's no
special treatment for situations when `host` is already an IP address. In this
case `getaddrinfo` takes a lot of time to perform at least two DNS lookups (if
there's just a single DNS server configured) which will time out as the IP
address in `host` will not be resolved by any of the servers.

`getaddrinfo` takes a "hints" parameter where caller can specify some
information about the `host:port` pair to make the lookup faster/easier.
However, Mono doesn't specify the address family in the `hints` parameter, thus
forcing the slow path of DNS lookups on `getaddrinfo`.

This commit adds a new hint named `MONO_HINT_NUMERIC_HOST` (which maps to
`AI_NUMERICHOST` for `getaddrinfo`) which will allow, if set, `getaddrinfo` to
take a faster route in address discovery. Debugger agent will, in most cases,
get an IP address to instead of host name so we call `mono_get_address_info` up
to 3 times (IPv4, IPv6 and unspecified) in order to make the lookup faster.

Commit migrated from https://github.com/mono/mono/commit/10795da1c065c5349bf78ca4d39cfc7992fe5f7c

4 years ago[interp] Resolve tokens also from wrappers during optimization (mono/mono#17880)
Vlad Brezae [Mon, 25 Nov 2019 13:45:56 +0000 (15:45 +0200)]
[interp] Resolve tokens also from wrappers during optimization (mono/mono#17880)

[interp] Resolve tokens also from wrappers during optimization

Remove some duplicated code.

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

4 years ago[eglib] In AIX/generic POSIX, handle null addresses better (mono/mono#17892)
Calvin Buckley [Mon, 25 Nov 2019 07:52:54 +0000 (03:52 -0400)]
[eglib] In AIX/generic POSIX, handle null addresses better (mono/mono#17892)

Fixes crash in tests on AIX.

Matches mono/mono@b0d966bd7ab887f075f6ce3d1c9858af6b52f30f

Commit migrated from https://github.com/mono/mono/commit/004fd06b967e0d2fd0e28bc516e8e33fe8a75a21

4 years agoAllow runtime to be built with C++ on AIX (mono/mono#17672)
Calvin Buckley [Sun, 24 Nov 2019 22:08:19 +0000 (18:08 -0400)]
Allow runtime to be built with C++ on AIX (mono/mono#17672)

* Allow runtime to be built with C++ on AIX

Many AIX/PPC/BE specific codepaths didn't do casting properly,
since C++ is much stricter than C about pointer typing.

Also specify the C99 format macros early as possible, since
inttypes may get included before eglib gets a chance to set the
macros.

Also explicitly use -pthread, since not using it is the cause of
many libstdc++ crashes on AIX.

* Oops, should have been that define instead

* Suggested changes from Jay on style

* Remove unneeded cast

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

4 years agoFix warnings in runtime build (mono/mono#17887)
Alexander Köplinger [Sat, 23 Nov 2019 23:16:20 +0000 (00:16 +0100)]
Fix warnings in runtime build (mono/mono#17887)

This makes at least the netcore-mono build in dotnet/runtime warning-free.

Commit migrated from https://github.com/mono/mono/commit/280e9d2423549d86686716f0818bcdbac9702ea1

4 years ago[netcore] Disable libmonoruntime-support.la build on netcore (mono/mono#17885)
Alexander Köplinger [Sat, 23 Nov 2019 09:06:40 +0000 (10:06 +0100)]
[netcore] Disable libmonoruntime-support.la build on netcore (mono/mono#17885)

It's used for the zlib compression helpers used by System.IO.Compression in the old Mono BCL.
On corefx this is handled differently so we don't need it there.

To avoid automake complaining about missing files we include the .c files directly instead of in the Makefile.

Commit migrated from https://github.com/mono/mono/commit/165e28ae97cc3bcac2f36484c74e8cd7c39ee9f1

4 years ago[netcore] Disable a test which fails on the interpreter
Alexander Köplinger [Fri, 22 Nov 2019 22:00:28 +0000 (23:00 +0100)]
[netcore] Disable a test which fails on the interpreter

The test is wrong, will be fixed upstream.

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

4 years agoMake configure.ac and Makefile.am work without certain directories (mono/mono#17871)
Alexander Köplinger [Fri, 22 Nov 2019 21:48:11 +0000 (22:48 +0100)]
Make configure.ac and Makefile.am work without certain directories (mono/mono#17871)

Those folders won't be present in the dotnet/runtime repository.

We need to factor out AC_OUTPUT into a separate file so we can continue
to share configure.ac but not the list of files in AC_OUTPUT since
autotools doesn't support variables there.

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

4 years ago[runtime] Treat calling a non-virtual method through an open delegate the same as...
Zoltan Varga [Fri, 22 Nov 2019 19:34:14 +0000 (20:34 +0100)]
[runtime] Treat calling a non-virtual method through an open delegate the same as the normal case instead of the OPEN_VIRTUAL case. (mono/mono#17832)

* [runtime] Treat calling a non-virtual method through an open delegate the same as the normal case instead of the OPEN_VIRTUAL case.

* [amd64] Fix the return value mapping in gsharedvt calls, the return address might be in different registers in the caller and callee.

* [runtime] Always initialize del->method_ptr even if interp_method is set, JITted code makes calls through it in mixed mode.

* Add a test for open delegates and gsharedvt.

* Increase nrgctx trampoline count, its needed by dynamic-method-churn.exe in full-aot-interp mode.

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

4 years agoReplace embedded libgc with Unity fork of recent Boehm (bdwgc) (mono/mono#16832)
Jonathan Chambers [Fri, 22 Nov 2019 17:03:23 +0000 (17:03 +0000)]
Replace embedded libgc with Unity fork of recent Boehm (bdwgc) (mono/mono#16832)

* Initial commit to migrate libgc to bdwgc.

* Fix submodule url

* Don't force Boehm as runtime wrapper. Was just for testing locally.

* Build bdwgc as single object file. Helps with performance.

* Bump bdwgc submodule.

* Attempt to fix windows MSVC based build.

* Remove any references to GC_INSIDE_DLL as we manually managed threads on Windows.

* Allow building boehm on Windows amd64.

* Allow building boehm with msvc.

* Bump bdwgc to fix line endings

* Use LF for sh, am, m4, and ac files in bdwgc

* Bump bdwgc & libatomic_ops with fix for cygwin

* Bump bdwgc to fix mono-boehm being generated as libtool wrapper script.

* Link the static boehm library.

* Revert "Link the static boehm library."

This reverts commit mono/mono@1f90d81d08308a61c890743cd79d8f6bb791bc99.

* Use --export-all-symbols on cygwin/mingw to fix issues with boehm causing mono symbols not to be exported.

* Fix

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

4 years agoFix InternalGetHashCode for boehm/null GC (mono/mono#17859)
Filip Navara [Fri, 22 Nov 2019 12:51:43 +0000 (13:51 +0100)]
Fix InternalGetHashCode for boehm/null GC (mono/mono#17859)

It was unintentionally shifting the address to left instead of right. It should be shift right to get rid of zeroes from the alignment.

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

4 years agoFix automake warning
Alexander Köplinger [Fri, 22 Nov 2019 12:18:10 +0000 (13:18 +0100)]
Fix automake warning

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

4 years ago[wasm] Add aot+netcore support. (mono/mono#17798)
Zoltan Varga [Fri, 22 Nov 2019 11:42:55 +0000 (12:42 +0100)]
[wasm] Add aot+netcore support. (mono/mono#17798)

* [wasm] Compile corelib as 32 bit.

* [wasm] Add a netcore cross compiler.

* [wasm] Add netcore+aot support.

* [aot] Load the dedup module lazily instead of at startup.

The previous version didn't work on netcore because it couldn't resolve references to corlib etc.
since they were not yet registered in the root domain at the time of loading.

* Add more icall trampoline signatures.

* Add more netcore pinvokes.

* Fix the build.

* Add more icall trampoline signatures.

* Add an --embed-file option to the packager.

* Add more netcore pinvokes.

* [interp] Return FALSE for IsDynamicCodeCompiled.

* Add a netcore project and targets for running BenchmarkDotNet.

* Fix pinvoke tables.

* Add missing files.

* Fix make clean.

* Add a comment.

* Revert "Fix pinvoke tables."

This reverts commit mono/mono@998065e77614b7e621d2873510aabc3930669ca9.

* Make xunit-runner into a dotnet project. Add a netcore version.

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

4 years ago[netcore] Run tests with Interpreter (mono/mono#17862)
Egor Bogatov [Fri, 22 Nov 2019 08:14:23 +0000 (11:14 +0300)]
[netcore] Run tests with Interpreter (mono/mono#17862)

* Run tests with interp and llvm

* fix build

* Run tests with llvm

* Add a few tests to rsp for LLVM

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

4 years agoRemove handles/MonoError from Mono.RuntimeGPtrArrayHandle. (mono/mono#17806)
Jay Krell [Thu, 21 Nov 2019 19:15:29 +0000 (11:15 -0800)]
Remove handles/MonoError from Mono.RuntimeGPtrArrayHandle. (mono/mono#17806)

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

4 years agoStop referencing files from Mono BCL in Netcore System.Private.CoreLib (mono/mono...
Jo Shields [Thu, 21 Nov 2019 18:48:00 +0000 (19:48 +0100)]
Stop referencing files from Mono BCL in Netcore System.Private.CoreLib (mono/mono#17866)

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

4 years ago[interp] fix array_element_size intrinsic (mono/mono#17857)
Bernhard Urban-Forster [Thu, 21 Nov 2019 10:56:03 +0000 (11:56 +0100)]
[interp] fix array_element_size intrinsic (mono/mono#17857)

[interp] fix array_element_size intrinsic

`mono_class_array_element_size` gives us the size of the provided MonoClass if it would be an array element. But here we want the element size of a given array's MonoClass. That's what `mono_array_element_size` is returning.

This leads to all kind of weird crashes otherwise, specifically here:
https://github.com/mono/mono/blob/mono/mono@2c20649539ac16e069a65f2a750c793eb341e50f/netcore/System.Private.CoreLib/src/System/Array.Mono.cs#L64

Which is then used later to compute the size to memset in order to clear the content of an array. If it's larger than it should be, then this will cause memory corruption. For example this would crash eventually:

```csharp
using System;
using System.Collections.Generic;

namespace HelloWorld {
    class Program {
        static void Main(string[] args) {
            for (int j = 0; j < 0x1000; j++) {
                var d = new Dictionary<string, string> ();
                for (int i = 0; i < 197; i++)
                    d.Add (i + "", i + "foo");
                d.Clear ();
            }
        }
    }
}
```

Thanks to @EgorBo for reporting.

Commit migrated from https://github.com/mono/mono/commit/058d157648f593f41a2afbf878c0f401ecb804b7

4 years ago[metadata] Remove native threadpool from netcore build (mono/mono#17856)
Alexander Köplinger [Thu, 21 Nov 2019 09:01:39 +0000 (10:01 +0100)]
[metadata] Remove native threadpool from netcore build (mono/mono#17856)

We use the managed threadpool there.

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

4 years ago[llvm] Recognize GEP (mono/mono#17844)
Egor Bogatov [Wed, 20 Nov 2019 20:25:24 +0000 (23:25 +0300)]
[llvm] Recognize GEP (mono/mono#17844)

* initial impl

* improve jit

* fix copy-paste

* disable for non-netcore

* clean up

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

4 years ago[interp] Move the freeing of interp method info into a callback. (mono/mono#17852)
Zoltan Varga [Wed, 20 Nov 2019 18:56:09 +0000 (19:56 +0100)]
[interp] Move the freeing of interp method info into a callback. (mono/mono#17852)

[interp] Move the freeing of interp method info into a callback.

Commit migrated from https://github.com/mono/mono/commit/4961d411e7f6a425c4b7fad86b72f02947f9c817

4 years agoenable gss on android (mono/mono#17838)
Egor Bogatov [Wed, 20 Nov 2019 15:53:14 +0000 (18:53 +0300)]
enable gss on android (mono/mono#17838)

Commit migrated from https://github.com/mono/mono/commit/27e6e812f14163d1cb6555803148947043065386

4 years ago[debugger-agent] Fix CMD_VM_ALL_THREADS returning wrong value due to unitialized...
Alexander Köplinger [Wed, 20 Nov 2019 07:28:58 +0000 (08:28 +0100)]
[debugger-agent] Fix CMD_VM_ALL_THREADS returning wrong value due to unitialized variable (mono/mono#17847)

`remove_gc_finalizing` wasn't initialized so its value is undefined.
The `count_thread_check_gc_finalizer()` function only sets it in some cases so we could end up with the variable having an undefined (and probably not 0) value.
This resulted in the returned thread count from the debuggee being wrong because we'd decrement `count` even though we shouldn't.

Regression from https://github.com/mono/mono/pull/15618

Commit migrated from https://github.com/mono/mono/commit/0396037d31dacac06358faf30eb05d8e00b8b231

4 years ago[master] Update dependencies from dotnet/arcade dotnet/core-setup dotnet/corefx ...
dotnet-maestro[bot] [Tue, 19 Nov 2019 15:47:57 +0000 (16:47 +0100)]
[master] Update dependencies from dotnet/arcade dotnet/core-setup dotnet/corefx (mono/mono#17690)

* Update dependencies from https://github.com/dotnet/arcade build 20191102.1

- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19552.1
- Microsoft.DotNet.Helix.Sdk - 5.0.0-beta.19552.1

* Update dependencies from https://github.com/dotnet/core-setup build 20191104.1

- Microsoft.NETCore.App - 5.0.0-alpha.1.19554.1

* Update dependencies from https://github.com/dotnet/corefx build 20191103.8

- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19553.8

* Update dependencies from https://github.com/dotnet/arcade build 20191108.11

- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19558.11
- Microsoft.DotNet.Helix.Sdk - 5.0.0-beta.19558.11

* Update dependencies from https://github.com/dotnet/core-setup build 20191109.5

- Microsoft.NETCore.App - 5.0.0-alpha.1.19559.5

* Update dependencies from https://github.com/dotnet/corefx build 20191109.6

- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19559.6

* Update dependencies from https://github.com/dotnet/arcade build 20191117.2

- Microsoft.DotNet.Arcade.Sdk - 5.0.0-beta.19567.2
- Microsoft.DotNet.Helix.Sdk - 5.0.0-beta.19567.2

* Update dependencies from https://github.com/dotnet/core-setup build 20191114.1

- Microsoft.NETCore.App - 5.0.0-alpha.1.19564.1

* Update dependencies from https://github.com/dotnet/corefx build 20191113.6

- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha.1.19563.6

* Use NETCoreApp version 5.0.0-alpha.1.19563.3

Later versions have an issue and the new dotnet/runtime assets aren't ready yet.

* Disable failing tests

* Fix merge error

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

4 years ago[interp] Add some missing netcore intrinsics. (mono/mono#17782)
Zoltan Varga [Mon, 18 Nov 2019 12:55:15 +0000 (13:55 +0100)]
[interp] Add some missing netcore intrinsics. (mono/mono#17782)

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

4 years agoBump corefx to pick up https://github.com/mono/corefx/pull/370 (mono/mono#17758)
Steve Pfister [Mon, 18 Nov 2019 11:13:16 +0000 (06:13 -0500)]
Bump corefx to pick up https://github.com/mono/corefx/pull/370 (mono/mono#17758)

Backport of https://github.com/dotnet/corefx/pull/34560

Added HAVE_LCHFLAGS & HAVE_STAT_FLAGS to configure.

Commit migrated from https://github.com/mono/mono/commit/0269f7b479f245c13b30c1b44cc91cc224c48b93

4 years ago[llvm] Add support for LLVM JIT on ARM64 (mono/mono#17827)
Filip Navara [Sun, 17 Nov 2019 23:24:11 +0000 (00:24 +0100)]
[llvm] Add support for LLVM JIT on ARM64 (mono/mono#17827)

* [llvm] Add support for LLVM JIT on ARM64

* Fix tabs

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