platform/upstream/dotnet/runtime.git
5 years ago[threading] embedded mono hangs (mono/mono#16907)
Thays Grazia [Wed, 25 Sep 2019 20:12:33 +0000 (17:12 -0300)]
[threading] embedded mono hangs (mono/mono#16907)

* [threading] embedded mono hangs

When embedded mono is executing a C++ code, it didn't start to execute a C# code, we don't need to suspend the thread to run GC.
Fixes mono/mono#16192
Fixes mono/mono#14725

* Changing what was discussed with Aleksey during our 1on1

* Changing what was suggested by Aleksey

* Separating mono_init_version that is being used on tests from the embedded ones

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

5 years ago[Coop] Unconvert ves_icall_Mono_TlsProviderFactory_IsBtlsSupported. (mono/mono#16995)
Jay Krell [Wed, 25 Sep 2019 18:40:38 +0000 (11:40 -0700)]
[Coop] Unconvert ves_icall_Mono_TlsProviderFactory_IsBtlsSupported. (mono/mono#16995)

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

5 years ago[netcore] Disable annoying SourceLink warrnings (mono/mono#17055)
Egor Bogatov [Wed, 25 Sep 2019 16:28:53 +0000 (19:28 +0300)]
[netcore] Disable annoying SourceLink warrnings (mono/mono#17055)

Currently netcore-build doesn't need submodules (except LLVM) so a task somewhere in arcade/microsoft.build.tasks.git always complain if those are not cloned.

Set EnableSourceControlManagerQueries=false to ignore the warnings.

Commit migrated from https://github.com/mono/mono/commit/39ff579432fc6261469f9f0ce6304ca29a5ef141

5 years agoFix comment about mono_thread_interruption_request_flag. (mono/mono#17036)
Jay Krell [Wed, 25 Sep 2019 10:30:27 +0000 (03:30 -0700)]
Fix comment about mono_thread_interruption_request_flag. (mono/mono#17036)

Fix https://github.com/mono/mono/pull/16906/files#r327660329.

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

5 years agoLLVM: Intrinsify MathF.Round (mono/mono#16840)
Egor Bogatov [Tue, 24 Sep 2019 18:53:23 +0000 (21:53 +0300)]
LLVM: Intrinsify MathF.Round (mono/mono#16840)

* improve MathF.Round

* prefer vroundss

* enable round only for jit

Commit migrated from https://github.com/mono/mono/commit/37e46aa9aeec213c94d991da55e16a78b5adf9de

5 years ago[checked-build] update allowed thread states (mono/mono#16971)
Bernhard Urban [Tue, 24 Sep 2019 18:53:10 +0000 (20:53 +0200)]
[checked-build] update allowed thread states (mono/mono#16971)

Commit migrated from https://github.com/mono/mono/commit/153b5def01ae036ad1b9318cc54973a10919f0a7

5 years agoAdd loop related optimizations to LLVM JIT (mono/mono#16436)
Egor Bogatov [Tue, 24 Sep 2019 18:45:32 +0000 (21:45 +0300)]
Add loop related optimizations to LLVM JIT (mono/mono#16436)

* Add loop-related optimizations

* Update llvm-jit.cpp

* Update llvm-jit.cpp

* Update llvm-jit.cpp

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

5 years ago[netcore] Implement missing Bmi1/Bmi2 intrinsics (mono/mono#16919)
Egor Bogatov [Tue, 24 Sep 2019 18:44:03 +0000 (21:44 +0300)]
[netcore] Implement missing Bmi1/Bmi2 intrinsics (mono/mono#16919)

* Finalize BMI1

* cleanup

* Update simd-intrinsics-netcore.c

* Update simd-intrinsics-netcore.c

* fix LLVM-AOT

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

5 years ago[threads] clear small_id_key TLS when unregistering a thread (mono/mono#16973)
Bernhard Urban [Tue, 24 Sep 2019 11:07:19 +0000 (13:07 +0200)]
[threads] clear small_id_key TLS when unregistering a thread (mono/mono#16973)

* [threads] clear small_id_key TLS when unregistering a thread

Fixes
```
* thread mono/mono#12, name = 'tid_a507', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1be66144)
  * frame mono/mono#0: 0x1be66144 libsystem_c.dylib`__abort + 184
    frame mono/mono#1: 0x1be6608c libsystem_c.dylib`abort + 152
    frame mono/mono#2: 0x003e1fa0 monotouchtest`log_callback(log_domain=0x00000000, log_level="error", message="* Assertion at ../../../../../mono/utils/hazard-pointer.c:158, condition `mono_bitset_test_fast (small_id_table, id)' not met\n", fatal=4, user_data=0x00000000) at runtime.m:1251:3
    frame mono/mono#3: 0x003abf44 monotouchtest`monoeg_g_logv_nofree(log_domain=0x00000000, log_level=G_LOG_LEVEL_ERROR, format=<unavailable>, args=<unavailable>) at goutput.c:149:2 [opt]
    frame mono/mono#4: 0x003abfb4 monotouchtest`monoeg_assertion_message(format=<unavailable>) at goutput.c:184:22 [opt]
    frame mono/mono#5: 0x003904dc monotouchtest`mono_thread_small_id_free(id=<unavailable>) at hazard-pointer.c:0:2 [opt]
    frame mono/mono#6: 0x003a0a74 monotouchtest`unregister_thread(arg=0x15c88400) at mono-threads.c:588:2 [opt]
    frame mono/mono#7: 0x00336110 monotouchtest`mono_thread_detach_if_exiting at threads.c:1571:4 [opt]
    frame mono/mono#8: 0x003e7a14 monotouchtest`::xamarin_release_trampoline(self=0x166452f0, sel="release") at trampolines.m:644:3
    frame mono/mono#9: 0x001cdc40 monotouchtest`::-[__Xamarin_NSTimerActionDispatcher release](self=0x166452f0, _cmd="release") at registrar.m:83445:3
    frame mono/mono#10: 0x1ce2ae68 Foundation`_timerRelease + 80
    frame mono/mono#11: 0x1c31b56c CoreFoundation`CFRunLoopTimerInvalidate + 612
    frame mono/mono#12: 0x1c31a554 CoreFoundation`__CFRunLoopTimerDeallocate + 32
    frame mono/mono#13: 0x1c31dde4 CoreFoundation`_CFRelease + 220
    frame mono/mono#14: 0x1c2be6e8 CoreFoundation`__CFArrayReleaseValues + 500
    frame mono/mono#15: 0x1c2be4c4 CoreFoundation`CFArrayRemoveAllValues + 104
    frame mono/mono#16: 0x1c31ff64 CoreFoundation`__CFSetApplyFunction_block_invoke + 24
    frame mono/mono#17: 0x1c3b2e18 CoreFoundation`CFBasicHashApply + 116
    frame mono/mono#18: 0x1c31ff10 CoreFoundation`CFSetApplyFunction + 160
    frame mono/mono#19: 0x1c3152cc CoreFoundation`__CFRunLoopDeallocate + 204
    frame mono/mono#20: 0x1c31dde4 CoreFoundation`_CFRelease + 220
    frame mono/mono#21: 0x1c304a80 CoreFoundation`__CFTSDFinalize + 144
    frame mono/mono#22: 0x1bfa324c libsystem_pthread.dylib`_pthread_tsd_cleanup + 644
    frame mono/mono#23: 0x1bf9cc08 libsystem_pthread.dylib`_pthread_exit + 80
    frame mono/mono#24: 0x1bf9af24 libsystem_pthread.dylib`pthread_exit + 36
    frame mono/mono#25: 0x0039df84 monotouchtest`mono_threads_platform_exit(exit_code=<unavailable>) at mono-threads-posix.c:145:2 [opt]
    frame mono/mono#26: 0x0033bb84 monotouchtest`start_wrapper(data=0x1609e1c0) at threads.c:1296:2 [opt]
    frame mono/mono#27: 0x1bf9b914 libsystem_pthread.dylib`_pthread_body + 128
    frame mono/mono#28: 0x1bf9b874 libsystem_pthread.dylib`_pthread_start + 44
    frame mono/mono#29: 0x1bfa3b94 libsystem_pthread.dylib`thread_start + 4
```

* Update mono/utils/mono-threads.c

Co-Authored-By: Aleksey Kliger (λgeek) <akliger@gmail.com>
Commit migrated from https://github.com/mono/mono/commit/749493d4b3a388b91bd454cc153000049b04b526

5 years ago[debugger] New way to filter exceptions to support VSWin features (mono/mono#16825)
Thays Grazia [Mon, 23 Sep 2019 21:16:59 +0000 (18:16 -0300)]
[debugger] New way to filter exceptions to support VSWin features (mono/mono#16825)

* Creating a new version of MOD_KIND_EXCEPTION_ONLY to support VsWin features, discussed with Joaquin Jares.
Because we don't have this functionality of get every other exception that is not specified, VsWin was getting every exception and filtering later. But this causes a slowness during the debugger because we stop all thread on each exception that we get, even if they are caught and we don't want to stop.

* Fixing other unit test because now we have 2 nested classes.
Fixing indentation.

* Creating a flag in the MOD_KIND_EXCEPTION_ONLY protocol event and not creating a new protocol event.

* Changing what was suggested by Zoltan.

* Coding style

* Bump API snapshot submodule

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

5 years agoCorrectly check for HAVE_STAT_BIRTHTIME in configure.ac checks for System.Native...
Alexander Köplinger [Mon, 23 Sep 2019 20:44:59 +0000 (22:44 +0200)]
Correctly check for HAVE_STAT_BIRTHTIME in configure.ac checks for System.Native (mono/mono#16999)

The check was done incorrectly, the include files need to be separated by newlines otherwise we would get a false negative result.

config.log contained this:

```
conftest.c:279:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
#include <sys/types.h>, #include <sys/stat.h>
                      ^
                      //
```

This means that when doing File.GetCreationTime() we'd fall back to returning the last modified time.

It regressed when we switched to System.IO.File to the CoreFX implementation i.e. System.Native in https://github.com/mono/mono/commit/mono/mono@8f5cef936491e8b20888bbf18d426482c890637c.

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

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

5 years ago[merp] Use function names even in 'private crashes' mode (mono/mono#16897)
Alexis Christoforides [Mon, 23 Sep 2019 19:49:53 +0000 (15:49 -0400)]
[merp] Use function names even in 'private crashes' mode (mono/mono#16897)

Partially fixes https://github.com/mono/mono/issues/16689

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

5 years ago[interp] Improve debuggability with enum. (mono/mono#16721)
Jay Krell [Mon, 23 Sep 2019 09:10:23 +0000 (02:10 -0700)]
[interp] Improve debuggability with enum. (mono/mono#16721)

Commit migrated from https://github.com/mono/mono/commit/7497e4933c6fc0819f8f202829c26c410e4f0e5c

5 years ago[debugger] Crash when debugging iOS application that throws (mono/mono#16958)
Thays Grazia [Sun, 22 Sep 2019 19:12:10 +0000 (16:12 -0300)]
[debugger] Crash when debugging iOS application that throws (mono/mono#16958)

* Doing the same fix from Android to IOS.
* On mini-exceptions.c check if there is no ji we can continue and generate the exception without checking wrapper_type.

Fixes mono/mono#16824

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

5 years agonetcore: fix debug build
EgorBo [Sat, 21 Sep 2019 18:05:13 +0000 (21:05 +0300)]
netcore: fix debug build

Commit migrated from https://github.com/mono/mono/commit/6257369adcf940d81196c476fbbf6978cb008ada

5 years agoInline TLS access. (mono/mono#16882)
Jay Krell [Sat, 21 Sep 2019 16:35:19 +0000 (09:35 -0700)]
Inline TLS access. (mono/mono#16882)

The same functions are referenced by JIT and runtime.
The JIT uses cannot be inlined. The runtime can.
Since I could not get anything else to build and the change is simple and mechanical, now two sets of functions are provided, inline and extern. Extern just calls inline.
This PR appears to change all the uses, but it is only the JIT uses. The runtime ones just work and keep the old names.

We should also consider building desktop with LTO/LTCG, which would do all this automatically, smarter, more generally. A quick experiment shows it grows the runtime size, which is why I say desktop.

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

5 years agoPartially inline mono_method_signature_checked/internal. (mono/mono#16927)
Jay Krell [Sat, 21 Sep 2019 09:09:41 +0000 (02:09 -0700)]
Partially inline mono_method_signature_checked/internal. (mono/mono#16927)

* Inline common fast paths of mono_method_signature_checked and mono_method_signature_internal.

* PR: Restore profilers to use mainstream functions.

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

5 years ago[arm64_32] fix pointer size in CallInfo (mono/mono#16970)
Bernhard Urban [Fri, 20 Sep 2019 22:02:20 +0000 (00:02 +0200)]
[arm64_32] fix pointer size in CallInfo (mono/mono#16970)

Note that in the output below `a`, `b`, etc. are NSObjects, so they are really passed as pointer.

Before:
```
* thread mono/mono#1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame mono/mono#0: 0x04f301d4 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=0x00000000) at nsstring-localization.m:81:9
   78   void *
   79   xamarin_localized_string_format_9 (NSString *format, id a, id b, id c, id d, id e, id f, id g, id h, id i)
   80   {
-> 81           return [NSString localizedStringWithFormat: format, a, b, c, d, e, f, g, h, i];
   82   }
   83
   84   }
(lldb) mbt 4
* thread mono/mono#1
  * frame mono/mono#0: 0x04f301d4 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=0x00000000) at nsstring-localization.m:81:9
    frame mono/mono#1: 0x04d9984c aWatchOSExtension`interp_to_native_trampoline + 156
    frame mono/mono#2: 0x04f41d5c aWatchOSExtension`ves_pinvoke_method(frame=0x05167af8, sig=0x1518afd0, addr=(aWatchOSExtension`::xamarin_localized_string_format_9(NSString *, id, id, id, id, id, id, id, id, id) at nsstring-localization.m:80), string_ctor=0, context=0x14550960, save_last_error=0) at interp.c:1411:2 [opt]
    NSString::xamarin_localized_string_format_9 @ 68 "calli.nat" || frame mono/mono#3: 0x04f3bfa4 aWatchOSExtension`interp_exec_method_full(frame=0x05167d38, context=<unavailable>, clause_args=0x00000000, error=0x05168540) at interp.c:3290:5 [opt]
```

After:
```
* thread mono/mono#1, name = 'tid_303', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame mono/mono#0: 0x04c2c1e0 aWatchOSExtension`::xamarin_localized_string_format_9(format="hello%@%@%@%@%@%@%@%@%@", a=0, b=1, c=2, d=3, e=4, f=5, g=6, h=7, i=8) at nsstring-localization.m:81:9
   78   void *
   79   xamarin_localized_string_format_9 (NSString *format, id a, id b, id c, id d, id e, id f, id g, id h, id i)
   80   {
-> 81           return [NSString localizedStringWithFormat: format, a, b, c, d, e, f, g, h, i];
   82   }
   83
   84   }
```

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

5 years ago[Coop] ves_icall_property_info_get_default_value. (mono/mono#16614)
Jay Krell [Fri, 20 Sep 2019 21:58:16 +0000 (14:58 -0700)]
[Coop] ves_icall_property_info_get_default_value. (mono/mono#16614)

This includes resolving a somewhat deep problem involving
a void* that is usually to a int/float, but can be a MonoObject** or at least MonoString**.
An additional MonoStringHandleOut parameter is pass around to address this.
Perhaps it should be MonoObjectHandleOut for more generality.

Commit migrated from https://github.com/mono/mono/commit/12d3dcecc6bdac25d485a90b6e077c1ec9d29bbe

5 years ago[interp] avoid exception checkpoint when in thread is in GC Safe state (mono/mono...
Bernhard Urban [Fri, 20 Sep 2019 20:15:55 +0000 (22:15 +0200)]
[interp] avoid exception checkpoint when in thread is in GC Safe state (mono/mono#16955)

[interp] avoid exception checkpoint when in thread is in GC Safe state

Usually the interpreter operates in GC Unsafe state. There is an exception however, and that is when it executes a `managed-to-native` wrapper in cooperative (or hybrid) suspend.

The wrapper does essentially:
1. enter GC Safe state via `mono_threads_enter_gc_safe_region_unbalanced`
2. call native function
3. exit GC state via `mono_threads_exit_gc_safe_region_unbalanced`

Usually upon return of a native function call, the interpreter would check for thread interruption and, if applicable, throw an exception.  That, however, would mess with the GC state as the interpreter operates in GC Safe state at this moment.

Note that ignoring thread interruption at that point shouldn't be a problem, because after 3. the `managed-to-native` wrapper will check for thread interruption anyway.

Contributes to https://github.com/mono/mono/issues/16819

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

5 years agoUse ld -Bsymbolic when linking AOT. (mono/mono#14511)
Jay Krell [Fri, 20 Sep 2019 17:12:01 +0000 (10:12 -0700)]
Use ld -Bsymbolic when linking AOT. (mono/mono#14511)

The runtime already does this itself.

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

5 years ago[netcore] Move to new arcade post build using yaml stages (mono/mono#16966)
Alexander Köplinger [Fri, 20 Sep 2019 15:27:15 +0000 (17:27 +0200)]
[netcore] Move to new arcade post build using yaml stages (mono/mono#16966)

This is required by the newer arcade builds.
We can simplify our scripts since we no longer need the special publishwitharcade.proj.

Added copyright and license to the .nuspecs since the new arcade validation now
verifies this against a set of Microsoft policies.

We also need to make the .nupkg pre-release by appending the -preview suffix as stable versions are not permitted in non-stable feeds.

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

5 years agoFix check for SafeHandle types
Filip Navara [Thu, 19 Sep 2019 16:21:21 +0000 (18:21 +0200)]
Fix check for SafeHandle types

Commit migrated from https://github.com/mono/mono/commit/338170ecceaf6d8e69ad1812d416dfaf728096f3

5 years ago[Coop] InterlockedCompare/Exchange (object/T) (mono/mono#16873)
Jay Krell [Fri, 20 Sep 2019 02:36:18 +0000 (19:36 -0700)]
[Coop] InterlockedCompare/Exchange (object/T) (mono/mono#16873)

* [Coop] InterlockedExchange (object and T), InterlockedCompareExchange (object and T).

 - Usually intrinsified.
 - Always?
 - Avoid coop handles by manually always using ref to object.
 - For efficiency on input, and efficiency wrt MonoError.
 - For correctness on output (due to aliasing in the wrappers).
 - To probably avoid assertion failure in runtime around icall marshaling of generics.
 - Unclear on location.

* Balance parens in prints, so they are balanced in the code.

* Reduce local arrays from 16 to auto-sized 1.

* Update and reformat System.Threading.Interlocked signature recognition.

* Rename the generic again to "_T" (or "Generic"?) on the theory
that the aot-runtime.c signature check is too strict/incorrect,
but that if we loosen it, it is not clearly specific to the generic.

* Revise corlib version again.

* Bump API snapshot submodule

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

5 years ago[llvm] Handle recursive calls as a direct call. (mono/mono#16944)
Zoltan Varga [Fri, 20 Sep 2019 01:43:49 +0000 (21:43 -0400)]
[llvm] Handle recursive calls as a direct call. (mono/mono#16944)

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

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

5 years agoInline mono_thread_interruption_request_flag. (mono/mono#16906)
Jay Krell [Thu, 19 Sep 2019 20:49:43 +0000 (13:49 -0700)]
Inline mono_thread_interruption_request_flag. (mono/mono#16906)

Note that the name mono_thread_interruption_request without trailing flag
was already taken.

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

5 years ago[netcore] Show line numbers when xunit tests fail (mono/mono#16931)
Filip Navara [Thu, 19 Sep 2019 18:08:07 +0000 (20:08 +0200)]
[netcore] Show line numbers when xunit tests fail (mono/mono#16931)

Commit migrated from https://github.com/mono/mono/commit/81b5819528f4b3520fbc51cc9b0b355bfa0cc515

5 years agoBalance parens in prints, so they are balanced in the code. (mono/mono#16930)
Jay Krell [Thu, 19 Sep 2019 16:19:59 +0000 (09:19 -0700)]
Balance parens in prints, so they are balanced in the code. (mono/mono#16930)

Commit migrated from https://github.com/mono/mono/commit/06a814e66f8da460cb4d6f94141dc6ba9882cc0d

5 years agoInline mono_object_unbox_internal and mono_object_get_data. (mono/mono#16856)
Jay Krell [Thu, 19 Sep 2019 10:41:29 +0000 (03:41 -0700)]
Inline mono_object_unbox_internal and mono_object_get_data. (mono/mono#16856)

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

5 years agoImplement Marshal.SetLastWin32Error
Filip Navara [Wed, 18 Sep 2019 16:06:49 +0000 (18:06 +0200)]
Implement Marshal.SetLastWin32Error

Commit migrated from https://github.com/mono/mono/commit/85056b086f950799b79a8f999e9a3edd406b0785

5 years agoFix build warnings in libmonoruntime. (mono/mono#16802)
Johan Lorensson [Thu, 19 Sep 2019 06:45:44 +0000 (08:45 +0200)]
Fix build warnings in libmonoruntime. (mono/mono#16802)

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

5 years agoExplicit disable hybrid suspend when cooperative suspend is enabled. (mono/mono#16798)
Johan Lorensson [Thu, 19 Sep 2019 06:45:00 +0000 (08:45 +0200)]
Explicit disable hybrid suspend when cooperative suspend is enabled. (mono/mono#16798)

hybrid suspend won't get disabled when using --enable-cooperative-suspend
triggering configure error:

Hybrid suspend and Cooperative suspend cannot be both enabled.

Fix explicit set hybrid suspend default behavior to no if cooperative
suspend has been configured.

Commit migrated from https://github.com/mono/mono/commit/077e76c47088348c6c4b5d16d821dfea67367683

5 years agoMake case-insensitive class lookup work correctly with exported types (mono/mono...
Ryan Lucia [Wed, 18 Sep 2019 21:18:30 +0000 (17:18 -0400)]
Make case-insensitive class lookup work correctly with exported types (mono/mono#16652)

* Make case-insensitive class lookup work correctly with exported types

* Search all matching namespaces

* Skip AOT cache for case-insensitive lookups

Commit migrated from https://github.com/mono/mono/commit/529a11cf5b7557851472d7cb646559e0d3b02763

5 years ago[netcore] Implement more System.Runtime.Intrinsics.X86.Bmi1/Bmi2 (mono/mono#16891)
Egor Bogatov [Wed, 18 Sep 2019 19:08:35 +0000 (22:08 +0300)]
[netcore] Implement more System.Runtime.Intrinsics.X86.Bmi1/Bmi2 (mono/mono#16891)

* Implement more BMI1/BMI2

* implement more bmi1 intrinsics

* Update simd-intrinsics-netcore.c

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

5 years ago- Some more prep for SIMD on s390x (mono/mono#16903)
Neale Ferguson [Wed, 18 Sep 2019 13:54:27 +0000 (09:54 -0400)]
- Some more prep for SIMD on s390x (mono/mono#16903)

- Use __builtin_bswapxx for s390x rather than inline assembler
- s390x ABI specifies that %f8-%f15 are protected between calls so avoid using or save/restore as required
- Save the "protected" FP registers in the context structure

Commit migrated from https://github.com/mono/mono/commit/86f7cef7f43f9289e9aea96799875ed9578c50ab

5 years ago[mini] Add missing membars when initializing rgctx entries (mono/mono#16904)
Vlad Brezae [Wed, 18 Sep 2019 13:16:17 +0000 (16:16 +0300)]
[mini] Add missing membars when initializing rgctx entries (mono/mono#16904)

[mini] Add missing membars when initializing rgctx entries

Whenever we are publishing changes to the rgctx arrays, we are racing with rgctx_lazy_fetch_trampoline, so we need to make sure any pointers we set there must have their contents initialized.

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

5 years agoAll existing safepoints appear to be mooted by pinned coop handles. (mono/mono#16695)
Jay Krell [Tue, 17 Sep 2019 21:39:09 +0000 (14:39 -0700)]
All existing safepoints appear to be mooted by pinned coop handles. (mono/mono#16695)

Perhaps they are never needed then.

Commit migrated from https://github.com/mono/mono/commit/12c48df242f61c6e028030499a43b140f41873e1

5 years ago[netcore] Fix compiler warnings (mono/mono#16883)
Alexander Köplinger [Tue, 17 Sep 2019 19:18:54 +0000 (21:18 +0200)]
[netcore] Fix compiler warnings (mono/mono#16883)

This fixes the compiler warnings when building netcore-only on macOS.

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

5 years ago[interp] Fix stack size regression (mono/mono#16887)
Vlad Brezae [Tue, 17 Sep 2019 16:27:51 +0000 (19:27 +0300)]
[interp] Fix stack size regression (mono/mono#16887)

Partly revert https://github.com/mono/mono/commit/mono/mono@b18840e92cb5b1afef6c0e5df05cc026eb32efbf

Commit migrated from https://github.com/mono/mono/commit/906c71b8bf990a9f6dce535a1842a2b3d22a5272

5 years ago[interp] Use +=, *= etc. Seems to generate identical code though. (mono/mono#16848)
Jay Krell [Tue, 17 Sep 2019 10:23:19 +0000 (03:23 -0700)]
[interp] Use +=, *= etc. Seems to generate identical code though. (mono/mono#16848)

i.e. a = a op b is *not* double evaluating a.

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

5 years agoTemporarily disable embedded ppdb data decompression (mono/mono#16868)
Ryan Lucia [Tue, 17 Sep 2019 09:23:05 +0000 (05:23 -0400)]
Temporarily disable embedded ppdb data decompression (mono/mono#16868)

This addresses mono/mono#16373. We will work on a proper fix, but this at least unblocks Roslyn CI

Commit migrated from https://github.com/mono/mono/commit/6252794ebe6cd6f04131dbb1ea0da3a8cd4c6ab1

5 years ago[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter (mono/mono...
Bernhard Urban [Tue, 17 Sep 2019 09:15:19 +0000 (11:15 +0200)]
[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter (mono/mono#16865)

[arm64_32] make "Debug Mode" work on Watch series 4 with --interpreter

Main objective for reviewers: This PR shouldn't change anything for `arm64`.

Context: "Debug Mode" on the Apple Watch allows execution of regular machine code and thus is pretty similar to FullAOT on iPhone, i.e. it doesn't require bitcode, but _still_ doesn't allow `signal(3)` so cooperative suspend is required.

Apple Watch Series 4 and onward use an ARM64 chip, but with a different ABI, also known as `arm64_32`. This PR changes the AOT compiler and related trampolines so that the AOT compiler can generate all necessary code to run the interpreter on this target.

Changes:

--------------------------------------

[arm64_32] set register size to 8 in cross compiler too

-----------------------------------------

 [machine] update `target_mgreg_t` definition

`SIZEOF_REGISTER` is usually the same as `TARGET_SIZEOF_VOID_P`, except when `MONO_ARCH_ILP32 is defined.

`target_mgreg_t` should represent the width of the hardware register, that is, `SIZEOF_REGISTER`.

---------------------------------------------

[arm64_32] fix AOT image layout

---------------------------------------------

 [arm64_32] make trampolines bitwidth aware

* replace pointer loads/stores with bitwidth-dependent macro
* reflect `specific` trampolines so that only two instructions are used for ILP32, since the related pair in the data page only needs 2 * 32bits too
* replace some `sizeof (target_mgreg_t)` with `TARGET_SIZEOF_VOID_P` (former is hardware register size, latter is pointer size)

---------------------------------------------
These regression tests are _not_ passing: https://github.com/mono/mono/issues/16864 Also some of monotouch-tests are crashing, see https://github.com/mono/mono/issues/16819

Here is a screenshot of a debug session in VSMac:
<img width="1321" alt="Screenshot 2019-09-16 at 19 13 22" src="https://user-images.githubusercontent.com/75403/64981326-1dfbc000-d8bc-11e9-9d16-48036f36b638.png">

Contributes to https://github.com/mono/mono/issues/10641

Commit migrated from https://github.com/mono/mono/commit/578e1a9dda135516d51f00680939facbc63061ba

5 years ago[cominterop] Default to [in] parameter direction when not specified explicitly.
Nikolay Sivov [Mon, 16 Sep 2019 17:42:43 +0000 (20:42 +0300)]
[cominterop] Default to [in] parameter direction when not specified explicitly.

Treat [In, Out], [In] and unspecified as input arguments. Important change from
current behavior is to allow parameter without directional attributes.

Use case example is _MethodInfo.Invoke() method called from native client.

Commit migrated from https://github.com/mono/mono/commit/08521a1c43780a711113ef42043f664f256e8978

5 years ago[interp] Cleanup dispatch macros. (mono/mono#16784)
Jay Krell [Tue, 17 Sep 2019 08:55:46 +0000 (01:55 -0700)]
[interp] Cleanup dispatch macros. (mono/mono#16784)

- Factor out reptition into already existing macros.
 - Remove the default for computed goto which is dead.
   Computed goto has no notion of default. It is just
   an unchecked array access.

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

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

5 years ago[llvm] Use IntPtrType () for byref arguments instead of a pointer, the latter causes...
Zoltan Varga [Tue, 17 Sep 2019 07:53:52 +0000 (03:53 -0400)]
[llvm] Use IntPtrType () for byref arguments instead of a pointer, the latter causes problems when pointer operations are used along with phi nodes. Fixes https://github.com/mono/mono/issues/16808. (mono/mono#16874)

Commit migrated from https://github.com/mono/mono/commit/1031c4650df27fc77206c38a912228fb0862e198

5 years ago[interp] Optimize multidimensional array access (mono/mono#16822)
Vlad Brezae [Tue, 17 Sep 2019 07:32:20 +0000 (10:32 +0300)]
[interp] Optimize multidimensional array access (mono/mono#16822)

* [interp] Pass rank instead to LDELEMA

It feels more intuitive and uses less computations.

* [interp] Avoid unnecessary type check

Loading element address of array requires type checks only if the elements of the array are references.

* [interp] Avoid using MINT_CALLRUN for Get intrinsic

It is very slow. Use ldelema/ldobj pair instead.

* [interp] Optimize MINT_LDELEMA

* [interp] Rename ldelema_fast to ldelema1

ldelema_fast was handling arrays with a single dimension. Rename it to better suggest this.

* [interp] Avoid using MINT_CALLRUN for Set intrinsic

* [interp] Remove some duplicated and confusing code

* [interp] Fix stack type of MINT_NEWARR result

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

5 years agoFix warnings in eglib gspawn.c on platforms lacking fork/execv. (mono/mono#16801)
Johan Lorensson [Mon, 16 Sep 2019 21:19:00 +0000 (23:19 +0200)]
Fix warnings in eglib gspawn.c on platforms lacking fork/execv. (mono/mono#16801)

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

5 years ago[netcore] Make Environment calls thread-safe (mono/mono#16852)
Filip Navara [Mon, 16 Sep 2019 21:16:14 +0000 (23:16 +0200)]
[netcore] Make Environment calls thread-safe (mono/mono#16852)

* [netcore] Make Environment calls thread-safe

* Address PR feedback

* Address PR feedback

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

5 years ago[debugger] remove extraneous ErrorCode declaration (mono/mono#16862)
Ryan Lucia [Mon, 16 Sep 2019 21:14:42 +0000 (17:14 -0400)]
[debugger] remove extraneous ErrorCode declaration (mono/mono#16862)

With the single point of exit, this means the main ErrorCode isn't being written to and uninitialized memory is returned.

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

5 years ago[wasm] Initial netcore support. (mono/mono#16718)
Zoltan Varga [Mon, 16 Sep 2019 19:42:57 +0000 (15:42 -0400)]
[wasm] Initial netcore support. (mono/mono#16718)

* [runtime] Fix configure support for netcore+out of tree builds. Add wasm support for generating netcore/config.make.

* [runtime] Add bundle support for the netcore assembly loader.

* [netcore] Add missing linker exclusion.

* [wasm] Add netcore builds, enabled by defining ENABLE_WASM_NETCORE in Make.config.

The targets are 'package-wasm-runtime-netcore' and 'package-wasm-bcl-netcore'.
The binaries are copied to out/wasm-runtime-netcore-<CONFIG> and out/wasm-bcl/netcore.

* [wasm] Add netcore support to the build system and packager.

* Fix the build.

* Fix the dynamic build.

Commit migrated from https://github.com/mono/mono/commit/422d559ea45f2e7e998825da26c3fd79a03d5e99

5 years agoStrike a size and conditional branch balance between (mono/mono#16836)
Jay Krell [Mon, 16 Sep 2019 07:10:47 +0000 (00:10 -0700)]
Strike a size and conditional branch balance between (mono/mono#16836)

https://github.com/mono/mono/pull/16835
and
 https://github.com/mono/mono/pull/16834

The main 4 call opcodes should have no conditionality here.
The non-virtuals no extra branch.
The other opcodes all have one condition and branch into common code.

Everything could be smaller or faster but not both.

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

5 years ago[Coop] ParseRouteInfo, fix some leaks, cleanup. (mono/mono#16815)
Jay Krell [Mon, 16 Sep 2019 04:10:12 +0000 (21:10 -0700)]
[Coop] ParseRouteInfo, fix some leaks, cleanup. (mono/mono#16815)

Commit migrated from https://github.com/mono/mono/commit/67fb575d11ef63aba77f1ece1e2dff23c2029467

5 years agoFix infrequent hangs in test-runner. (mono/mono#16793)
Johan Lorensson [Mon, 16 Sep 2019 00:51:07 +0000 (02:51 +0200)]
Fix infrequent hangs in test-runner. (mono/mono#16793)

* Fix infrequent hangs in test-runner.

test-runner has been plagued with very infrequent hangs causing long
timeouts on CI. Turns out that there is a race in AsyncStreamReader
used by Process class for handling stdout/stderr when closing down
process. Since AsyncStreamReader::Dispose didn't make sure no pending
async read requests were still in flight before closing the stream
and underlying handle, it led to a race condition deadlocking the
complete process, hanging test-runner. A similar race has also been
observed but instead of causing a deadlock, it could also manifest as an
System.ObjectDisposedException when doing EndRead while another thread
is disposing the underlying stream. Hitting that race didn't deadlock
the process but failed to complete invoke of test-runner.

Fix is to better protect the async callback and the thread doing the
dispose call. In order to make sure we don't close underlying handle
while still having async reads in flight, fix also checks async result
for completion and if not completed when trying to dispose AsyncStreamReader
it will try to cancel outstanding pending IO and wait for completion
before closing the stream.

Since the issue has only been seen on Windows, the fix will try
to cancel pending IO and wait for completion before closing stream
on Windows. On other platforms, old behavior will be preserved, meaning
that the implementation will still be vunarable to race between pending
reads and close of stream, but since problem has not been observed on
other platforms and since there is no good way of cancel outstanding
blocking reads, old behavior is kept.

At some point in future we should look into replacing the implementation
of AsyncStreamReader and use cancelation tokens, but since we don't have
all corefx support around cancelation in Mono BCL, that currently won't
solve the issue, meaning that we need to bring in more classes. Since the
problem also occur in test-runner using the build BCL profile, even more
needs to be added to that profile in order to get similar support. But due
to the infrequency of the problem and that it has only been observed on
Windows, the isolated fix seems more reasonable.

* Build error fix.

* Review feedback.

* Fix type cast not working on linux builds.

* Adjust icall naming in icall-def.h.

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

5 years ago[Coop] GetValueInternal. (mono/mono#16811)
Jay Krell [Mon, 16 Sep 2019 00:50:25 +0000 (17:50 -0700)]
[Coop] GetValueInternal. (mono/mono#16811)

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

5 years agoFix warnings in libmono. (mono/mono#16813)
Johan Lorensson [Mon, 16 Sep 2019 00:49:53 +0000 (02:49 +0200)]
Fix warnings in libmono. (mono/mono#16813)

Commit migrated from https://github.com/mono/mono/commit/9249d38079f97896da7f97ca54342d58eddc52a6

5 years ago[netcore] Change an ArrayList to a List<T>. (mono/mono#16842)
Zoltan Varga [Mon, 16 Sep 2019 00:45:13 +0000 (20:45 -0400)]
[netcore] Change an ArrayList to a List<T>. (mono/mono#16842)

* [netcore] Change an ArrayList to a List<T>.

* [netcore] Call the generic version of Array.IndexOf () in the ICollection wrappers. Update exclusions file.

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

5 years agoLLVM: Dump Module instead of Function in JIT mode (mono/mono#16837)
Egor Bogatov [Mon, 16 Sep 2019 00:43:10 +0000 (03:43 +0300)]
LLVM: Dump Module instead of Function in JIT mode (mono/mono#16837)

Since each function has its own module (in JIT mode) it makes sense to dump the whole module for MONO_VERBOSE_METHOD instead of just LLVM::Function.
It adds metadata, attributes and global variables (so it will be possible to copy-paste it to godbolt)

Example

static int Test(int x)
{
    return x / 10;
}

Diff for Unoptimized IR: https://www.diffchecker.com/NrF413Ts
Diff for Optimized IR: https://www.diffchecker.com/jbEkeFFS

So now we can see global variables and metadata for each function (and can easily paste them to godbolt.org)

NOTE: optimized IR for this case contains "dead" variables (dump_module allowed us to see such), we probably need some Module-wide optimizations to strip dead code such as -globaldce

NOTE2: why do we emit exceptions in the first place for this case at all?

Commit migrated from https://github.com/mono/mono/commit/0438397b8afc51aac45da55c155162e13e83cf19

5 years ago[interp] Speed up passing this parameter. (mono/mono#16846)
Jay Krell [Sun, 15 Sep 2019 19:26:41 +0000 (12:26 -0700)]
[interp] Speed up passing this parameter. (mono/mono#16846)

Commit migrated from https://github.com/mono/mono/commit/304f3add20dcdb32a3c4c095779efba3a8f5bca1

5 years agoFix small sized argument output with tracing enabled (mono/mono#16841)
Calvin Buckley [Sun, 15 Sep 2019 15:50:32 +0000 (12:50 -0300)]
Fix small sized argument output with tracing enabled (mono/mono#16841)

This is a legacy of before the profiler was used for the trace
output; it would apparently get the raw stack pointer and try to
dereference things by recalculating the offset as needed (no for
little, yes for big). However, because the profiler returns the
actual fixed-up pointer, this recalculation isn't needed on BE,
but instead grabs garbage a bit ahead on the stack.

To fix, use what was the little endian case unconditionally.

Example before:

[1: 20.70598 14] ENTER: System.Globalization.CultureInfo:.ctor (int,bool,bool)(this:700000000408fb0[System.Globalization.CultureInfo platform.exe], 271824864, -32, -32, )

Example after:

[1: 1.93377 14] ENTER: System.Globalization.CultureInfo:.ctor (int,bool,bool)(this:700000000408fb0[System.Globalization.CultureInfo platform.exe], 127, 0, 1)

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

5 years ago[Coop] ves_icall_InternalExecute. (mono/mono#16611)
Jay Krell [Fri, 13 Sep 2019 13:57:45 +0000 (06:57 -0700)]
[Coop] ves_icall_InternalExecute. (mono/mono#16611)

Commit migrated from https://github.com/mono/mono/commit/9608debd7bdf94fe27258d7365d7c04d1c648d90

5 years ago[aot] Do not wrap tool_prefix path when calling strip (mono/mono#16792)
Radek Doulik [Fri, 13 Sep 2019 13:05:27 +0000 (06:05 -0700)]
[aot] Do not wrap tool_prefix path when calling strip (mono/mono#16792)

[aot] Do not put quotes around wrapped path

Should fix: https://github.com/xamarin/xamarin-android/issues/3619

As it results in double quoting, which vanishes the effect and breaks
AOT for XA on Windows.

The actual error:

    [aot-compiler stdout] Stripping the binary: ""C:\Program Files (x86)\Microsoft Visual Studio\2019\Stable\MSBuild\Xamarin\Android\ndk\arm-linux-androideabi-"strip" --strip-symbol=\$a --strip-symbol=\$d obj\Release\90\aot\armeabi-v7a\libaot-Xamarin.Android.Arch.Core.Common.dll.so.tmp
    [aot-compiler stderr] '""C:\Program' is not recognized as an internal or external command,
    [aot-compiler stderr] operable program or batch file.
    [aot-compiler stderr] AOT of image C:\Users\peter\source\repos\App9\App9\App9.Android\obj\Release\90\android\assets\Xamarin.Android.Support.CoordinaterLayout.dll failed.

Commit migrated from https://github.com/mono/mono/commit/131b3a9a92c43d673bbe46229668062a0d447a9f

5 years agoImprove alias analysis for pointer sized variables (mono/mono#16812)
Filip Navara [Fri, 13 Sep 2019 13:02:50 +0000 (15:02 +0200)]
Improve alias analysis for pointer sized variables (mono/mono#16812)

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

5 years ago[interp] Propagate locals and kill dead ones afterwards (mono/mono#16791)
Vlad Brezae [Fri, 13 Sep 2019 07:35:44 +0000 (10:35 +0300)]
[interp] Propagate locals and kill dead ones afterwards (mono/mono#16791)

* [interp] Add flag for locals that have their address taken

The previous handling of LDLOCA was broken because if the address was taken before the instructions that would be optimized we would miss any potential changes to the local value. Right now we just skip optimizing locals that have their address taken. This is achieved simply by not pushing LDLOC on the evaluation stack, for those locals.

* [interp] Add separate counters for optimized instructions

To provide more insight.

* [interp] Propagate locals

Whenever we generate a movloc we remember what local was copied. When loading a local we check if it's currently storing the value of another local, in which case we load the original local instead.

* [interp] Kill instructions that write to dead locals

We track the liveness of a local by counting how many times the local is loaded using ldloc. When such instructions are optimized, the ldloc counter is updated accordingly.

* [interp] Don't optimize code if under debugger

Commit migrated from https://github.com/mono/mono/commit/6908a1941b7278fe6711c75976f2434db55136f0

5 years ago[interp] Replace frame_objref with a volatile store to local. (mono/mono#16790)
Jay Krell [Fri, 13 Sep 2019 02:39:02 +0000 (19:39 -0700)]
[interp] Replace frame_objref with a volatile store to local. (mono/mono#16790)

* [interp] Replace frame_objref with volatile stores to non-volatile locals.
Non-volatiles subject to volatile read/write still get stack-packed.
Volatiles do not.

This will possibly conserve stack, unless MINT_NEWOBJ_FAST is critical path.
 It looks like it is -- enabling this for Linux/gcc/amd64 grows
  frame from 0x98 to 0xA8.

In either case, it is more efficient as the reads do not have to be volatile.
The value can be on the stack and in registers. The stack value will pin it.

* PR: Comments.

* PR: Rearrange comment for correctness, same length.

Commit migrated from https://github.com/mono/mono/commit/735b2cd20c51a926aae93f50903b4e022e851c58

5 years ago[interp] Add percentage to opcode count stats
Vlad Brezae [Thu, 12 Sep 2019 14:20:13 +0000 (17:20 +0300)]
[interp] Add percentage to opcode count stats

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

5 years ago[interp] Disable computed goto when debugging interp
Vlad Brezae [Thu, 12 Sep 2019 11:25:45 +0000 (14:25 +0300)]
[interp] Disable computed goto when debugging interp

It makes tracing and following the code more painful.

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

5 years ago[interp] Fix COUNT_OPS
Vlad Brezae [Thu, 12 Sep 2019 09:45:35 +0000 (12:45 +0300)]
[interp] Fix COUNT_OPS

And make it print the sorted opcode counts when runtime is shutting down

Commit migrated from https://github.com/mono/mono/commit/54a7e61115ba556fbef59c0849ded109baa67cde

5 years agoMerge pull request mono/mono#16388 from naricc/naricc/GetTotalAllocatedBytes
naricc [Thu, 12 Sep 2019 22:12:26 +0000 (18:12 -0400)]
Merge pull request mono/mono#16388 from naricc/naricc/GetTotalAllocatedBytes

Naricc/get total allocated bytes

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

5 years ago[Coop] Debugger single point of exit. (mono/mono#16620)
Jay Krell [Thu, 12 Sep 2019 21:57:02 +0000 (14:57 -0700)]
[Coop] Debugger single point of exit. (mono/mono#16620)

* [Coop] Debugger single point of exit.
Extracted from https://github.com/mono/mono/pull/16614.

* Use a label per error for code size.

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

5 years ago[interp] Emit more stloc.np (mono/mono#16796)
Vlad Brezae [Thu, 12 Sep 2019 17:46:22 +0000 (20:46 +0300)]
[interp] Emit more stloc.np (mono/mono#16796)

Use STLOC_NP_O also for MINT_TYPE_P. It has the same behavior.

Commit migrated from https://github.com/mono/mono/commit/72405f68af0d7684c3601d0d8b2c63b966022622

5 years ago[mini] Fix couple of R4 constant folding checks (mono/mono#16782)
Filip Navara [Thu, 12 Sep 2019 16:37:52 +0000 (18:37 +0200)]
[mini] Fix couple of R4 constant folding checks (mono/mono#16782)

* Fix couple of R4 constant folding checks

* Address feedback

* Split RMOVE and FMOVE

Commit migrated from https://github.com/mono/mono/commit/017f21c2c6b3c23c248b5d9a2d6816edd5deeb04

5 years ago[interp] Remove unused parameters. (mono/mono#16773)
Jay Krell [Thu, 12 Sep 2019 12:42:23 +0000 (05:42 -0700)]
[interp] Remove unused parameters. (mono/mono#16773)

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

5 years ago[interp] Add assert in jmp that sp == stack at start. (mono/mono#16788)
Jay Krell [Thu, 12 Sep 2019 12:06:31 +0000 (05:06 -0700)]
[interp] Add assert in jmp that sp == stack at start. (mono/mono#16788)

It makes it true sometimes, only if not calling alloca.
Throwing invalid IL if false might be preferred here.

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

5 years ago[netcore] Add LLVM to nuget (mono/mono#16524)
Egor Bogatov [Thu, 12 Sep 2019 11:09:03 +0000 (14:09 +0300)]
[netcore] Add LLVM to nuget (mono/mono#16524)

* nuspec for llvm

* Add llvm to matrix

* fix scripts/ci/pipeline-netcore-runtime.yml

* fix scripts/ci/pipeline-netcore-runtime.yml

* fix scripts/ci/pipeline-netcore-runtime.yml

* run tests with llvm

* add macOS lane

* disable llvm tests for now

Commit migrated from https://github.com/mono/mono/commit/977a37844b158e5aabbffa65891fa2ffaf1a416c

5 years agoFix DynamicMethodToString.ToStringTest
EgorBo [Wed, 11 Sep 2019 23:03:01 +0000 (02:03 +0300)]
Fix DynamicMethodToString.ToStringTest

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

5 years agouse full name for llvm ir and asm dumps
EgorBo [Wed, 11 Sep 2019 22:01:39 +0000 (01:01 +0300)]
use full name for llvm ir and asm dumps

Commit migrated from https://github.com/mono/mono/commit/313ce184be497a259f9ebfd40bf1f14a8cc35794

5 years ago[interp] Fix buffer overreads and overwrites found by valgrind. (mono/mono#16726)
Jay Krell [Thu, 12 Sep 2019 00:35:05 +0000 (17:35 -0700)]
[interp] Fix buffer overreads and overwrites found by valgrind. (mono/mono#16726)

* [interp] Fix buffer overreads and overwrites found by valgrind.

* Attempt to deal with inlining correctly.

* PR: Dial back IR changes. Only IL relevant.

* PR: Dial back more -- only needed changes to .NET IL manipulation, not interpreter IR manipulation.

* PR: Remove one more line.

Commit migrated from https://github.com/mono/mono/commit/2235e37470312828bae5c0d2448f1e5ee8e651a8

5 years ago[netcore] Create a separate version of threadpool.c for netcore with the domain suppo...
Zoltan Varga [Thu, 12 Sep 2019 00:04:44 +0000 (20:04 -0400)]
[netcore] Create a separate version of threadpool.c for netcore with the domain support removed. (mono/mono#16250)

* [netcore] Create a separate version of threadpool.c for netcore with the domain support removed.

* Fix the windows build.

* Fix the build.

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

5 years agoWhite space, naming convetions.
Nathan Ricci [Wed, 11 Sep 2019 18:43:06 +0000 (14:43 -0400)]
White space, naming convetions.

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

5 years agoWhite space issues, typos.
Nathan Ricci [Wed, 11 Sep 2019 18:28:16 +0000 (14:28 -0400)]
White space issues, typos.

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

5 years ago[interp] Reduce register pressure in endfinally.
Jay Krell [Fri, 6 Sep 2019 11:52:45 +0000 (04:52 -0700)]
[interp] Reduce register pressure in endfinally.
Eventually this could contribute to stack savings. On its own, nothing.
The compiler apparently likes to create temporaries, like ip and ip - 1.
Which then have to survive functions calls, on the stack, if nonvolatile registers are exhausted.
This combats that and in a larger PR helped.

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

5 years ago[aot] Emit interp entry code for methods which are not AOTed when using AOT profiling...
Zoltan Varga [Wed, 11 Sep 2019 04:11:51 +0000 (00:11 -0400)]
[aot] Emit interp entry code for methods which are not AOTed when using AOT profiling. Also emit most wrappers.

Commit migrated from https://github.com/mono/mono/commit/52d24a57d266d52db53381962e11e5416d3ff1f2

5 years ago[wasm] Add missing aot-profile/runtime.js. (mono/mono#16762)
Zoltan Varga [Wed, 11 Sep 2019 02:24:40 +0000 (22:24 -0400)]
[wasm] Add missing aot-profile/runtime.js. (mono/mono#16762)

* [wasm] Add missing aot-profile/runtime.js.

* [aot] Avoid writing out a zero AOTID in deterministic mode.

* [wasm] Add --aot-profile= option to packager.

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

5 years ago[docs] Improve sgen write barrier documentation (mono/mono#16761)
Vlad Brezae [Wed, 11 Sep 2019 01:54:07 +0000 (04:54 +0300)]
[docs] Improve sgen write barrier documentation (mono/mono#16761)

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

5 years ago[netcore] Disable more features. (mono/mono#16748)
Zoltan Varga [Tue, 10 Sep 2019 19:36:29 +0000 (15:36 -0400)]
[netcore] Disable more features. (mono/mono#16748)

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

5 years ago[wasm] test cleanup (mono/mono#15727)
Larry Ewing [Tue, 10 Sep 2019 17:08:58 +0000 (12:08 -0500)]
[wasm] test cleanup (mono/mono#15727)

* [wasm] stop excluding test_0_large_nullable_invoke on wasm

* [wasm] remove wasm exclusion from test_0_simple_double_casts

* Add category MultiThreaded to more of the concurrent collection tests

* Add more MultiThreaded annotations to HttpListener2Test

* Add category MultiThreaded to HttpWebRequestTest

* [wasm] flag more tests that are taking down the runtime

* [wasm] force sockets to throw PNSE in the ctor for now

* [wasm] enable corlib interpreter tests

* [wasm] Increase timeout for corlib tests

* try to fix wasm-cross-win-release-configure on macos

Commit migrated from https://github.com/mono/mono/commit/47905828121f9929961cc105d1d0b835b3333b32

5 years agoUpdate tests exclusion
Marek Safar [Tue, 10 Sep 2019 09:17:57 +0000 (11:17 +0200)]
Update tests exclusion

Commit migrated from https://github.com/mono/mono/commit/9894bfa6fadb1b2c2c1452cda65896274ddd321f

5 years ago[netcore] Update System.Private.CoreLib public APIs
Marek Safar [Tue, 10 Sep 2019 09:08:00 +0000 (11:08 +0200)]
[netcore] Update System.Private.CoreLib public APIs

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

5 years ago[aot] move method_addresses to data.rel.so section to avoid text relocations (mono...
Bernhard Urban [Tue, 10 Sep 2019 08:16:07 +0000 (10:16 +0200)]
[aot] move method_addresses to data.rel.so section to avoid text relocations (mono/mono#16729)

[aot] move method_addresses to data.rel.so section to avoid text relocations

Another revert of a revert! 🎉

After some discussions with @grendello and @radekdoulik, we came up with this solution. It's a better attempt to fix https://github.com/mono/mono/issues/16369 as it (1) works within the restrictions of Android 10 and (2) still works for armv7 AOT.

`.text` relocations aren't allowed in Android 10 (and this change shouldn't hurt on Linux).

AOT compilation:
```console
$ MONO_PATH=/Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v1.0/ \
MONO_ENV_OPTIONS="" \
./sdks/out/android-cross-arm-release/bin/armv7-linux-android-mono-sgen \
--aot=keep-temps,outfile=here.dll.so,asmwriter,mtriple=armv7-linux-gnueabi,tool-prefix=/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-,ld-flags= \
~/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll

Mono Ahead of Time compiler - compiling assembly /Users/lewurm/Downloads/xamarin.android-oss-v10.0.99.136_Darwin-x86_64_pr_766265b9-Debug/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v10.0/Mono.Android.dll
AOTID 7DDD05DA-37E0-813A-8C27-3E1634391BB3
Compiled: 144382/144382
Executing the native assembler: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-as"   -mfpu=vfp3 -o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
Executing the native linker: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-ld"  -shared -o here.dll.so.tmp  /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ.o
Stripping the binary: "/Users/lewurm/android-toolchain/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip" --strip-symbol=\$a --strip-symbol=\$d here.dll.so.tmp
Retained input file.
JIT time: 15031 ms, Generation time: 7374 ms, Assembly+Link time: 75130 ms.
```

Before:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_550yHJ
        .align 3
jit_code_end:

        .byte 0,0,0,0
.text 1
        .align 3
method_addresses:
        .local method_addresses
        .type method_addresses,#function
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
 0x00000016 (TEXTREL)                    0x0
 0x0000001e (FLAGS)                      TEXTREL
```

After switching to `.data.rel.so`:
```console
$ grep -C 6 'method_addresses:' /var/folders/p3/5279mmgn1p575bz28j0ngfqw0000gn/T/mono_aot_1YhAgn  # assembly file produced by AOT compiler
jit_code_end:

        .byte 0,0,0,0
.section ".data.rel.ro"
.subsection 0
        .align 3
method_addresses:
        .local method_addresses
        .type method_addresses,#object
ldr pc,=.Lm_0
.ltorg
ldr pc,=.Lm_1
.ltorg
$ arm-linux-androideabi-readelf -a here.dll.so | grep -i textrel
$ echo $?
1
```

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

5 years agoDisable failing tests
Marek Safar [Tue, 10 Sep 2019 07:04:40 +0000 (09:04 +0200)]
Disable failing tests

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

5 years agoRefactored where the varaibles for allocation count live.
Nathan Ricci [Mon, 9 Sep 2019 20:39:51 +0000 (16:39 -0400)]
Refactored where the varaibles for allocation count live.

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

5 years agoVtable [i] can be null so this should be check before use it. (mono/mono#16733)
Thays Grazia [Mon, 9 Sep 2019 20:07:34 +0000 (17:07 -0300)]
Vtable [i] can be null so this should be check before use it. (mono/mono#16733)

Fixes mono/mono#16712

Commit migrated from https://github.com/mono/mono/commit/055818f3449b5176dcf0e4eb07491b2501112701

5 years ago[interp] Let compiler decide clear_resume_state inlining. (mono/mono#16704)
Jay Krell [Mon, 9 Sep 2019 17:31:37 +0000 (10:31 -0700)]
[interp] Let compiler decide clear_resume_state inlining. (mono/mono#16704)

Manual inlining shows no additional stack use any longer.

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

5 years ago[llvm] Mark Vector128/Vector256 types as SIMD.
Zoltan Varga [Thu, 22 Aug 2019 06:01:17 +0000 (02:01 -0400)]
[llvm] Mark Vector128/Vector256 types as SIMD.

These are not currently supported, but marking them as simd helps llvm eliminate dead variables with these types, since
XZERO is easier to eliminate than VZERO.

Commit migrated from https://github.com/mono/mono/commit/798af6613796fcbe11cf20a33a889705483197a7

5 years agoDefault to SAFEARRAY(VARIANT) as CCW argument for object[]. (mono/mono#16673)
Nikolay Sivov [Mon, 9 Sep 2019 17:02:46 +0000 (20:02 +0300)]
Default to SAFEARRAY(VARIANT) as CCW argument for object[]. (mono/mono#16673)

* [cominterop] Add a helper to create default marshal spec for ccw arguments.

* [cominterop] Default to SAFEARRAY(VARIANT) as CCW argument for object[].

* [cominterop] Fix build with --enable-cxx.

Commit migrated from https://github.com/mono/mono/commit/8590a25b301ec08ac688e93df37fe3ef3c2ddb11

5 years ago[interp] Embrace that ip is const guint16* and remove casts to that type, (mono/mono...
Jay Krell [Mon, 9 Sep 2019 15:06:16 +0000 (08:06 -0700)]
[interp] Embrace that ip is const guint16* and remove casts to that type, (mono/mono#16708)

[interp] Embrace that ip is const guint16* and remove casts to that type.

or to gint16*. Or is there a reason for this style?

Maybe could change type but still want to cast for the deref?

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

5 years ago[interp] Defer local offset allocation to compacted emit phase (mono/mono#16714)
Vlad Brezae [Mon, 9 Sep 2019 14:10:50 +0000 (17:10 +0300)]
[interp] Defer local offset allocation to compacted emit phase (mono/mono#16714)

Before this commit, the only information associated with a local was just the offset at which it resides and instructions had this offset embedded from the start. This makes it awkward to have data structures indexed on the local, or have additional information per local, which we might care at some point (for example if it is multi basic block local, if the address of the local was taken etc). In addition to this, if we will want to remove some instructions that make some locals dead, it means that we will have to compact the whole locals space and update all the offsets referenced by all instructions. We solve all these problems by resolving (and allocating) the local offset at the latest time, while emitting the instruction in the compacted byte stream. At this point dead locals will remain dead, with no additional work needed to handle them.

For now, IL locals of the current method that we are compiling are immortal. We can address that later if needed.

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

5 years ago[netcore] Tweak inlining heurestic for memcpy
Filip Navara [Sat, 31 Aug 2019 16:30:16 +0000 (18:30 +0200)]
[netcore] Tweak inlining heurestic for memcpy

Commit migrated from https://github.com/mono/mono/commit/320f91129dbc839ccd19154ea687945aa0ce2a77

5 years ago[netcore][x64] Implement lowering of new SIMD OPs into SSE opcodes (mono/mono#16672)
Filip Navara [Sun, 8 Sep 2019 19:57:21 +0000 (21:57 +0200)]
[netcore][x64] Implement lowering of new SIMD OPs into SSE opcodes (mono/mono#16672)

* [netcore][x64] Implement lowering of new SIMD OPs into SSE2 or SSE4.1 opcodes.

* Implement LZCNT/POPCNT in mini JIT

* Fix C++ build

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

5 years ago[interp] Fix debug build. (mono/mono#16720)
Jay Krell [Sun, 8 Sep 2019 06:25:33 +0000 (23:25 -0700)]
[interp] Fix debug build. (mono/mono#16720)

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