Bernhard Urban [Thu, 9 May 2019 15:31:24 +0000 (17:31 +0200)]
[metadata] use handle stack in mono_runtime_object_init_handle (mono/mono#14399)
Fixes this crash on watchOS with llvmonly:
```
(lldb) bt 35
* thread %1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x4d55545c)
* frame %0: 0x01ab81de mscorlibtests`sgen_vtable_get_descriptor(vtable=0x4d555458) at sgen-client-mono.h:29:33
frame %1: 0x01a9e278 mscorlibtests`major_copy_or_mark_object_canonical at sgen-marksweep-drain-gray-stack.h:158:10
frame %2: 0x01a9debc mscorlibtests`major_copy_or_mark_object_canonical(ptr=0x182f260c, queue=0x01dd4894) at sgen-marksweep.c:1363
frame %3: 0x019d31f2 mscorlibtests`mono_handle_stack_scan(stack=0x17e200b0, func=(mscorlibtests`major_copy_or_mark_object_canonical + 1 at sgen-marksweep.c:1362), gc_data=0x01dd4894, precise=1, check=1) at handle.c:340:5
frame %4: 0x01a45680 mscorlibtests`sgen_client_scan_thread_data(start_nursery=0x00000000, end_nursery=0xffffffff, precise=1, ctx=ScanCopyContext @ 0x01dd4580) at sgen-mono.c:2254:5
frame %5: 0x01a93e80 mscorlibtests`job_scan_thread_data(worker_data_untyped=0x00000000, job=0x0511c004) at sgen-gc.c:1416:2
frame %6: 0x01adef0a mscorlibtests`sgen_workers_enqueue_job(generation=1, job=0x0511c004, enqueue=0) at sgen-workers.c:184:3
frame %7: 0x01a9334a mscorlibtests`enqueue_scan_from_roots_jobs(gc_thread_gray_queue=0x01dd4894, heap_start=0x00000000, heap_end="", ops=0x01c6aaac, enqueue=0) at sgen-gc.c:1661:2
frame %8: 0x01a94d16 mscorlibtests`major_copy_or_mark_from_roots(gc_thread_gray_queue=0x01dd4894, old_next_pin_slot=0x01dd4864, mode=COPY_OR_MARK_FROM_ROOTS_SERIAL, object_ops_nopar=0x01c6aaac, object_ops_par=0x00000000) at sgen-gc.c:2070:2
frame %9: 0x01a95658 mscorlibtests`major_start_collection(gc_thread_gray_queue=0x01dd4894, reason="LOS overflow", concurrent=0, old_next_pin_slot=0x01dd4864) at sgen-gc.c:2189:2
frame %10: 0x01a92ccc mscorlibtests`major_do_collection(reason="LOS overflow", is_overflow=0, forced=1) at sgen-gc.c:2362:2
frame %11: 0x01a8e9ce mscorlibtests`sgen_perform_collection_inner(requested_size=21616, generation_to_collect=1, reason="LOS overflow", forced_serial=1, stw=1) at sgen-gc.c:2563:14
frame %12: 0x01a8e76c mscorlibtests`sgen_perform_collection(requested_size=21616, generation_to_collect=1, reason="LOS overflow", forced_serial=1, stw=1) at sgen-gc.c:2640:2
frame %13: 0x01a8e73e mscorlibtests`sgen_ensure_free_space(size=21616, generation=1) at sgen-gc.c:2514:2
frame %14: 0x01a99184 mscorlibtests`sgen_los_alloc_large_inner(vtable=0x185749d0, size=21616) at sgen-los.c:380:2
frame %15: 0x01a81c0a mscorlibtests`sgen_alloc_obj_nolock(vtable=0x185749d0, size=21616) at sgen-alloc.c:172:16
frame %16: 0x01a44940 mscorlibtests`mono_gc_alloc_vector(vtable=0x185749d0, size=21616, max_length=900) at sgen-mono.c:1317:20
frame %17: 0x00a5b408 mscorlibtests`aot_wrapper_icall_mono_gc_alloc_vector + 102
frame %18: 0x00a56818 mscorlibtests`mscorlib_wrapper_alloc_object_AllocVector_intptr_intptr + 324
frame %19: 0x01092b26 mscorlibtests`mscorlibtests1_MonoTests_System_DecimalTest2__ctor + 7286
frame %20: 0x00a78912 mscorlibtests`aot_wrapper_gsharedvt_out_sig_pinvoke_void_this_ + 28
frame %21: 0x00a4a4d2 mscorlibtests`mscorlib_wrapper_runtime_invoke_object_runtime_invoke_sig_void_intptr_intptr_object_intptr_intptr_intptr + 312
```
The hint here was that the crash happened in `mono_handle_stack_scan ()` and inspecting the handle stack there. After enabling `MONO_HANDLE_TRACK_OWNER` and `MONO_HANDLE_TRACK_SP` in `handle.h`, I got this:
```
warning: Handle 0x17886a0c (object = 0x16e73fd0) (allocated from "../../../../../mono/metadata/object.c:3182") is leaking.
frame %1: 0x019833ba mscorlibtests`mono_handle_new(obj=0x01f194a0, info=0x17882600, owner="../../../../../mono/metadata/gc.c:1337") at handle.c:183:2
frame %2: 0x019823c0 mscorlibtests`mono_gc_alloc_handle_string(vtable=0x17888760, size=24, len=5) at gc.c:1337:9
frame %3: 0x019de896 mscorlibtests`mono_string_new_size_handle(domain=0x16e73fd0, len=5, error=0x01dc804c) at object.c:6643:6
frame %4: 0x019d6fc4 mscorlibtests`mono_string_new_size_checked(domain=0x16e73fd0, length=5, error=0x01dc804c) at object.c:6655:2
frame %5: 0x019de64e mscorlibtests`mono_string_new_utf16_checked(domain=0x16e73fd0, text=0x1842ab10, len=5, error=0x01dc804c) at object.c:6536:6
frame %6: 0x019debc2 mscorlibtests`mono_string_new_checked(domain=0x16e73fd0, text="ar-SA", error=0x01dc804c) at object.c:6778:7
frame %7: 0x019b06a8 mscorlibtests`construct_culture(this_obj=0x01f19428, ci=0x01b2d878, error=0x01dc804c) at locales.c:357:2
frame %8: 0x019b0e3a mscorlibtests`ves_icall_System_Globalization_CultureInfo_internal_get_cultures(neutral='\0', specific='\x01', installed='\0') at locales.c:714:9
frame %9: 0x007061f0 mscorlibtests`aot_wrapper___System_dot_Globalization_System_dot_Globalization_dot_CultureInfo__internal_get_cultures_pinvoke_cl2a_System_2eGlobalization_2eCultureInfo_5b_5d__cl4_bool_cl4_bool_cl4_bool_cl2a_System_2eGlobalization_2eCultureInfo_5b_5d__cl4_bool_cl4_bool_cl4_bool_ + 100
frame %10: 0x00704fb2 mscorlibtests`mscorlib_System_Globalization_CultureInfo_GetCultures_System_Globalization_CultureTypes + 192
frame %11: 0x0100f422 mscorlibtests`mscorlibtests1_MonoTests_System_DateTimeTest_Parse_Bug53023b + 192
frame %12: 0x00a28702 mscorlibtests`aot_wrapper_gsharedvt_out_sig_pinvoke_void_this_ + 28
frame %13: 0x009fa2c2 mscorlibtests`mscorlib_wrapper_runtime_invoke_object_runtime_invoke_sig_void_intptr_intptr_object_intptr_intptr_intptr + 312
frame %14: 0x019278f2 mscorlibtests`mono_llvmonly_runtime_invoke(method=0x17953820, info=0x1842a9a0, obj=0x053b7c40, params=0x00000000, exc=0x01dc8550, error=0x01dc88a4) at mini-runtime.c:3000:2
```
@lambdageek suggested this fix after showing this trace to him. As far as I understand we do _not_ know the root cause yet. The handle leak happens in this trace:
```
(lldb) mbt
* thread %1
* frame %0: 0x0176192c mscorlibtests`do_debug_me_please_kkthx at object.c:128:2
frame %1: 0x01761a62 mscorlibtests`mono_runtime_object_init_handle(this_obj=MonoObjectHandle @ 0x01b53fbc, error=0x01b5404c) at object.c:146:3
frame %2: 0x0176191e mscorlibtests`mono_runtime_object_init_checked(this_obj_raw=0x01fde880, error=0x01b5404c) at object.c:176:2
frame %3: 0x0173ce32 mscorlibtests`ves_icall_System_Globalization_CultureInfo_internal_get_cultures(neutral='\0', specific='\x01', installed='\0') at locales.c:712:4
frame %4: 0x004931d8 mscorlibtests`aot_wrapper___System_dot_Globalization_System_dot_Globalization_dot_CultureInfo__internal_get_cultures_pinvoke_cl2a_System_2eGlobalization_2eCultureInfo_5b_5d__cl4_bool_cl4_bool_cl4_bool_cl2a_System_2eGlobalization_2eCultureInfo_5b_5d__cl4_bool_cl4_bool_cl4_bool_ + 100
frame %5: 0x00491f9a mscorlibtests`mscorlib_System_Globalization_CultureInfo_GetCultures_System_Globalization_CultureTypes + 192
frame %6: 0x00d9b8f4 mscorlibtests`mscorlibtests1_MonoTests_System_DateTimeTest_Parse_Bug53023b + 192
frame %7: 0x007b56ea mscorlibtests`aot_wrapper_gsharedvt_out_sig_pinvoke_void_this_ + 28
```
`mono_runtime_object_init_checked ()` already should take care of the handle stack 😕
Commit migrated from https://github.com/mono/mono/commit/
a093cbddbab1fc9dd6b1fde89e623ad8384e6392
Jay Krell [Thu, 9 May 2019 14:13:21 +0000 (07:13 -0700)]
Usually do not create a handle in mono_runtime_invoke_handle. (mono/mono#14404)
Use mono_runtime_invoke_handle_void instead.
Commit migrated from https://github.com/mono/mono/commit/
2524d5613be83c6b6e3f4c1800b5a0f4eb2450aa
Egor Bogatov [Thu, 9 May 2019 12:36:44 +0000 (15:36 +0300)]
[netcore] Set of workarounds for ArrayTests (mono/mono#14369)
* Fix ushort to char conversion
* fix one more test
* Enable more Array tests
* fix comment
* Fix CreateInstance_NotSupportedType_ThrowsNotSupportedException
* Address feedback
* Update ArraySortHelper.cs
* fix compilation error?
* bump corefx-tests, fix one more array.copy issue
Commit migrated from https://github.com/mono/mono/commit/
b4e565f21b5dda3ecd3513986eb2eb15d184559b
Jay Krell [Thu, 9 May 2019 08:03:55 +0000 (01:03 -0700)]
Mechanize strings in marshal.c register_icall and cleanup a little. (mono/mono#14357)
The less mechical parts:
- spell out monoeg_g_free
- register_dyn_icall not used, remove
- register_icall_no_wrapper only used once, spell it out instead
This is nice cosmetically on its own and will help remove JIT icall hashing.
Commit migrated from https://github.com/mono/mono/commit/
c7697e06438ebb66d74e2ec20dd90d08773b2f4b
Jay Krell [Thu, 9 May 2019 06:06:52 +0000 (23:06 -0700)]
Introduce enum and static data for JIT icalls, that are currently hashed (mono/mono#14359)
* Introduce enum and static data for JIT icalls, that are currently hashed
by string and address and use dynamic allocation.
These will be used shortly.
* PR: Move MONO_JIT_ICALLS content from class-internals.h to jit-icall-reg.h.
Not clear what is the best name but moving along.
Commit migrated from https://github.com/mono/mono/commit/
997190c12c5826364874208a57b0e0334a02b59d
Ryan Lucia [Wed, 8 May 2019 21:36:11 +0000 (14:36 -0700)]
[gitignore] Add crash dump files, .dylib.dSYM directories, and test-path (mono/mono#14408)
[gitignore] Add crash dump files, .dylib.dSYM directories, and test-path
Wasn't sure where in the file to best put the .dylib.dSYM stuff, so suggestions are welcome
Commit migrated from https://github.com/mono/mono/commit/
2894e57ed72387a17db9f9ee01f56c320d82a819
Larry Ewing [Wed, 8 May 2019 16:44:03 +0000 (11:44 -0500)]
Merge pull request mono/mono#14203 from kjpou1/wasm-sdk-lower-version
[wasm][sdk] Fix warning NU1604, does not contain an inclusive lower b…
Commit migrated from https://github.com/mono/mono/commit/
0dd432096be8585865a9b12fbe1616c0ae30ab13
Bernhard Urban [Wed, 8 May 2019 13:40:00 +0000 (15:40 +0200)]
[llvmonly] make local copy of trace_ips pointer from exception object (mono/mono#14400)
Fixes a race in llvmonly (watchOS):
```
Process 397 stopped
* thread %10, name = 'tid_8e2f', stop reason = EXC_BAD_ACCESS (code=1, address=0x28)
frame %0: 0x0177f690 mscorlibtests`mono_llvm_load_exception at mini-exceptions.c:3886:23
3883 size_t upper = mono_array_length_internal (mono_ex->trace_ips);
3884
3885 for (int i = 0; i < upper; i += TRACE_IP_ENTRY_SIZE) {
-> 3886 gpointer curr_ip = mono_array_get_internal (mono_ex->trace_ips, gpointer, i);
3887 for (int j = 0; j < TRACE_IP_ENTRY_SIZE; ++j) {
3888 gpointer p = mono_array_get_internal (mono_ex->trace_ips, gpointer, i + j);
3889 trace_ips = g_list_append (trace_ips, p);
Target 0: (mscorlibtests) stopped.
(lldb) mbt
* thread %10
* frame %0: 0x0177f690 mscorlibtests`mono_llvm_load_exception at mini-exceptions.c:3886:23
frame %1: 0x00e23b7a mscorlibtests`mscorlibtests1_MonoTests_System_LazyTest__c__DisplayClass16_0__ConcurrentInitializationb__1 + 254
frame %2: 0x0087af98 mscorlibtests`mscorlib_wrapper_delegate_invoke__Module_invoke_void + 610
frame %3: 0x00368856 mscorlibtests`mscorlib_System_Threading_ThreadHelper_ThreadStart_Context_object + 448
[...]
(lldb) p/x mono_ex
(MonoException *) $2 = 0x01d9e968
(lldb) p/x mono_ex->trace_ips
(MonoArray *) $3 = 0x00000000
(lldb) thread list
Process 397 stopped
thread %1: tid = 0x38772, 0x018156aa mscorlibtests`jit_info_table_copy_and_split_chunk(table=0x17635a00, chunk=0x17b767f0) at jit-info.c:483:28, name = 'tid_303', queue = 'com.apple.main-thread'
thread %3: tid = 0x387ad, 0x1c4f9764 libsystem_kernel.dylib`__psynch_cvwait + 24, name = 'SGen worker'
thread %4: tid = 0x387b0, 0x1c4f1224 libsystem_kernel.dylib`semaphore_wait_trap + 8, name = 'Finalizer'
thread %5: tid = 0x387b5, 0x1c4fa6cc libsystem_kernel.dylib`__workq_kernreturn + 8
thread %6: tid = 0x387b6, 0x1c4f11d4 libsystem_kernel.dylib`mach_msg_trap + 20, name = 'com.apple.uikit.eventfetch-thread'
* thread %10: tid = 0x389a6, 0x0177f690 mscorlibtests`mono_llvm_load_exception at mini-exceptions.c:3886:23, name = 'tid_8e2f', stop reason = EXC_BAD_ACCESS (code=1, address=0x28)
thread %11: tid = 0x38985, 0x1c4f9764 libsystem_kernel.dylib`__psynch_cvwait + 24, name = 'tid_8113'
thread %12: tid = 0x38986, 0x1c4f123c libsystem_kernel.dylib`semaphore_timedwait_trap + 8, name = 'Thread Pool Worker'
thread %13: tid = 0x38987, 0x1c4f123c libsystem_kernel.dylib`semaphore_timedwait_trap + 8, name = 'Thread Pool Worker'
thread %14: tid = 0x389a3, 0x1c4f123c libsystem_kernel.dylib`semaphore_timedwait_trap + 8, name = 'Thread Pool Worker'
thread %15: tid = 0x389a4, 0x1c4f123c libsystem_kernel.dylib`semaphore_timedwait_trap + 8, name = 'Thread Pool Worker'
thread %16: tid = 0x389a5, 0x1c4f123c libsystem_kernel.dylib`semaphore_timedwait_trap + 8, name = 'Thread Pool Worker'
(lldb) thread select 1
* thread %1, name = 'tid_303', queue = 'com.apple.main-thread'
frame %0: 0x018156aa mscorlibtests`jit_info_table_copy_and_split_chunk(table=0x17635a00, chunk=0x17b767f0) at jit-info.c:483:28
480 jit_info_table_split_chunk (chunk, &new_table->chunks [j], &new_table->chunks [j + 1]);
481 j += 2;
482 } else {
-> 483 new_table->chunks [j] = table->chunks [i];
484 ++new_table->chunks [j]->refcount;
485 ++j;
486 }
(lldb) mbt
* thread %1
* frame %0: 0x018156aa mscorlibtests`jit_info_table_copy_and_split_chunk(table=0x17635a00, chunk=0x17b767f0) at jit-info.c:483:28
frame %1: 0x01815304 mscorlibtests`jit_info_table_chunk_overflow(table=0x17635a00, chunk=0x17b767f0) at jit-info.c:579:10
frame %2: 0x018146ee mscorlibtests`jit_info_table_add(domain=0x16624cc0, table_ptr=0x16624d9c, ji=0x176f4428) at jit-info.c:614:33
frame %3: 0x01814662 mscorlibtests`mono_jit_info_table_add(domain=0x16624cc0, ji=0x176f4428) at jit-info.c:674:2
frame %4: 0x0175f5da mscorlibtests`mono_aot_find_jit_info(domain=0x16624cc0, image=0x16c07200, addr=0x00271ff1) at aot-runtime.c:3710:3
frame %5: 0x0181443e mscorlibtests`mono_jit_info_table_find_internal(domain=0x16624cc0, addr=0x00271ff1, try_aot=1, allow_trampolines=0) at jit-info.c:306:9
frame %6: 0x018145e0 mscorlibtests`mono_jit_info_table_find(domain=0x16624cc0, addr=0x00271ff1) at jit-info.c:335:9
frame %7: 0x01780212 mscorlibtests`build_stack_trace(frame_ctx=0x01c2fb18, state=0x01c2ffb8) at mini-exceptions.c:392:31
frame %8: 0x1c598aa2 libunwind.dylib`_Unwind_Backtrace + 232
frame %9: 0x0177f4fc mscorlibtests`throw_exception(ex=0x01d9e968, rethrow=0) at mini-exceptions.c:3800:3
frame %10: 0x0177f3c8 mscorlibtests`mono_llvm_throw_exception(ex=0x01d9e968) at mini-exceptions.c:3823:2
frame %11: 0x00439ed0 mscorlibtests`mscorlib_System_Runtime_ExceptionServices_ExceptionDispatchInfo_Throw + 116
frame %12: 0x00271ff0 mscorlibtests`mscorlib_System_LazyHelper_ThrowException + 98
frame %13: 0x002730c2 mscorlibtests`mscorlib_System_Lazy_1_T_REF_CreateValue + 194
frame %14: 0x00273390 mscorlibtests`mscorlib_System_Lazy_1_T_REF_get_Value + 128
frame %15: 0x0027307a mscorlibtests`mscorlib_System_Lazy_1_T_REF_CreateValue + 122
frame %16: 0x00273390 mscorlibtests`mscorlib_System_Lazy_1_T_REF_get_Value + 128
frame %17: 0x00e22eb0 mscorlibtests`mscorlibtests1_MonoTests_System_LazyTest_ConcurrentInitialization + 1422
frame %18: 0x008948e2 mscorlibtests`aot_wrapper_gsharedvt_out_sig_pinvoke_void_this_ + 28
frame %19: 0x008664a2 mscorlibtests`mscorlib_wrapper_runtime_invoke_object_runtime_invoke_sig_void_intptr_intptr_object_intptr_intptr_intptr + 312
```
Commit migrated from https://github.com/mono/mono/commit/
19f57ad0b82c73c2d56f98b56a32a07f84a0f6d0
Zoltan Varga [Wed, 8 May 2019 11:20:55 +0000 (07:20 -0400)]
[runtime] Use MAP_JIT automatically when running under a hardened runtime on osx. (mono/mono#14395)
* [runtime] Use MAP_JIT automatically when running under a hardened runtime on osx.
* Fix memory ordering.
Commit migrated from https://github.com/mono/mono/commit/
f879e35e3ed7496d819bd766deb8be6992d068ed
Jay Krell [Wed, 8 May 2019 07:46:32 +0000 (00:46 -0700)]
Mechanize strings in mini-runtime.c register_jit_icall. (mono/mono#14374)
* Mechanism strings to register_dyn_icall in mini-runtime.c.
That is both, generate them kinda, and make them available for some later manipulation.
* Mechanize strings for JIT icall registration in mini-runtime.c.
Generate them slightly and make them amenable to crude preprocessor transforms later.
* Try to improve github diff presentation.
Commit migrated from https://github.com/mono/mono/commit/
8928ed6fd89d03c26d3428cf390c1f5384e8686f
Zoltan Varga [Wed, 8 May 2019 03:16:20 +0000 (23:16 -0400)]
[interp] Add tracing support. Return values are not yet supported. (mono/mono#14389)
Commit migrated from https://github.com/mono/mono/commit/
5ccb9854b8d73552d5cca531bd75494095032826
Jo Shields [Tue, 7 May 2019 19:52:35 +0000 (15:52 -0400)]
Don't apply MONO_ATTR_FORMAT_PRINTF to mono_error_set_argument (mono/mono#14385)
The constructor for mono_error_set_argument lacks a `const char *msg_format`
so clearly we shouldn't be applying formatting from an entirely
unrelated parameter.
This was flagged by `-Werror=format-security`
Commit migrated from https://github.com/mono/mono/commit/
1ecbff9e934c8ffc27446d684b4b053e4eaad54d
Jo Shields [Tue, 7 May 2019 19:32:30 +0000 (15:32 -0400)]
Remapping should affect GAC search paths considered by the loader (mono/mono#14384)
Closes: mono/mono#14366
Fixes Mac package failures during IronRuby compilation
Commit migrated from https://github.com/mono/mono/commit/
80f99fc37d49e9efc415eff87435e966dbae196d
Larry Ewing [Tue, 7 May 2019 16:05:50 +0000 (11:05 -0500)]
Merge pull request mono/mono#14370 from lewing/mixed-sample
[wasm] Add a mixed target for sample
Commit migrated from https://github.com/mono/mono/commit/
b0ec83c4d0ceba3c5fd5f692c656339af6addcaf
Johan Lorensson [Tue, 7 May 2019 11:57:05 +0000 (13:57 +0200)]
Merge pull request mono/mono#14375 from lateralusX/lateralusX/fix-mutex-leak-on-gc
Mutex memory leak on sgen GC (nursery, major).
Commit migrated from https://github.com/mono/mono/commit/
5bcf1663754ccfe1434aa848e04c0114583a50d3
Bernhard Urban [Tue, 7 May 2019 09:24:55 +0000 (11:24 +0200)]
[arm] fix armv7k regression on struct passing (mono/mono#14362)
We can't use `slotsize=8` on `armv7k` as it leads to stack corruption.
Note that `mtouch` already calls the AOT compiler with `--aot=mtriple=arm64_32-ios`, so no changes are required there.
Regression introduced by https://github.com/mono/mono/pull/12992
Fixes https://github.com/mono/mono/issues/13454
Commit migrated from https://github.com/mono/mono/commit/
8913a1a73e85c60a7d896832d0dac4cfea979e6a
lateralusX [Tue, 7 May 2019 08:02:10 +0000 (10:02 +0200)]
Mutex memory leak on sgen GC (nursery, major).
During GC we allocate a gray queue protected by a mutex, sgen_gray_object_queue_init.
This mutex is never destroyed when clearing up the object containing it,
sgen_gray_object_queue_dispose, so it will leak. Overtime this could cause
OOM on some systems depending on how memory related to system primitives are
handled and partitioned.
Commit migrated from https://github.com/mono/mono/commit/
c5d014397a675fc34e2c69d3505a3a35560bdab9
Jay Krell [Mon, 6 May 2019 23:31:03 +0000 (16:31 -0700)]
Mechanize strings in cominterop register_jit_icall. (mono/mono#14356)
This reduces the current source code and will be useful in eliminating JIT icall hashing.
Commit migrated from https://github.com/mono/mono/commit/
b3ecd1710998baf1397db05e265fb659f81b8726
Jay Krell [Mon, 6 May 2019 23:29:43 +0000 (16:29 -0700)]
Mechanize strings in remoting.c register_icall. (mono/mono#14360)
This will help remove/reduce JIT icall hashing, as the
name will also be a field name or token paste to an enum value.
Commit migrated from https://github.com/mono/mono/commit/
072ff8fcfb75eefb3744f8b88f1965db3b275960
Thays Grazia [Mon, 6 May 2019 22:24:02 +0000 (19:24 -0300)]
A deadlock happens when during a process_suspend there is a pending invoke and then when it's calling the invoke there is another call to process_suspend in the same thread. (mono/mono#14368)
Commit migrated from https://github.com/mono/mono/commit/
1294e4d0e5597d1174bddb19258b6cf47c905e19
Jay Krell [Mon, 6 May 2019 21:49:29 +0000 (14:49 -0700)]
Make mono_fmod extern "C and not static, to simplify later (mono/mono#14355)
* Make mono_fmod extern "C and not static, to simplify later
removal of JIT icall hashing. Making it more consistent with other icalls.
Costing maybe one instruction in some slow paths.
* Move mono_fmod from mini-runtime.c to jit-icalls.c.
* Fix declaratoin of mono_fmod.
Commit migrated from https://github.com/mono/mono/commit/
a41be288719e56df153158faba0ad3c27af2e896
pedestrianlove [Mon, 6 May 2019 06:00:16 +0000 (14:00 +0800)]
Remove special casing (mono/mono#14155)
* match the parameter
* Removed special handling.
Removed special handling of TypedReference and RuntimeArgumentHandle
* Remove the whole special casing block
* Revert part of last commit
Restored the check for IsByRefLikeAttribute
* Corrected the function name
Commit migrated from https://github.com/mono/mono/commit/
f60a397ab5714751482d2823ad5eeee1fb03fa43
Larry Ewing [Sun, 5 May 2019 21:39:52 +0000 (16:39 -0500)]
Merge pull request mono/mono#14259 from jeromelaban/dev/jela/wasm-dlopen
[Wasm] Add support for P/Invoke through dynamic linking
Commit migrated from https://github.com/mono/mono/commit/
8d80ccc897c678d7bdae645ca8629b0c5cc0b667
Larry Ewing [Sat, 4 May 2019 05:55:38 +0000 (00:55 -0500)]
Merge pull request mono/mono#14331 from BrzVlad/feature-interp-ldsflda-opt
[interp] Optimize ldsflda opcode
Commit migrated from https://github.com/mono/mono/commit/
b2a9049de4835386f7ad4831986a0f8481536736
Egor Bogatov [Sat, 4 May 2019 04:36:03 +0000 (07:36 +0300)]
[netcore] Fix CreateInstance_PublicOnlyValueTypeWithPrivateDefaultConstructor_T… (mono/mono#14321)
* Fix CreateInstance_PublicOnlyValueTypeWithPrivateDefaultConstructor_ThrowsMissingMethodException
* Update excludes-System.Runtime.Tests.rsp
* Update RuntimeType.cs
Commit migrated from https://github.com/mono/mono/commit/
534c6883b1fd155113867f9b684863dffae98e04
Larry Ewing [Sat, 4 May 2019 03:56:13 +0000 (22:56 -0500)]
Merge pull request mono/mono#14340 from lewing/wasm-link-descriptor
[wasm] Add --link-descriptor arg to packager
Commit migrated from https://github.com/mono/mono/commit/
887887a7fe3fb302cea267db760fed9dfb46209a
Jérôme Laban [Sat, 4 May 2019 00:42:10 +0000 (20:42 -0400)]
Regenerate m2n trampolines
Commit migrated from https://github.com/mono/mono/commit/
ff4839d99e57a4bd53e92e005245c483ccfaeda0
Jérôme Laban [Wed, 1 May 2019 18:55:54 +0000 (14:55 -0400)]
Adjust indentation
Commit migrated from https://github.com/mono/mono/commit/
40981f0cfdfff290ae5000498724e252053339da
Jérôme Laban [Wed, 1 May 2019 15:41:51 +0000 (11:41 -0400)]
Add vifffff and viffffff trampolines
Commit migrated from https://github.com/mono/mono/commit/
21743bd58da762558e04752882b2760d0b6c30e9
Jérôme Laban [Wed, 1 May 2019 02:20:51 +0000 (22:20 -0400)]
Make wasm dlopen use only for release-dynamic configuration
Commit migrated from https://github.com/mono/mono/commit/
ee6603916d280a67b9fa4412180e54c6e1b6c8ed
Jérôme Laban [Mon, 29 Apr 2019 20:04:03 +0000 (16:04 -0400)]
Make libmono_icall_table_la_LIBADD and libmono_ilgen_la_LIBADD conditional to wasm.
Commit migrated from https://github.com/mono/mono/commit/
b5b860f8d707589f0f0b1ff255fad08f98d5c9c0
Jérôme Laban [Mon, 29 Apr 2019 20:03:29 +0000 (16:03 -0400)]
Fix indentation, spacing.
Commit migrated from https://github.com/mono/mono/commit/
8bddfdb2d2ad1def23ae760cba595bcffd1205e4
Jérôme Laban [Mon, 29 Apr 2019 20:03:11 +0000 (16:03 -0400)]
Generate m2n after update
Commit migrated from https://github.com/mono/mono/commit/
f8371d811444ec9c52eafb73bd522e5168ada15a
Jérôme Laban [Mon, 29 Apr 2019 14:45:48 +0000 (10:45 -0400)]
Fix indentation
Commit migrated from https://github.com/mono/mono/commit/
935bc21276cd3389caeae2b5ac175bef4a3b0eed
Jérôme Laban [Mon, 29 Apr 2019 13:35:08 +0000 (09:35 -0400)]
Add more driver cookies
Commit migrated from https://github.com/mono/mono/commit/
ecd8c210e08d6d2ac5e127a329cac5eeb9f62dc3
Jérôme Laban [Mon, 29 Apr 2019 12:29:32 +0000 (08:29 -0400)]
mono emscripten double loading issue
Commit migrated from https://github.com/mono/mono/commit/
51abc92b6e42e65149835602b0d643a29ac5b4b1
Jérôme Laban [Sun, 28 Apr 2019 01:22:40 +0000 (21:22 -0400)]
Workaround for second dlopen failure returns non-null
Commit migrated from https://github.com/mono/mono/commit/
a1cda3879331d05bd06b1c53da8bcb18fc775157
Jérôme Laban [Sat, 27 Apr 2019 12:18:21 +0000 (08:18 -0400)]
Add missing include
Commit migrated from https://github.com/mono/mono/commit/
195e7f0b0506582d91db20752651638d42db0150
Jérôme Laban [Sat, 27 Apr 2019 03:31:17 +0000 (23:31 -0400)]
Add minimal dl support
Commit migrated from https://github.com/mono/mono/commit/
b50d35f620718b20fe21689f65fb1e7997d2116d
Jérôme Laban [Fri, 26 Apr 2019 17:45:16 +0000 (13:45 -0400)]
Enable dynamic linking support for mono
Commit migrated from https://github.com/mono/mono/commit/
96e4e2f532aeb327875751e4f8d80a4e9c126d74
Larry Ewing [Fri, 3 May 2019 22:56:32 +0000 (17:56 -0500)]
Merge pull request mono/mono#14309 from lewing/icall-branch
[wasm] generate icall_trampoline_dispatch as nested branches
Commit migrated from https://github.com/mono/mono/commit/
4cc2c190c02fdec25930d6bc8dae0104b5ef06c5
Larry Ewing [Fri, 3 May 2019 21:12:56 +0000 (16:12 -0500)]
Merge pull request mono/mono#14306 from radical/bump_msbuild_master
[msbuild] Bump to pick up test fixes
Commit migrated from https://github.com/mono/mono/commit/
ea912ff155ee8eee3d21d312f369c36ed113f76d
Jo Shields [Fri, 3 May 2019 18:41:44 +0000 (14:41 -0400)]
[netcore] Unique Asset Manifest filenames per branch
Commit migrated from https://github.com/mono/mono/commit/
cae77959908f13a828cc9fd9a50c76e8291b7271
Larry Ewing [Thu, 2 May 2019 05:17:34 +0000 (00:17 -0500)]
Order the groupings preferentially by length to reduce the worst case
Commit migrated from https://github.com/mono/mono/commit/
1d86f1a7923dff7421ad82d0ab4216c72521b5f2
Vlad Brezae [Fri, 3 May 2019 10:45:58 +0000 (13:45 +0300)]
[interp] Optimize ldsflda opcode
2-4x speedup
Commit migrated from https://github.com/mono/mono/commit/
ccdc79fd9ec0aa2bfcfdf3c7f335b0801aa68df4
Jay Krell [Fri, 3 May 2019 06:29:57 +0000 (23:29 -0700)]
ld -Bsymboli so dynamic linker does not get betweem mono and itself. (mono/mono#14298)
Commit migrated from https://github.com/mono/mono/commit/
d37cd2c2fc2495f9251ee5c2c22432a83d556c7f
Zoltan Varga [Fri, 3 May 2019 02:44:08 +0000 (22:44 -0400)]
[runtime] Fix the signature of the AppDomain:DoUnhandledException () icall. (mono/mono#14322)
Commit migrated from https://github.com/mono/mono/commit/
15f9b329c0deceec725f0263246c792f1299745d
Bernhard Urban [Thu, 2 May 2019 17:48:41 +0000 (19:48 +0200)]
[arm] amend stack pointer properly in exception trampoline (mono/mono#14310)
The previous attempt ( https://github.com/mono/mono/pull/14078 ) only fixed it for ABIs where the stack pointer alignment is 8 bytes. ABIs, such as watchOS, require 16 byte alignment.
Commit migrated from https://github.com/mono/mono/commit/
1cbd5cbacf12114f6a9e26231733bad959e45050
Alexander Kyte [Thu, 2 May 2019 16:24:35 +0000 (12:24 -0400)]
[llvm] Widen vector equality (OP_PCMPEQx) (mono/mono#14292)
* [llvm] Widen vector equality (OP_PCMPEQx)
Fixes https://github.com/mono/mono/issues/14261
Fixes https://github.com/mono/mono/issues/14143
This was causing an issue when trying to inline
System.Numerics.Vectors.Vector`1<byte>:Equals into System.Span.IndexOf
from System.Memory.dll as provided by nuget. I believe that it is
comparing the result of a SIMD operation on two SIMD registers there with a
SIMD register full of zero bytes.
When we produce the Equals call (no inline), we spill the SIMD <4 x i32>
vector to the stack in the caller, and we then later load it
with the widened type used here <16 x i8>.
When we inline, we end up making the args into XMOV opcodes,
and then doing the "pcmpeqb" mini opcode with the return values
from those operations. This becomes a register to register no-op
copy, and the original <4 x i32> gets compared against the <16 x i8>
type:
```
%116 = icmp eq <16 x i8> zeroinitializer, <4 x i32> %115
```
This does not go the way we want it to. It reliably leads to IndexOf
breaking and only finding the desired byte in the portion not processed
by the SIMD code (in the last few elements of the array).
This fix checks if the input dimensions differ, and does a conversion.
This produces the following IR:
```
%114 = bitcast <4 x i32> %99 to <16 x i8>
%115 = icmp eq <16 x i8> %114, %113
%116 = sext <16 x i1> %115 to <16 x i8>
%117 = icmp eq <16 x i8> zeroinitializer, %116
```
* [llvm] Widen vector greater-than
Here we do the same trick used in the above fix, but for the parallel greater-than operation.
Commit migrated from https://github.com/mono/mono/commit/
b15631d641e1c296b58ae744226c9076ca81b0ab
Jay Krell [Thu, 2 May 2019 14:25:58 +0000 (07:25 -0700)]
Move three trivial threadpool icalls to callers. (mono/mono#14296)
ves_icall_System_Threading_ThreadPool_PostQueuedCompletionStatus
ves_icall_System_Threading_ThreadPool_BindIOCompletionCallbackNative
ves_icall_System_Threading_ThreadPool_IsThreadPoolHosted
Commit migrated from https://github.com/mono/mono/commit/
d371432a1030db86d1ed6afb9bc174fb1587191f
Jo Shields [Thu, 2 May 2019 14:24:10 +0000 (10:24 -0400)]
[netcore] Onboard Arcade (mono/mono#14301)
Commit migrated from https://github.com/mono/mono/commit/
748da2e4a93e820540f857ee8c6d3f752141f4de
Egor Bogatov [Thu, 2 May 2019 12:00:40 +0000 (15:00 +0300)]
[netcore] clean up excludes-System.Runtime.Tests.rsp (mono/mono#14294)
* update System.Runtime.Tests.rsp
* Update System.Private.CoreLib.csproj
* Update excludes-System.Runtime.Tests.rsp
* Invoke AppContext.OnProcessExit from runtime
* remove Utf16/Utf8 tests
* Implement LoadFromPath
* make NativeLibrary os specific
* Add missing LoadWithPartialName
* Update Assembly.cs
* Update Assembly.cs
* Update NativeLibrary.Unix.cs
Commit migrated from https://github.com/mono/mono/commit/
ea917ba76abcfdc7efaf5d4fc4570d67b7c836b1
Larry Ewing [Thu, 2 May 2019 06:46:36 +0000 (01:46 -0500)]
Merge pull request mono/mono#14295 from vargaz/mixed-eh-5
[runtime] Fix some mixed EH problems.
Commit migrated from https://github.com/mono/mono/commit/
2e97d6edd7e57127acc1582a75714ccadc1cfee3
Larry Ewing [Thu, 2 May 2019 03:31:40 +0000 (22:31 -0500)]
Try out a branching trampoline dispatch
Commit migrated from https://github.com/mono/mono/commit/
f557414b6164f9428ffbef1d8b42754ef89aae0b
Zoltan Varga [Wed, 1 May 2019 06:00:56 +0000 (02:00 -0400)]
[runtime] Fix some mixed EH problems.
Commit migrated from https://github.com/mono/mono/commit/
781d20bab4902bfad0ac29b9fb82c28812d7edc1
Zoltan Varga [Wed, 1 May 2019 00:47:27 +0000 (20:47 -0400)]
[aot] Avoid passing -march=arm to llc when using thumb, it forces arm32 code generation. (mono/mono#14288)
Fixes https://github.com/mono/mono/issues/14247.
Commit migrated from https://github.com/mono/mono/commit/
e431093f73360b5726e5256fd0de3108ec21b38a
lateralusX [Mon, 29 Apr 2019 08:17:45 +0000 (10:17 +0200)]
Add minimal COM support into WinAOT BCL profile and Windows Mono runtime.
Technologies like SharpDX uses a minimal set of COM support from runtime
and System.Runtime.InteropServices.Marshal:
AddRef
Release
QueryInterface
All these are low level wrappers around methods in IUknown interface and
doesn't need any of the additional runtime COM support enabled to work.
Technologies like CoreRT includes these methods in their full AOT
profile, meaning that SharpDX can run on CoreRT on Windows platforms. Mono's
WinAOT profile and runtime currently don't, making it impossible to use
SharpDX.
This PR adds the needed methods into WinAOT profile and also make
sure corresponding icalls always gets included on Windows build Mono runtime.
Commit migrated from https://github.com/mono/mono/commit/
81ce33f6b6a2cc70ac3f9dd91073e747b5739611
Larry Ewing [Mon, 29 Apr 2019 22:33:44 +0000 (17:33 -0500)]
Merge pull request mono/mono#14199 from kjpou1/wasm-sdk-cl-args
[wasm][sdk] Add command line quoting and escaping to WasmLinkAssembli…
Commit migrated from https://github.com/mono/mono/commit/
498974d09ac841eb2ad62cb8f528a79490e9492d
Marek Safar [Mon, 29 Apr 2019 17:30:57 +0000 (19:30 +0200)]
Mirror changes from mono/coreclr,corefx,corert (mono/mono#14163)
Mirror changes from mono/coreclr,corefx,corert
Commit migrated from https://github.com/mono/mono/commit/
c6c25db0c2e9ccb60f2da751ea58e711ae874a40
Jay Krell [Sun, 28 Apr 2019 01:57:17 +0000 (18:57 -0700)]
Remove libgcc_s_seh-1.dll dependency when targeting Win32 with gcc. (mono/mono#14251)
Don't use popcount intrinsic.
Alternative but not exactly contradictory to https://github.com/mono/mono/pull/14248.
Note that this is a single inlinable instruction on x86,
if you assume at least SSE4 from circa 2007, which I am avoiding here.
Commit migrated from https://github.com/mono/mono/commit/
90a91429ae75240b4d0e791a563a9d553be09d56
Vlad Brezae [Sat, 27 Apr 2019 09:14:16 +0000 (12:14 +0300)]
[interp] Optimize enum Hasflag (mono/mono#14173)
* [interp] Optimize enum.HasFlag for csc pattern
Avoid boxing and slow call. Makes it 100x faster.
* [interp] Optimize enum.HasFlag for mcs pattern
* [interp] Transform ldc.i4 + conv.i8 into ldc.i8
Simplifies code, making enum.HasFlag optimization work for long enums.
Commit migrated from https://github.com/mono/mono/commit/
6d9c4c24d243b850381ff724cef7bd3e2054deb1
Vlad Brezae [Fri, 26 Apr 2019 21:28:12 +0000 (00:28 +0300)]
[interp] Optimize special static field access (mono/mono#14202)
* [interp] Optimize special static field access
3x faster. For value types 10x.
* [interp] Remove duplicated code
* [interp] Further optimize thread static field access
Provides an additional 50% perf gain.
Commit migrated from https://github.com/mono/mono/commit/
a68022ae7e26952e7a5dfe6cbe99b3021b3c98cc
Vlad Brezae [Fri, 26 Apr 2019 15:20:33 +0000 (18:20 +0300)]
[interp] Don't change next_jit_code_hash during imethod transform (mono/mono#14240)
This field is used by the internal hash table to link nodes and it can be changed during hash table insertion of other imethods. Copying this field back was leading to random hangs in hash table lookup.
Commit migrated from https://github.com/mono/mono/commit/
6fb7b496bd3a0bb0fa9e66cf03761eca38c78ff2
Zoltan Varga [Fri, 26 Apr 2019 15:12:24 +0000 (11:12 -0400)]
[runtime] Add a python version of the offsets tool. (mono/mono#14229)
* [runtime] Add a python version of the offsets tool.
This version only depends on python and libclang. It currently only
works on osx.
* [runtime] Add a dummy structure needed by the python version of the offsets tool.
* [offsets-tool-py] Change some argument names for compatibility.
* [wasm] Use the python offsets tool on osx, the c# version is 32 bit, and the 64 bit version doesn't work.
* [wasm] Fix the ordering of mono libraries on the link line.
Commit migrated from https://github.com/mono/mono/commit/
c2e540331d54ee6b875dd01f94e040f3888fca10
Jo Shields [Thu, 25 Apr 2019 20:47:01 +0000 (16:47 -0400)]
[netcore] Avoid touching or using submodules in coreonly mode
Commit migrated from https://github.com/mono/mono/commit/
d44e45c32ec1315f5ab97b2e2ec5104ccad6e868
Jo Shields [Thu, 25 Apr 2019 19:42:56 +0000 (15:42 -0400)]
[netcore] Smarter version numbering of nupkg (mono/mono#14011)
The version number in version.h only shows e.g. "6.3.0", and we
want full version numbers ideally, to match what our Mac pkg files
show. This logic calculates that version number.
Commit migrated from https://github.com/mono/mono/commit/
3521df4cf476ce459cdacd815f64876d8b3e5a94
Jo Shields [Thu, 25 Apr 2019 18:27:46 +0000 (14:27 -0400)]
[netcore] Fix `make dist` following https://github.com/mono/mono/pull/14167 (mono/mono#14233)
Commit migrated from https://github.com/mono/mono/commit/
b1d54d2e428f88ef7d4cef6db50f78dc06024258
Jay Krell [Thu, 25 Apr 2019 17:10:06 +0000 (10:10 -0700)]
Fix arm32 tailcall_reg/tailcall_membase. (mono/mono#14187)
* Revert "[Tailcall] [arm] [jit] Fix moving tailcall parameters. (mono/mono#12701)"
This reverts commit mono/mono@
257efc6374cbffb95d83dc9257b432d6ae3d80f6.
* When moving parameters for tailcall, and having pushed ip,
and adjusting the offset to account for that, split the adjustment
between sp and frame pointer, as frame pointer may or may not be sp.
This fixes https://github.com/mono/mono/issues/11489.
Commit migrated from https://github.com/mono/mono/commit/
8eec35bcdd3aa1b7caa9bfa9bf95c02fd48de8dc
Egor Bogatov [Thu, 25 Apr 2019 16:28:56 +0000 (19:28 +0300)]
[netcore] ASP.NET Core sample (mono/mono#14224)
* ASP.NET Core sample
* update makefile
* update Home page
* Update Makefile
* remove ASPNET_SHAREDRUNTIME
* replace mvc with web sample
Commit migrated from https://github.com/mono/mono/commit/
591d6d0a2139757760aaf169769f4967ee7d70e8
Vlad Brezae [Thu, 25 Apr 2019 07:09:11 +0000 (10:09 +0300)]
[interp] Don't check for exception in native wrappers (mono/mono#14184)
We already do it when we get back to the interpreter.
Commit migrated from https://github.com/mono/mono/commit/
913951b350a89d8e594aaa25506d91fc66abcdad
Johan Lorensson [Thu, 25 Apr 2019 06:53:13 +0000 (02:53 -0400)]
Merge pull request mono/mono#14101 from lateralusX/lateralusX/add-coop-support-windows-msvc
Add hybrid/cooperate suspend runtime support on Windows.
Commit migrated from https://github.com/mono/mono/commit/
45a3eef924a5a4b9012f3e2e802527614292b8c1
Bernhard Urban [Thu, 25 Apr 2019 06:37:01 +0000 (08:37 +0200)]
[interp] fix op_explicit for cast from nfloat to nint and vice versa (mono/mono#14201)
Fixes https://github.com/xamarin/xamarin-macios/issues/5809
Commit migrated from https://github.com/mono/mono/commit/
b6587926147b15ba15cf8e1a52793ccfe8928308
Filip Navara [Wed, 24 Apr 2019 15:24:46 +0000 (17:24 +0200)]
[netcore] Restore Roslyn compilers from NuGet to allow up-to-date version to be used (mono/mono#14157)
* Restore Roslyn compilers from NuGet to allow up-to-date version to be used
* Move the Roslyn version to makefile, ensure that it is updated before building System.Private.CoreLib
* Pass the whole path to Roslyn props file instead of just Roslyn version to dotnet build
* Make the Roslyn restore compatible with .NET Core 2.2 SDK
Commit migrated from https://github.com/mono/mono/commit/
019b4563d3ef09e91b4382091232964d9548d69a
Egor Bogatov [Wed, 24 Apr 2019 15:23:51 +0000 (18:23 +0300)]
[netcore] Don't wrap CustomAttributeNamedArgument into CustomAttributeNamedArgument (mono/mono#14180)
* don't wrap CustomaAttributeNamedArg
* fix BlockCopy failing test
* update NETCORETESTS_VERSION and NETCOREAPP_VERSION
* avoid typedard creation in netcore
* fix merge issue
Commit migrated from https://github.com/mono/mono/commit/
95b873997aaa220362e3da45b4a541ff17e9d9b4
Alexander Kyte [Wed, 24 Apr 2019 14:53:47 +0000 (10:53 -0400)]
[llvm] Propagate nonnull attribute through LLVM IR (mono/mono#13697)
## Summary
This change allows LLVM to identify unnecessary null checks. We mark GOT accesses (including those made by LDSTR) and new object calls as nonnull.
Since LLVM won't propagate this, we propagate from definition to usage, across casts, and from usage to definition (conditionally).
This enables it to remove a significant portion of some benchmarks.
In real-world code, we can expect to see this remove the unnecessary null checks made by private methods.
## Example
### C#:
Note that the constant strings are trivially non-null. This PR spots and propagates that.
```
static void ThrowIfNull(string s)
{
if (s == null)
ThrowArgumentNullException();
}
static void ThrowArgumentNullException()
{
throw new ArgumentNullException();
}
[MethodImpl(MethodImplOptions.NoInlining)]
static int Bench(string a, string b, string c, string d)
{
ThrowIfNull(a);
ThrowIfNull(b);
ThrowIfNull(c);
ThrowIfNull(d);
return a.Length + b.Length + c.Length + d.Length;
}
[Benchmark(Description = nameof(NoThrowInline))]
public int Test() => Bench("a", "bc", "def", "ghij");
```
### Before:
```
define hidden monocc i32 @NoThrowInline_MainClass_Bench_string_string_string_string(i64* %arg_a, i64* %arg_b, i64* %arg_c, i64* %arg_d) mono/mono#6 gc "mono" {
BB0:
br label %INIT_BB1
INIT_BB1: ; preds = %BB0
br label %INITED_BB2
INITED_BB2: ; preds = %INIT_BB1
br label %BB3
BB3: ; preds = %INITED_BB2
br label %BB2
BB2: ; preds = %BB3
notail call monocc void @NoThrowInline_MainClass_ThrowIfNull_string(i64* %arg_a)
notail call monocc void @NoThrowInline_MainClass_ThrowIfNull_string(i64* %arg_b)
notail call monocc void @NoThrowInline_MainClass_ThrowIfNull_string(i64* %arg_c)
notail call monocc void @NoThrowInline_MainClass_ThrowIfNull_string(i64* %arg_d)
%0 = bitcast i64* %arg_a to i32*
%1 = getelementptr i32, i32* %0, i32 4
%t50 = load volatile i32, i32* %1
%2 = bitcast i64* %arg_b to i32*
%3 = getelementptr i32, i32* %2, i32 4
%t52 = load volatile i32, i32* %3
%t53 = add i32 %t50, %t52
%4 = bitcast i64* %arg_c to i32*
%5 = getelementptr i32, i32* %4, i32 4
%t55 = load volatile i32, i32* %5
%t56 = add i32 %t53, %t55
%6 = bitcast i64* %arg_d to i32*
%7 = getelementptr i32, i32* %6, i32 4
%t58 = load volatile i32, i32* %7
%t60 = add i32 %t56, %t58
br label %BB1
BB1: ; preds = %BB2
ret i32 %t60
}
```
### After:
Note: safepoint in below code is added by backend, not part of this change
```
define hidden monocc i32 @NoThrowInline_MainClass_Bench_string_string_string_string(i64* nonnull %arg_a, i64* nonnull %arg_b, i64* nonnull %arg_c, i64* nonnull %arg_d) mono/mono#6 gc "mono" {
BB0:
%0 = getelementptr i64, i64* %arg_a, i64 2
%1 = bitcast i64* %0 to i32*
%t50 = load volatile i32, i32* %1, align 4
%2 = getelementptr i64, i64* %arg_b, i64 2
%3 = bitcast i64* %2 to i32*
%t52 = load volatile i32, i32* %3, align 4
%t53 = add i32 %t52, %t50
%4 = getelementptr i64, i64* %arg_c, i64 2
%5 = bitcast i64* %4 to i32*
%t55 = load volatile i32, i32* %5, align 4
%t56 = add i32 %t53, %t55
%6 = getelementptr i64, i64* %arg_d, i64 2
%7 = bitcast i64* %6 to i32*
%t58 = load volatile i32, i32* %7, align 4
%t60 = add i32 %t56, %t58
%8 = load i64*, i64** getelementptr inbounds ([37 x i64*], [37 x i64*]* @mono_aot_NoThrowInline_llvm_got, i64 0, i64 7), align 8
%9 = load i64, i64* %8, align 4
%10 = icmp eq i64 %9, 0
br i1 %10, label %gc.safepoint_poll.exit, label %gc.safepoint_poll.poll.i
gc.safepoint_poll.poll.i: ; preds = %BB0
%11 = load void ()*, void ()** bitcast (i64** getelementptr inbounds ([37 x i64*], [37 x i64*]* @mono_aot_NoThrowInline_llvm_got, i64 0, i64 25) to void ()**), align 8
call void %11() mono/mono#8
br label %gc.safepoint_poll.exit
gc.safepoint_poll.exit: ; preds = %BB0, %gc.safepoint_poll.poll.i
ret i32 %t60
}
```
## Dependencies
This depends on https://github.com/mono/linker/pull/528.
Commit migrated from https://github.com/mono/mono/commit/
0d9e13f983ffa82e8e2360072dc67a4ee3989324
Larry Ewing [Wed, 24 Apr 2019 13:59:39 +0000 (08:59 -0500)]
Merge pull request mono/mono#14192 from kjpou1/wasm-fix-cl
[wasm][tests] Fix browser test command line arguments.
Commit migrated from https://github.com/mono/mono/commit/
194070823c5136aae08d0987a83232e69f25db10
lateralusX [Wed, 24 Apr 2019 08:16:17 +0000 (10:16 +0200)]
Fix race condition under wow64 for cooperative suspended threads.
Under hybrid suspend a thread can be cooperative suspended but still
checked for a platform critical region under wow64. Since thread is
not preemptive suspended we can't reliably call GetThreadContext and
doing so could also (even correctly) return a context flagged as critical
triggering an assert in stw for cooperative suspended threads.
Commit migrated from https://github.com/mono/mono/commit/
0d390066ca091528bb551f24ec4e7c4177551f09
lateralusX [Thu, 11 Apr 2019 14:08:24 +0000 (16:08 +0200)]
Add hybrid/cooperate runtime support on Windows.
Commit migrated from https://github.com/mono/mono/commit/
f26e30c38a40b12838ed5eb517069d0678cab5b5
Zoltan Varga [Tue, 23 Apr 2019 21:01:24 +0000 (17:01 -0400)]
[netcore] Convert netcore/Makefile.am to a normal makefile, get the configure variables from config.make. (mono/mono#14167)
* [netcore] Convert netcore/Makefile.am to a normal makefile, get the configure variables from config.make.
* [netcore] Convert mcs/class/System.Private.CoreLib/Makefile.am to a normal makefile.
Commit migrated from https://github.com/mono/mono/commit/
fdc2dce3840e4f71adf3cb54de9b77a79fb66813
Zoltan Varga [Tue, 23 Apr 2019 16:05:50 +0000 (12:05 -0400)]
[netcore] Throw the correct exception for byref returns returning null, .net core throws a nullref. (mono/mono#14128)
Commit migrated from https://github.com/mono/mono/commit/
c1c7a739cc5e83690350cf209e4c48e6b1e6cdf0
Bernhard Urban [Tue, 23 Apr 2019 13:53:05 +0000 (15:53 +0200)]
[aot] partial revert of mono/mono#14043 (mono/mono#14135)
We need to emit a real call here. On arm/android we would emit this now:
```asm
ldr pc, =label
.ltorg # place address of `label` here.
```
which is a jump to `label`, not a call.
We need a different solution to make larger assemblies work, but for now
I revert it so the `2019-02` intergration is unblocked.
Partial revert of mono/mono#14043
Commit migrated from https://github.com/mono/mono/commit/
223e0bd78d0531eb7b58edb1286e1c545c65f57a
Thays Grazia [Tue, 23 Apr 2019 12:48:39 +0000 (09:48 -0300)]
[DIM] Throwing AmbiguousImplementationException on call of multiple candidate implementations. (mono/mono#14127)
* Adding AmbiguousImplementationException exception and throwing this when there are multiple candidate implementations.
Commit migrated from https://github.com/mono/mono/commit/
aed21f3e4bcdc2f50640866affe808cc5c1423ed
Filip Navara [Tue, 23 Apr 2019 12:44:39 +0000 (14:44 +0200)]
[netcore] Establish a baseline for make xtestpass (mono/mono#14072)
* Bump CoreFX version, include few more packages
* Add exclusions for System.Collections.NonGeneric.Tests
* Exclude tests that crash runtime
* Add more exclusions for known failures
* Exclude System.Utf8String.Experimental.Tests, it is CoreCLR specific
Exclude System.ComponentModel.Composition.Registration.Tests, the published version throws PNSE for all methods
Please enter the commit message for your changes. Lines starting
* Make a list of known non-passing tests and establish baseline for 'make xtestpass'
* Add exclusions
* Reenable System.Net.NameResolution.Functional.Tests
* Reenable System.Net.Sockets.Tests
* Reenable System.Diagnostics.Tracing.Tests
* Reenable System.Net.Http.Functional.Tests
* Reenable System.Net.HttpListener.Tests
* Reenable System.CodeDom.Tests
* Reenable System.Linq.Expressions.Tests
* Reenable System.Threading.ThreadPool.Tests
* Reenable System.Runtime.Tests
* Reenable System.Collections.Tests
* Reenable System.Threading.ThreadPool.Tests
* Reenable System.Memory.Tests
* Reenable System.Linq.Parallel.Tests
* Update exclusions for System.Diagnostics.Process.Tests
* Reenable System.Dynamic.Runtime.Tests
* Reenable System.Runtime.Numerics.Tests
* Sort excluded tests
* Reenable System.Reflection.Tests
* Reenable System.Reflection.Emit.Tests
* Reenable System.Linq.Parallel.Tests
* Reenable System.Diagnostics.TraceSource.Tests
* Reenable System.Threading.Tests
* Disable tests that trigger UI on macOS
* Update System.Runtime.Tests exclusion list
* Update line numbers
Commit migrated from https://github.com/mono/mono/commit/
921f00352f173c7f20551cc900a6c41fb73770f2
Jay Krell [Tue, 23 Apr 2019 08:57:31 +0000 (01:57 -0700)]
Cleanup patch_info code a little. (mono/mono#14037)
e.g. whenever underlying representation is nul terminated string.
MONO_PATCH_INFO_LDSTR_LIT
MONO_PATCH_INFO_OBJC_SELECTOR_REF
almost the same as
MONO_PATCH_INFO_JIT_ICALL
MONO_PATCH_INFO_JIT_ICALL_ADDR
MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL
MONO_PATCH_INFO_LDSTR_LIT no longer allocate
and copy the string from the AOT image into image_pool.
g_str_equal check pointer equality first.
While obviously correct, not obviously faster,
as it adds cost when strings are unequal.
Uninline g_str_equal, seems cleaner, but perhaps less efficient.
Combine the switch-exit and default: paths,
as only one case other than default exited the switch.
Lift out other common subexpressions.
Commit migrated from https://github.com/mono/mono/commit/
1ffb5fb83f41c77e901617e6c35e8306bad393ec
Zoltan Varga [Tue, 23 Apr 2019 00:56:48 +0000 (20:56 -0400)]
[runtime] Fix a warning. (mono/mono#14168)
Commit migrated from https://github.com/mono/mono/commit/
2477d73d58176c69107a829d04ad2dd2ac73efd2
Zoltan Varga [Tue, 23 Apr 2019 00:56:33 +0000 (20:56 -0400)]
[llvm] Remove unused dlsym_cb. (mono/mono#14164)
Commit migrated from https://github.com/mono/mono/commit/
0a95f46f30512ed9f28bd1468035bc0ca6bfb90f
Zoltan Varga [Mon, 22 Apr 2019 22:03:36 +0000 (18:03 -0400)]
[llvmonly] Enable invariant loads from preinited got slots. (mono/mono#14027)
Commit migrated from https://github.com/mono/mono/commit/
f1d1bd6084771fa039957b7d9193fe4f949b15be
Aleksey Kliger (λgeek) [Mon, 22 Apr 2019 18:43:11 +0000 (14:43 -0400)]
[image] Create MonoImageStorage to own the image raw data (mono/mono#13942)
* [image] Create MonoImageStorage to own the image raw data
Create a new data structure: MonoImageStorage.
It is an object that will have the responsibility for the raw data of a
MonoImage. It has a string key and a refcount that is used to share a
MonoImageStorage between multiple MonoImage objects.
The reason we need this is because the current MonoAssembly/MonoImage design is
broken for multiple domains and (more evidently) it will be broken when we add
AssemblyLoadContext support. The issue is that a MonoImage may be shared
between multiple domains (or ALCs), but it has a 'references' field which
points to a single other MonoAssembly.
This is a problem because the references of an image may be resolved
differently in different domains (or ALCs).
The eventual solution will be to stop sharing MonoImages based on path name (or
in the case of in-memory images based on a name made up from the address of the
byte blob).
However we still don't want to open the same data more than once (if we're on a
config where we don't have mmap, we malloc some memory and dump the data in
there - we don't want to do that multiple times for the same file).
So the solution is to create this MonoImageStorage object and make it possible
to share it based on path name, but don't give it any responsibilities except
for owning the memory. It doesn't know anything about metadata or assemblies
or any of that stuff - it just owns a chunk of memory and knows when and how to
free it.
This commit just adds the MonoImageStorage object and wires it up in MonoImage
loading. There should be no observable behavioral changes from this commit.
* [win32] call FreeLibrary from MonoImageStorage dtor, not mono_image_close_except_pools
If we're sharing a MonoImageStorage, only call FreeLibrary when the storage is
finally destroyed, not every time one of the images is closed.
Commit migrated from https://github.com/mono/mono/commit/
43540e6649806a84257f1a385dbfe5482eb8ae7f
Jay Krell [Mon, 22 Apr 2019 09:04:32 +0000 (02:04 -0700)]
Small step toward reduction/elimination of JIT icall hashing. (mono/mono#14149)
Ultimate goal is to significantly reduce or maybe completely
eliminate the hashing of JIT icalls.
It is not a small change.
This is a small digestable albeit tedious step toward that.
The "names" of opcode emulation icalls are needed for
token pasting and/or struct fields. They are needed without quotes.
This PR removes the quotes.
And then for now, just always restores them.
This is extracted from https://github.com/mono/mono/pull/14047
as a step toward making it easier to review.
Commit migrated from https://github.com/mono/mono/commit/
800701fe3f370a3f1ab79723192fb3262d1b8375
Vlad Brezae [Fri, 19 Apr 2019 20:11:38 +0000 (23:11 +0300)]
[interp] Fix buffer overflow when incrementing sp
Fixes https://github.com/mono/mono/issues/14079
Commit migrated from https://github.com/mono/mono/commit/
afc16a873315cce2af41b38a74cb74d259cebc98
Alexander Köplinger [Fri, 19 Apr 2019 22:35:18 +0000 (00:35 +0200)]
Bump monolite (mono/mono#14144)
Looks like monolite was broken somehow. Rebuild it.
Commit migrated from https://github.com/mono/mono/commit/
6b73e8db82c8b7a04719c8a95dc65c54939a41e0
Larry Ewing [Fri, 19 Apr 2019 21:08:12 +0000 (16:08 -0500)]
Merge pull request mono/mono#14136 from kjpou1/wasm-function-tests
[wasm] Fix NRE WebAssembly.Core.Array during initialization
Commit migrated from https://github.com/mono/mono/commit/
061fb882951f3d7cced1c527b1a8d4ff75659196
Aleksey Kliger (λgeek) [Fri, 19 Apr 2019 19:57:31 +0000 (15:57 -0400)]
[loader] Don't store through a null ptr (mono/mono#14110)
* [loader] Dont't store through a null ptr
If 'status' is null, don't try to write to it.
Fixes https://github.com/mono/mono/issues/13941
* [metadata] Protect writes to MonoImageOpenStatus* in a few places.
When possible assert that `MonoImageOpenStatus *status` arguments to various
functions in the runtime aren't null. There are a few places (MONO_API) where
it's possible that callers are passing null. In that case, use a local
MonoImageOpenStatus, or check for null before doing assignments.
Commit migrated from https://github.com/mono/mono/commit/
7ba1f77f6da6375bd941b6bac0bbab3bb30ddd6b
pedestrianlove [Fri, 19 Apr 2019 16:13:21 +0000 (00:13 +0800)]
Make dedicated MonoError for `mono_error_set_argument_out_of_range` (mono/mono#14119)
* Make dedicated MonoError for mono_error_set_argument_out_of_range
Commit migrated from https://github.com/mono/mono/commit/
1bdffd21cbd9873a04b6d4f399259a563c8a1e97
Jay Krell [Fri, 19 Apr 2019 15:27:16 +0000 (08:27 -0700)]
[Coop] Convert performance counters and performance counter categories. (mono/mono#13623)
* Cut down on strlen calls.
But keep the shared memory format unchanged to match .NET. (i.e. don't
put string lengths in it).
* PR: MONO_ENTER_NO_SAFEPOINTS instead of gchandle.
Push/pop frames in loops and mind the return/goto/break/continue carefully, instead of using assignment.
*PR: Reduce gsize to adequate int, move multiple int declarations to same line.
* PR: Fix prototypes in disabled code.
* PR: Spell out `int` as `gint32`.
Use an uppercase guid to workaround Windows problem.
* A bit more true to the previous version.
* Reduce diff a little.
* if (is_ok()) around one line instead of goto around it.
* Restore some old code.
* Restore more verbosity, that used to have a point but no longer does.
Commit migrated from https://github.com/mono/mono/commit/
435feaaa0201de4341198c0cec5e225732d50298
Zoltan Varga [Fri, 19 Apr 2019 08:15:54 +0000 (04:15 -0400)]
[llvm] Avoid looking up intrinsics by name in most cases. (mono/mono#14029)
[llvm] Avoid looking up intrinsics by name in most cases.
Commit migrated from https://github.com/mono/mono/commit/
84f6e1dfacbb8deba277907028e9418b4fdfe5b3
Larry Ewing [Fri, 19 Apr 2019 02:24:47 +0000 (21:24 -0500)]
Merge pull request mono/mono#14129 from lewing/sample-tfm
[wasm] Fix the samples target framework
Commit migrated from https://github.com/mono/mono/commit/
e0e3592c200df6b3b4fd771227841b60b0855f95
Zoltan Varga [Thu, 18 Apr 2019 20:41:47 +0000 (16:41 -0400)]
[aot] Add a depfile= argument which causes the AOT compiler to write out a gcc style dep file listing the dependencies between the output file and all referenced assemblies. (mono/mono#14124)
* [aot] Add a depfile= argument which causes the AOT compiler to write out a gcc style dep file listing the dependencies between the output file and all referenced assemblies.
* Add a manpage entry.
* Update after comments.
Commit migrated from https://github.com/mono/mono/commit/
f7dff29c6ce959968cb489fcbee2d3ebde0784d0
Larry Ewing [Thu, 18 Apr 2019 16:43:09 +0000 (11:43 -0500)]
Merge pull request mono/mono#14113 from vargaz/netcore-pinvoke
[wasm] Fix the types of the generated function declarations in the pinvoke table.
Commit migrated from https://github.com/mono/mono/commit/
eaba6c608c81aab472de41156127d4abbd7ee9d5
Thays Grazia [Thu, 18 Apr 2019 16:29:21 +0000 (13:29 -0300)]
Protecting boxing a null value (mono/mono#14018)
When a static method is called the obj is not used, so it can be null and it doesn't need to be boxed.
Adding an assert in the method to prevent other crash in this method if a NULL is received.
Commit migrated from https://github.com/mono/mono/commit/
bc2d8e7c92d1254a6081244be84fc1f7b62cbe33