platform/upstream/dotnet/runtime.git
4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 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

4 years ago[interp] Fix recent warnings I added. (mono/mono#16722)
Jay Krell [Sat, 7 Sep 2019 19:30:48 +0000 (12:30 -0700)]
[interp] Fix recent warnings I added. (mono/mono#16722)

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

4 years ago[interp] Assign sp once is enough in leave. (mono/mono#16694)
Jay Krell [Sat, 7 Sep 2019 01:48:15 +0000 (18:48 -0700)]
[interp] Assign sp once is enough in leave. (mono/mono#16694)

Move vt_sp there too.

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

4 years agoRemove accidentally committed debug line
Alexis Christoforides [Fri, 6 Sep 2019 18:27:57 +0000 (14:27 -0400)]
Remove accidentally committed debug line

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

4 years ago[jit][llvm] Track variable nullness separately from array length ranges/index ranges...
imhameed [Fri, 6 Sep 2019 12:55:21 +0000 (05:55 -0700)]
[jit][llvm] Track variable nullness separately from array length ranges/index ranges in abcrem. (mono/mono#16499)

* [jit][llvm] Track variable nullness separately from array length ranges/index ranges in abcrem.

"Nullness" is tracked via a separate field that is stored adjacent
variable/array value ranges; values may be "maybe-null" or "not-null";
the intersection of maybe-null and not-null yields not-null, the union of
maybe-null and not-null yields maybe-null. The existing graph traversal logic
is reused as much as possible, which makes the implementation of this
null value approximation slightly more complicated than it would be
otherwise.

Fixes https://github.com/mono/mono/issues/16310, which was caused by
the use of non-empty array length ranges as a way to encode non-null
values.

This also allows null check elision for zero-sized arrays.

* Fix C++ compatibility. Fix a typo in a comment.

* Add symmetric nullness relations.

* Make ldlen imply that the source register is not-null, similar to CHECK_THIS or any other null check.

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

4 years ago[metadata] Fix leaks when handling a few attributes (mono/mono#16675)
Vlad Brezae [Fri, 6 Sep 2019 07:31:39 +0000 (10:31 +0300)]
[metadata] Fix leaks when handling a few attributes (mono/mono#16675)

Callers of mono_reflection_create_custom_attr_data_args_noalloc were leaking some of the returned information. Accessed attributes are FixedBufferAttribute and UnmanagedFunctionPointerAttribute.

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

4 years ago[debugger][android] It was not initialising seq_points on MonoCompile on Android...
Thays Grazia [Fri, 6 Sep 2019 01:16:50 +0000 (22:16 -0300)]
[debugger][android] It was not initialising seq_points on MonoCompile on Android, so when was compiling dynamic methods, seq_points wasn't created and we got the assert when try to single step. (mono/mono#16691)

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

4 years ago[interp] Kill InterpFrame.ex (mono/mono#16666)
Vlad Brezae [Thu, 5 Sep 2019 20:10:13 +0000 (23:10 +0300)]
[interp] Kill InterpFrame.ex (mono/mono#16666)

* [interp] Reduce unnecessary uses of frame->ex

* [interp] Remove ex from InterpFrame

We save stack space and move the exception where it belongs, in ThreadContext. It was confusing what frame->ex really meant, it was probably not used / initialized properly. We move it now to ThreadContext where it represents the current exception being thrown during EH (when we have a resume state set).

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

4 years ago[netcore] Bump CoreFX, core-setup dependencies (mono/mono#16681)
Filip Navara [Thu, 5 Sep 2019 18:03:47 +0000 (20:03 +0200)]
[netcore] Bump CoreFX, core-setup dependencies (mono/mono#16681)

* [netcore] Bump CoreFX, core-setup dependencies

* Update .deps.json hacks

* Update test exclusions

Commit migrated from https://github.com/mono/mono/commit/673c8835fd90c5aa05a8836fcfcf24711d456fc7

4 years ago[interp] Localize endfinally_ip to leave, and it cannot be null (barring (mono/mono...
Jay Krell [Thu, 5 Sep 2019 17:46:12 +0000 (10:46 -0700)]
[interp] Localize endfinally_ip to leave, and it cannot be null (barring (mono/mono#16676)

[interp] Localize endfinally_ip to leave, and it cannot likely be null (unless offset carefully formed).

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

4 years agoFix distclean (mono/mono#16667)
Jo Shields [Thu, 5 Sep 2019 17:25:48 +0000 (13:25 -0400)]
Fix distclean (mono/mono#16667)

* Disable `subdir-objects` mode in Automake

This forces creation of subdirectories' files (e.g. .deps/*.Plo) in the
parent directory listing the source file. This works around a situation
where two different files specify files in a different parent directory
(i.e. ../../support/adler32.c in mono/metadata/ and adler32.c in
support/) both emit files into the same place (support/.deps), causing
`make distclean` to try and delete support/.deps from two different
places, breaking distclean.

This unfortunately adds a pile of Automake warnings, during autogen.

The "correct" fix is to stop specifying zlib as a pile of flat .c files,
and instead put it in its own subdirectory, conditionally including
its .la files as required.

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

* Ship netcore/Makefile with an empty distclean rule

We need a netcore/ directory because we write to it during configure,
and we need a netcore/Makefile with a distclean rule, so top-level
recursive distclean doesn't fail. So specify both here.

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

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

4 years agoRemove redundant function call of EscapeTypeName to make (mono/mono#16425)
Fan Yang [Thu, 5 Sep 2019 16:12:57 +0000 (12:12 -0400)]
Remove redundant function call of EscapeTypeName to make  (mono/mono#16425)

* Remove redundant function call

* Remove commented out line of code

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

4 years ago[interp] Remove unused parameter to ves_pinvoke_method. (mono/mono#16677)
Jay Krell [Thu, 5 Sep 2019 15:30:59 +0000 (08:30 -0700)]
[interp] Remove unused parameter to ves_pinvoke_method. (mono/mono#16677)

[interp] Remove unused parameter to ves_pinvoke_method.

It might actually cause stack pressure (but on its own, this PR does not save stack).

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

4 years ago[netcore] Fix the range checks for Vector.CopyTo(). (mono/mono#16663)
Zoltan Varga [Thu, 5 Sep 2019 11:55:53 +0000 (07:55 -0400)]
[netcore] Fix the range checks for Vector.CopyTo(). (mono/mono#16663)

* [netcore] Fix the range checks for Vector.CopyTo().

* [netcore] Fix Vector.get_Item () for u1/u2, the llvm type is a vector of i1/i2, so we need to zero extend.

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

4 years ago[llvm] Use branch weight metadata in some cases. (mono/mono#16668)
Zoltan Varga [Wed, 4 Sep 2019 22:17:07 +0000 (18:17 -0400)]
[llvm] Use branch weight metadata in some cases. (mono/mono#16668)

* [llvm] Add functions to create weighted branches.

* [llvm] Use weighted branches in GC_SAFE_POINT, some llvm passes doesn't seem to recognize llvm.expect so the LLVM JIT generates the slow inline.

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

4 years agoTake stars out of types where they make more sense.
Jay Krell [Tue, 3 Sep 2019 22:47:18 +0000 (15:47 -0700)]
Take stars out of types where they make more sense.

Co-Authored-By: Larry Ewing <lewing@microsoft.com>
Commit migrated from https://github.com/mono/mono/commit/1f21aae8cb410fb4c6e695489a27eae9d22e265d

4 years agoTake stars out of types where they make more sense.
Jay Krell [Tue, 3 Sep 2019 22:46:35 +0000 (15:46 -0700)]
Take stars out of types where they make more sense.

Co-Authored-By: Larry Ewing <lewing@microsoft.com>
Commit migrated from https://github.com/mono/mono/commit/9fc2ade131f7c2ca7b176854b7891a998065c832

4 years agoTake stars out of types where they make more sense.
Jay Krell [Tue, 3 Sep 2019 22:46:16 +0000 (15:46 -0700)]
Take stars out of types where they make more sense.

Co-Authored-By: Larry Ewing <lewing@microsoft.com>
Commit migrated from https://github.com/mono/mono/commit/4359ad66d0621afc79b4f46174a8a20acb418905

4 years agoTake stars out of types where they make more sense.
Jay Krell [Tue, 3 Sep 2019 22:45:52 +0000 (15:45 -0700)]
Take stars out of types where they make more sense.

Co-Authored-By: Larry Ewing <lewing@microsoft.com>
Commit migrated from https://github.com/mono/mono/commit/e25d2e55360d6b108a51d823c45aaaae766e0923