platform/upstream/dotnet/runtime.git
5 years agoOptimize LOS for better parallelization. (mono/mono#17173)
Johan Lorensson [Wed, 23 Oct 2019 18:58:04 +0000 (20:58 +0200)]
Optimize LOS for better parallelization. (mono/mono#17173)

Scanning LOS list as part of minor GC didn't parallelize well since
all scan jobs needed to walk the complete LOS list. This led to touching
a lot of memory walking the list, increasing minor GC pause times
when the number of items in the LOS list increased. As an example,
stressing LOS data structure using ~600 MB's of random sized byte arrays
caused minor GC pause times between ~20ms without parallelization and ~19ms
with parallelization. NOTE, the more work each job gets (more memory to scan)
we will get a better parallelization, but still a lot of room for improvement.

Changing from a normal linked list to a SgenArrayList makes it more effective
to parallelize the scan jobs and since the list is using sequential
memory, this will also reduce cache misses for each thread iterating LOS
objects. Tagging objects in SgenArrayList with reference information reduce
cache misses dramatically in cases where objects not including references
exists on the list, since scanning jobs can skip these items without any
need to touch object memory causing cache misses.

Same scenario running with fix gives us minor GC pause times, without
parallelization in ~7ms (down from 20~ms) and with parallelization,
< 5ms (down from 19ms). NOTE, the more work each job gets (more memory to scan)
we will get a better result using parallelization, so the delta will increase
between using and not using parallelization, this scenario primarily stress
the extreme case where most LOS objects doesn't have references.

In total, this optimization reduce minor GC pause time 4x, from ~19ms when
using parallelization down to < 5ms.

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

5 years ago[wasm] Avoid adding an extra arg to native-to-managed wrappers. (mono/mono#17508)
Zoltan Varga [Wed, 23 Oct 2019 15:06:18 +0000 (11:06 -0400)]
[wasm] Avoid adding an extra arg to native-to-managed wrappers. (mono/mono#17508)

[wasm] Avoid adding an extra arg to native-to-managed wrappers.

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

<!--
Thank you for your Pull Request!

If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.

Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
-->

Commit migrated from https://github.com/mono/mono/commit/31b475e25a4ab5b6d8af731be9bb9e8158da31d9

5 years ago[coop] Fix big endian problem in MonoThradStateMachine and cleanup. (mono/mono#17502)
Jay Krell [Wed, 23 Oct 2019 14:21:54 +0000 (07:21 -0700)]
[coop] Fix big endian problem in MonoThradStateMachine and cleanup. (mono/mono#17502)

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

5 years ago[netcore] Add Unsafe.SkipInit intrinsic
Filip Navara [Wed, 23 Oct 2019 09:53:06 +0000 (11:53 +0200)]
[netcore] Add Unsafe.SkipInit intrinsic

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

5 years ago[interp] Add a new super instructions pass (mono/mono#17489)
Vlad Brezae [Wed, 23 Oct 2019 08:57:07 +0000 (11:57 +0300)]
[interp] Add a new super instructions pass (mono/mono#17489)

Together with a few very simple super instructions. We replace common instruction patterns to avoid indirection via interp stack, instruction dispatch overhead and to allow the compiler to generate better code for the instruction.

Commit migrated from https://github.com/mono/mono/commit/479d2dff365a688cc0045b3c76aa7aba79d4784e

5 years ago[interp] Retry cprop pass if killing stloc (mono/mono#17491)
Vlad Brezae [Wed, 23 Oct 2019 07:39:27 +0000 (10:39 +0300)]
[interp] Retry cprop pass if killing stloc (mono/mono#17491)

When replacing a stloc with a pop, we should retry the pass, since it is very likely that we will be able to kill the instruction that pushed that value on the stack.

Commit migrated from https://github.com/mono/mono/commit/4419dc919f01c6d97ecd1662929adc6e7e642e83

5 years agoSetLastError slightly later, in case last error not preserved, and it is just as...
Jay Krell [Wed, 23 Oct 2019 07:36:15 +0000 (00:36 -0700)]
SetLastError slightly later, in case last error not preserved, and it is just as good. (mono/mono#17483)

SetLastError slightly later, in case last error not preserved, and it is just as good.

Commit migrated from https://github.com/mono/mono/commit/92c08fab4d417d9c3e62dab7f1bac5a710f28916

5 years ago[interp] Optimize ldelem instructions (mono/mono#17494)
Vlad Brezae [Wed, 23 Oct 2019 07:23:49 +0000 (10:23 +0300)]
[interp] Optimize ldelem instructions (mono/mono#17494)

Remove the switch and have each instruction have its own code. Seems to improve speed on a benchmark that heavily uses ldelem by about 10-20%.

Commit migrated from https://github.com/mono/mono/commit/61594078466fd80a4f80a0c3d670adb8301144b0

5 years ago[netcore] Disable debugging code in lookup_intrins (mono/mono#17464)
Filip Navara [Wed, 23 Oct 2019 04:01:51 +0000 (06:01 +0200)]
[netcore] Disable debugging code in lookup_intrins (mono/mono#17464)

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

5 years ago[reflection] mono_method_get_base_method on a GTD should use canonical ginst (mono...
Aleksey Kliger (λgeek) [Tue, 22 Oct 2019 18:07:44 +0000 (14:07 -0400)]
[reflection] mono_method_get_base_method on a GTD should use canonical ginst (mono/mono#17475)

* [test] GetCustomAttributes on generic type definition

* [reflection] mono_method_get_base_method on a GTD should use canonical ginst

The issue is in how we pass along the generic instantiation.  So there are two
parts here: we start with a method on a GTD which has to decompose into the GTD
and it's instantiation with its own generic parameters, and then we go up to
its parent and grandparent inflating and decomposing the resulting
instantiation. The instantiations keep passing the last parameter as the number
of parameters shrinks so that the gparam index from the original type is now
out of bounds for the parent and grandparent.  If we mess up, we'll get a
BadImageFormatException from the runtime

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

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

5 years ago[coop] Use bitfields for coop state machine state representation (mono/mono#17298)
Aleksey Kliger (λgeek) [Tue, 22 Oct 2019 16:14:05 +0000 (12:14 -0400)]
[coop] Use bitfields for coop state machine state representation (mono/mono#17298)

* [checked] Mask the thread state in GC thread state assertions

Because we have extra bits (like suspend count and the no_checkpoints bit) on
the thread state, we have to mask it to get the actual thread state enum value

* [coop] Use bitfields to represent coop thread state

Instead of using a 32-bit int, use bitfields and type-punning through a union
type.  We need to type pun because we need to access the entire state as a 32-bit int so that we can do atomic CAS.

* use atomic load of thread state in unwrap_thread_state.

Saw one stack trace on CI on the full coop lane where check_thread_state saw STATE_RUNNING
but with a positive suspend count.  Another thread was starting a GC a
the time.  Seems like we saw the state as runnning, but the suspend
count as if we were already in async_suspend_requested.

Thread 22 (Thread 0x7f43c03ff700 (LWP 39860)):

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

5 years ago[System.Private.CoreLib] Remove unused methods
Marek Safar [Tue, 22 Oct 2019 13:49:26 +0000 (09:49 -0400)]
[System.Private.CoreLib] Remove unused methods

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

5 years agoUpdate Mono for changes in shared CoreLib partition
Filip Navara [Tue, 22 Oct 2019 09:54:15 +0000 (11:54 +0200)]
Update Mono for changes in shared CoreLib partition

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

5 years ago[jit] Avoid running mono_handle_native_crash () on the altstack, it can't produce...
Zoltan Varga [Tue, 22 Oct 2019 10:31:23 +0000 (06:31 -0400)]
[jit] Avoid running mono_handle_native_crash () on the altstack, it can't produce a backtrace. AMD64 only for now. (mono/mono#17466)

* [jit] Avoid running mono_handle_native_crash () on the altstack, it can't produce a backtrace. AMD64 only for now.

* Fix checks so stack overflows work again.

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

5 years ago[interp] Replace loading of static readonly fields with LDC (mono/mono#17420)
Vlad Brezae [Mon, 21 Oct 2019 20:42:24 +0000 (23:42 +0300)]
[interp] Replace loading of static readonly fields with LDC (mono/mono#17420)

LDC is faster and also allows for constant propagation. Cleanup code a little bit.

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

5 years agoNo type_traits on Android.
Jay Krell [Fri, 18 Oct 2019 01:17:24 +0000 (18:17 -0700)]
No type_traits on Android.

In file included from /Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android/mono/metadata/icall.c:42:
/Users/builder/jenkins/workspace/test-mono-pull-request-amd64-osx-products-sdks-android/mono/metadata/icall-internals.h:89:10: fatal error: 'type_traits' file not found

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

5 years ago[cxx][debug-interp] Cast once from void* to non-void*.
Jay Krell [Sat, 19 Oct 2019 01:35:42 +0000 (18:35 -0700)]
[cxx][debug-interp] Cast once from void* to non-void*.

Commit migrated from https://github.com/mono/mono/commit/21d7d41bfe4a8aebed8e73deadd1fb1177360392

5 years ago[Coop] Unconvert Microsoft.Win32.NativeMethods. (mono/mono#16992)
Jay Krell [Mon, 21 Oct 2019 08:29:39 +0000 (01:29 -0700)]
[Coop] Unconvert Microsoft.Win32.NativeMethods. (mono/mono#16992)

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_CloseProcess.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcessId.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetExitCodeProcess.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_TerminateProcess.

* [Coop] Unconvert ves_icall_Microsoft_Win32_NativeMethods_WaitForInputIdle.

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

5 years ago[interp] Small fixes. (mono/mono#17442)
Zoltan Varga [Mon, 21 Oct 2019 03:28:25 +0000 (23:28 -0400)]
[interp] Small fixes. (mono/mono#17442)

* [interp] Really abort in ves_real_abort ().

* [interp] Fix stack usage in TRACE_EXIT.

* [interp] Add a callback to free ThreadContext.

* Fix warnings.

* Remove an empty statement.

* Fix a double free.

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

5 years ago[netcore] Implement Array.GetElementSize as intrinsic (mono/mono#17437)
Filip Navara [Sun, 20 Oct 2019 22:39:39 +0000 (00:39 +0200)]
[netcore] Implement Array.GetElementSize as intrinsic (mono/mono#17437)

* [netcore] Implement Array.GetElementSize as intrinsic

* Remove unnecessary icall

* alloc_preg -> alloc_ireg

* Implement Array.GetElementSize as intrinsic in interpreter

* Address PR feedback

Commit migrated from https://github.com/mono/mono/commit/32ab6bcf004dee2009ab98f9381842ff3fc6e6f2

5 years ago[netcore] Remove unused code for Array.Unsafe[Mov/Load/Store] intrinsics
Filip Navara [Sat, 19 Oct 2019 09:58:49 +0000 (11:58 +0200)]
[netcore] Remove unused code for Array.Unsafe[Mov/Load/Store] intrinsics

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

5 years agoUse correct variable in mini_get_cpu_features (mono/mono#17436)
Filip Navara [Sun, 20 Oct 2019 05:26:44 +0000 (07:26 +0200)]
Use correct variable in mini_get_cpu_features (mono/mono#17436)

* Use correct variable in mini_get_cpu_features

* Address PR feedback

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

5 years agoRemove dead code left out in mono/mono#17341 (mono/mono#17433)
Filip Navara [Sun, 20 Oct 2019 05:23:05 +0000 (07:23 +0200)]
Remove dead code left out in mono/mono#17341 (mono/mono#17433)

Commit migrated from https://github.com/mono/mono/commit/91f10aeee4ff70696f19fdda9f3d6b67403bc45d

5 years ago[jit][x86][cxx] int/ptr casts in mini-x86.c (mono/mono#17380)
Jay Krell [Sat, 19 Oct 2019 17:20:56 +0000 (10:20 -0700)]
[jit][x86][cxx] int/ptr casts in mini-x86.c (mono/mono#17380)

Commit migrated from https://github.com/mono/mono/commit/91413f78f3242aab3d38d0fb609dd748999265fc

5 years agoReplace ICALL_DECL_EXPORT with ICALL_EXPORT. They are always the same, and it is...
Jay Krell [Sat, 19 Oct 2019 11:25:54 +0000 (04:25 -0700)]
Replace ICALL_DECL_EXPORT with ICALL_EXPORT. They are always the same, and it is only used once. (mono/mono#17429)

Replace ICALL_DECL_EXPORT with ICALL_EXPORT. They are always the same and it is only used once.

Commit migrated from https://github.com/mono/mono/commit/84f4e1dcbf96925105f4d4f54bb9cb9b61067603

5 years ago[bcl] Add null reference checks to Interlocked.Exchange<T> (mono/mono#17400)
Aleksey Kliger (λgeek) [Fri, 18 Oct 2019 23:11:22 +0000 (19:11 -0400)]
[bcl] Add null reference checks to Interlocked.Exchange<T> (mono/mono#17400)

* [bcl] Add null reference checks to Interlocked.Exchange<T>

and Interlocked.CompareExchange<T>

This is to mimic the old behavior in unmanaged when the intrinsic cannot be
used.

The issue was detected via the coreclr acceptance test:
https://github.com/mono/coreclr/blob/mono/tests/src/baseservices/threading/interlocked/exchange/exchangetneg.il

* and netcore

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

5 years ago[cxx] [wasm] int/ptr casts esp. m2n-gen. (mono/mono#17379)
Jay Krell [Fri, 18 Oct 2019 22:03:00 +0000 (15:03 -0700)]
[cxx] [wasm] int/ptr casts esp. m2n-gen. (mono/mono#17379)

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

5 years agoMerge pull request mono/mono#17279 from imhameed/bug-gh-16935-netcore-equalsall-codegen
imhameed [Fri, 18 Oct 2019 19:47:41 +0000 (12:47 -0700)]
Merge pull request mono/mono#17279 from imhameed/bug-gh-16935-netcore-equalsall-codegen

Generate LLVM IR for OP_XEQUAL that is recognized by LLVM's vector pattern recognizers.

Commit migrated from https://github.com/mono/mono/commit/8836231459121e0144ae03169554c1d0636ec5ba

5 years agoSome updates to make RISC-V buildable again. (mono/mono#17408)
Alex Rønne Petersen [Fri, 18 Oct 2019 18:16:14 +0000 (20:16 +0200)]
Some updates to make RISC-V buildable again. (mono/mono#17408)

Some updates to make RISC-V buildable again.

Also some updates to the toolchain setup documentation.

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

5 years ago[profiler] Fix coverage profiler on macos (mono/mono#17396)
Vlad Brezae [Fri, 18 Oct 2019 14:31:47 +0000 (17:31 +0300)]
[profiler] Fix coverage profiler on macos (mono/mono#17396)

If we have coverage profiling enabled for a method (mono_profiler_coverage_instrumentation_enabled, with coverage_filter callback), then we should be able to allocate a coverage info structure (mono_profiler_coverage_alloc). After https://github.com/mono/mono/commit/mono/mono@52429673dc617fd437518757c04c7448211075e9, coverage_filter was reporting wrapper methods as ok to profile, while mono_profiler_coverage_alloc was refusing to allocate the necessary structure, leading to crashes.

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

5 years ago[interp][wasm] Remove more varargs to conserve stack. (mono/mono#17388)
Jay Krell [Fri, 18 Oct 2019 07:39:05 +0000 (00:39 -0700)]
[interp][wasm] Remove more varargs to conserve stack. (mono/mono#17388)

Commit migrated from https://github.com/mono/mono/commit/958b9b2658f6d866ba451781cfa2180e2b340f35

5 years agoEnable GSS on Linux and Android (mono/mono#17223)
Egor Bogatov [Thu, 17 Oct 2019 23:01:44 +0000 (02:01 +0300)]
Enable GSS on Linux and Android (mono/mono#17223)

Commit migrated from https://github.com/mono/mono/commit/4908d1f19a615b033ec148b49c8fab83f1e6f0ec

5 years ago[interp] Constant folding for integers (mono/mono#17362)
Vlad Brezae [Thu, 17 Oct 2019 11:23:12 +0000 (14:23 +0300)]
[interp] Constant folding for integers (mono/mono#17362)

* [interp] Move instructions together

For easy check if an instruction is unary or binary operation. We consider conversion instructions to be unary operators and compare instructions to be binary operators.

* [interp] Add stloc.np also for longs

* [interp] Add stats for total number of emitted instructions

Also make the killed_instructions counter actually track the total amount of killed instructions. It was not previously tracking instructions killed as part of addition of stloc.np / movloc.

* [interp] Improve logging during cprop

Make dumping instruction support also InterpInst's not just compacted instructions.

* [interp] Constant folding of common unary operators

* [interp] Constant fold binary operations

* [interp] Remove MINT_CONV_U8_I4 opcode

It is equivalent with MINT_CONV_I8_U4.

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

5 years ago[cxx] Int vs. enum, static for efficiency, cleanup, fix typo. (mono/mono#17377)
Jay Krell [Thu, 17 Oct 2019 10:25:18 +0000 (03:25 -0700)]
[cxx] Int vs. enum, static for efficiency, cleanup, fix typo. (mono/mono#17377)

[cxx] Int vs. enum, static for efficiency, cleanup, fix typo.

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

5 years ago[cxx][x86] int/ptr casts. (mono/mono#17345)
Jay Krell [Thu, 17 Oct 2019 10:24:46 +0000 (03:24 -0700)]
[cxx][x86] int/ptr casts. (mono/mono#17345)

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

5 years ago[interp] Always intrinsify MemoryBarrier method
Vlad Brezae [Wed, 16 Oct 2019 20:13:10 +0000 (23:13 +0300)]
[interp] Always intrinsify MemoryBarrier method

As we do it on jit.

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

5 years ago[interp] Avoid using full barriers for volatile operations
Vlad Brezae [Wed, 16 Oct 2019 20:01:54 +0000 (23:01 +0300)]
[interp] Avoid using full barriers for volatile operations

This commit avoid unnecessary memory barriers on x86 and amd64.

Volatile writes have release semantics, volatile reads have acquire semantics. Organize the code a little bit to indicate this. On x86 and amd64 we don't require barrier for acquire and release semantics since they are provided by the arch, so we can skip them. Ideally we should have 3 memory barrier interp instructions for each type, but, currently, they would all seem to call mono_memory_barrier so it is useless at this point.

Commit migrated from https://github.com/mono/mono/commit/0102263645b73422d84dbe7fac3bdee65c7447a7

5 years agoUpgrade build scripts to support VS2019. (mono/mono#17269)
Johan Lorensson [Thu, 17 Oct 2019 06:55:50 +0000 (08:55 +0200)]
Upgrade build scripts to support VS2019. (mono/mono#17269)

Changes will default Windows SDK version as well as Platform Toolset to
the default versions used in the targeted VS version. If the projects are
opened up in VS2015, it should default to Windows SDK 8.1 and v140, but if
the same projects are opened in VS2019, it will default to latest Windows SDK 10
and v142. This way the project files should adapt to used VS version, meaning
that we could still build them using VS2015 (what's currently used on CI) but also
using VS2017 and VS2019. There should not be a need to install any previous versions
of build tools, unless an older version is targeted. It is also possible to set
PlatformToolset when calling msbuild and that should adapt to corresponding default
Windows SDK version for targeted toolset version.

Commit makes many changes and adjustments, aligning all vcxproj files but changes
should not affect build output.

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

5 years agoUse functions instead of macros for is_in/is_out. (mono/mono#17350)
Jay Krell [Thu, 17 Oct 2019 04:46:03 +0000 (21:46 -0700)]
Use functions instead of macros for is_in/is_out. (mono/mono#17350)

Use functions instead of macros for is_in/is_out.

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

5 years ago[master] Update dependencies from dotnet/core-setup dotnet/corefx (mono/mono#17355)
dotnet-maestro[bot] [Wed, 16 Oct 2019 21:12:15 +0000 (23:12 +0200)]
[master] Update dependencies from dotnet/core-setup dotnet/corefx (mono/mono#17355)

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

- Microsoft.NETCore.App - 5.0.0-alpha1.19515.17

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

- Microsoft.Private.CoreFx.NETCoreApp - 5.0.0-alpha1.19515.14

* Reenable a test that was fixed

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

5 years ago[cxx][x86][amd64] Remove unused STORE_MEM_IMM. (mono/mono#17347)
Jay Krell [Wed, 16 Oct 2019 20:26:02 +0000 (13:26 -0700)]
[cxx][x86][amd64] Remove unused STORE_MEM_IMM. (mono/mono#17347)

[cxx][x86][amd64] Remove unused STORE_MEM_IMM.

And there was an int/ptr cast error within.

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

5 years ago[bcl][jit] implement Interlocked.Exchange<T> in terms of object (mono/mono#17341)
Aleksey Kliger (λgeek) [Wed, 16 Oct 2019 19:35:49 +0000 (15:35 -0400)]
[bcl][jit] implement Interlocked.Exchange<T> in terms of object (mono/mono#17341)

* [bcl][jit] implement Interlocked.Exchange<T> in terms of object

Exchange<T> is supposed to be picked up as an intrinsic.  But if it isn't,
since T has a class constraint, call the `Exchange (ref object, ref object, ref
object)` overload instead.

This works around a limitation in the JIT:
https://github.com/mono/mono/blob/mono/mono@82a07273c22b996b08fa88ee2e6632d782ac2242/mono/mini/mini-trampolines.c#L704-L713

if we're in the common call trampoline, and the caller is generic method and
the callee is a generic method, if we're using generic sharing for the caller,
but there's no generic jit info for the callee, we will not patch the call
site.

In this case we had Exchange<T> calling Exchange_T<T>
where the callee is an icall (and evidently didn't have generic jit info).

So every time we called Exchange<T>, we would go through the trampoline when
trying to call Exchange_T<T> without patching the call site.

Addresses part of https://github.com/mono/mono/issues/17334

* Bump Mono

* Also drop CompareExchange_T<T>

* Sprinkle some Unsafe magic.

Mark the non-icall methods that we expect the JIT to treet as intrinsics with [Intrinsic]

* aot-runtime doesn't need Volatile.Read<T>/Write<T> code

Both of those methods are implemented as calls to the object overload of Volatile.Read/Write

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

5 years agoremove GenericVectorTests from rsp (mono/mono#17366)
Egor Bogatov [Wed, 16 Oct 2019 19:24:16 +0000 (22:24 +0300)]
remove GenericVectorTests from rsp (mono/mono#17366)

Commit migrated from https://github.com/mono/mono/commit/58b53299b76c7f788a18116676ea8aa9c00a0b9c

5 years ago[cxx][netcore] Goto around init. (mono/mono#17348)
Jay Krell [Wed, 16 Oct 2019 18:56:09 +0000 (11:56 -0700)]
[cxx][netcore] Goto around init. (mono/mono#17348)

[cxx][netcore] Goto around init.

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

5 years ago[cxx][x86] ifndef DISABLE_JIT around mono_arch_emit_prolog. (mono/mono#17346)
Jay Krell [Wed, 16 Oct 2019 18:28:24 +0000 (11:28 -0700)]
[cxx][x86] ifndef DISABLE_JIT around mono_arch_emit_prolog. (mono/mono#17346)

Commit migrated from https://github.com/mono/mono/commit/70675241410f886b096ee79decaf6c3da047640a

5 years agofix netcore build with cygwin (mono/mono#17361)
Egor Bogatov [Wed, 16 Oct 2019 18:20:48 +0000 (21:20 +0300)]
fix netcore build with cygwin (mono/mono#17361)

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

5 years ago[netcore] Implement System.IO.HasOverriddenBeginEndRead(Write)… (mono/mono#17237)
Egor Bogatov [Wed, 16 Oct 2019 18:16:51 +0000 (21:16 +0300)]
[netcore] Implement System.IO.HasOverriddenBeginEndRead(Write)… (mono/mono#17237)

* Implement HasOverriddenBeginEndRead and HasOverriddenBeginEndWrite

* fix typo

* clean up

* more clean up

* more clean up

* convert into intrinsics

* handle end* methods

* Update intrinsics.c

* make cache_System_IO_Stream_slots static

* fix race condition

* Rollback to icall

* Update icall.c

* Address feedback

* Address feedback

Commit migrated from https://github.com/mono/mono/commit/886cd73784befd68b45c4fa3fa4f6864fe366139

5 years ago[ci] Improve netcore build telemetry by running nupkg and tests through build.sh...
Alexander Köplinger [Wed, 16 Oct 2019 16:52:13 +0000 (18:52 +0200)]
[ci] Improve netcore build telemetry by running nupkg and tests through build.sh (mono/mono#17349)

Follow-up to https://github.com/mono/mono/pull/17331.

We were running nuget pack and tests explicitly in the Azure Pipelines
config so we weren't capturing failure telemetry.

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

5 years agoReplace mono_assembly_name_free use with mono_assembly_name_free_internal. (mono...
Jay Krell [Wed, 16 Oct 2019 12:25:55 +0000 (05:25 -0700)]
Replace mono_assembly_name_free use with mono_assembly_name_free_internal. (mono/mono#16982)

Replace mono_assembly_name_free use with mono_assembly_name_free_internal.

Maybe just remove the GC mode change and remove the internal form.
We don't really equate malloc/free with GC/locks/hangs, though arguably we should. Arguably this change is right.

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

5 years ago[interp] Add constant propagation of integers (mono/mono#17326)
Vlad Brezae [Wed, 16 Oct 2019 10:56:14 +0000 (13:56 +0300)]
[interp] Add constant propagation of integers (mono/mono#17326)

* [interp] Make StackValue more intuitive

Replace the opcode field with an enum which will represent what type of value is contained (STACK_VALUE_LOCAL, STACK_VALUE_I4 etc)

* [interp] Add the mint type to the local data

Makes the emitting code easier and we no longer compute the mint type for each local access, which is fairly expensive.

* [interp] Handle indirect locals saner during cprop

Instead of checking for the indirect flag when loading from a local, simply never store a StackValue into such a local since we can't use it. We use the same logic when not pushing on the stack values for such locals.

* [interp] Add constant folding for integers

We decode the values from LDC_I4 and LDC_I8 opcodes and track/propagate the values on the stack and in the locals using the existing infrastructure. When loading a local, we try to load using the known constant value instead, so we might get to kill that local.

* [interp] Similar to stloc.np we can optimize pop/push pairs

If the pushing instruction pushes the same value that was popped by the previous instruction, we can kill them both

* [tests] Remove issue that seems to have been fixed for a while

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

5 years agoFix C++ WebAssembly build. (mono/mono#17302)
Jay Krell [Wed, 16 Oct 2019 08:12:41 +0000 (01:12 -0700)]
Fix C++ WebAssembly build. (mono/mono#17302)

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

5 years agoFix SafeHandle marshalling in ref/in/out parameters (mono/mono#17330)
Filip Navara [Wed, 16 Oct 2019 05:43:42 +0000 (07:43 +0200)]
Fix SafeHandle marshalling in ref/in/out parameters (mono/mono#17330)

* Fix SafeHandle marshalling in ref/in/out parameters

* Reorder code to make it exception safe, update comments

* Revert the code reordering because it breaks the invariant that new handle returned from native code should always create new SafeHandle on the managed side

* Fix test_0_safehandle_ref test. The test was expecting incorrect behavior, verified on .NET Core 3 and .NET Framework 4.8.

* Address PR feedback

* Fix cut & paste error

* Fix build

* Really fix the test_0_safehandle_ref tests

* Add more tests for SafeHandle marshalling

* Add exclusion for broken CoreFX test

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

5 years ago[jit] Fix is_reference checks for intrinsics with byref parameters. (mono/mono#17338)
Zoltan Varga [Wed, 16 Oct 2019 01:45:04 +0000 (21:45 -0400)]
[jit] Fix is_reference checks for intrinsics with byref parameters. (mono/mono#17338)

Found by https://github.com/mono/mono/issues/17335.

Commit migrated from https://github.com/mono/mono/commit/08e8a7f2c3c43366358901d304bfe2808962577a

5 years ago[loader] Add an explicit define DISABLE_DLLMAP to control dllmap usage (mono/mono...
Ryan Lucia [Tue, 15 Oct 2019 23:40:24 +0000 (19:40 -0400)]
[loader] Add an explicit define DISABLE_DLLMAP to control dllmap usage (mono/mono#17315)

* [loader] Add an explicit define ENABLE_DLLMAP to control dllmap usage

* Update configure.ac

* Update configure.ac

* Add dllmap to enable-minimal

* Change to DISABLE_DLLMAP

* Grab some missing MonoDllMap uses

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

5 years agoInitial telemetry for netcore builds (mono/mono#17331)
Jo Shields [Tue, 15 Oct 2019 20:21:21 +0000 (16:21 -0400)]
Initial telemetry for netcore builds (mono/mono#17331)

* Load VSTS telemetry helpers into build.sh script

* First cut adding some basic VSTS-compatible telemetry on failures

* Don't make `ci=true` the default, make it a build.sh flag

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

5 years agoUpdate CoreFX.issues.rsp
Filip Navara [Mon, 14 Oct 2019 23:44:42 +0000 (01:44 +0200)]
Update CoreFX.issues.rsp

See https://github.com/mono/mono/pull/17232#issuecomment-541973035.

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

5 years ago[netcore] Avoid suspending threads in Environment.Exit, it can hang process (mono...
Filip Navara [Mon, 14 Oct 2019 22:35:26 +0000 (00:35 +0200)]
[netcore] Avoid suspending threads in Environment.Exit, it can hang process (mono/mono#17318)

CoreCLR doesn't suspend threads on exit (https://github.com/dotnet/corefx/pull/41450#issuecomment-536755093, https://github.com/dotnet/coreclr/pull/1813).

Fixes mono/mono#17317
Fixes mono/mono#15006
Fixes mono/mono#15010
Fixes mono/mono#15181

Unblocks mono/mono#17232

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

5 years agoRemove broken sin/cos optimization for x86
Filip Navara [Sat, 12 Oct 2019 10:29:27 +0000 (12:29 +0200)]
Remove broken sin/cos optimization for x86

Commit migrated from https://github.com/mono/mono/commit/76068d8d6130f837f004bd435b23175886319a02

5 years agoRemove broken sin/cos optimization for x64
Filip Navara [Sat, 12 Oct 2019 10:27:47 +0000 (12:27 +0200)]
Remove broken sin/cos optimization for x64

Commit migrated from https://github.com/mono/mono/commit/05df3970c21fc31d17a1d79e6738fa43d78709fd

5 years agoFix msvc build warning, empty source main-core.c. (mono/mono#17305)
Johan Lorensson [Mon, 14 Oct 2019 16:55:07 +0000 (18:55 +0200)]
Fix msvc build warning, empty source main-core.c. (mono/mono#17305)

Commit migrated from https://github.com/mono/mono/commit/734b77688467defe62010b3f4eeb6d1694a7e596

5 years ago[loader] Locking and coop related cleanup; fix leak
Ryan Lucia [Wed, 9 Oct 2019 17:16:48 +0000 (13:16 -0400)]
[loader] Locking and coop related cleanup; fix leak

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

5 years ago[loader] Move PInvoke and DllMap code into separate source file
Ryan Lucia [Tue, 8 Oct 2019 22:02:05 +0000 (18:02 -0400)]
[loader] Move PInvoke and DllMap code into separate source file

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

5 years ago[netcore] Remove unused InternalLoadUnmanagedDllFromPath
Ryan Lucia [Wed, 9 Oct 2019 17:37:35 +0000 (13:37 -0400)]
[netcore] Remove unused InternalLoadUnmanagedDllFromPath

As of https://github.com/dotnet/coreclr/pull/27090

Commit migrated from https://github.com/mono/mono/commit/80db55591af3bc85f3f2d0735c316b9b08350a79

5 years ago[netcore] Use a single NativeLibrary.cs for all platforms
Ryan Lucia [Tue, 8 Oct 2019 20:10:03 +0000 (16:10 -0400)]
[netcore] Use a single NativeLibrary.cs for all platforms

Commit migrated from https://github.com/mono/mono/commit/96050effa6e0461b986ac33ab15940b3a9d93353

5 years agoMirror changes from mono/coreclr (mono/mono#17297)
Dotnet-GitSync-Bot [Sat, 12 Oct 2019 06:50:00 +0000 (23:50 -0700)]
Mirror changes from mono/coreclr (mono/mono#17297)

* Enable fast-paths on Mono for Array (dotnet/coreclrmono/mono#27144)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* [CoreLib] Remove String fields moved to shared

* Stub Array Try* methods

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

5 years ago[loader] Fix gnu/lib-names.h define (mono/mono#17294)
Ryan Lucia [Sat, 12 Oct 2019 00:49:24 +0000 (20:49 -0400)]
[loader] Fix gnu/lib-names.h define (mono/mono#17294)

Commit migrated from https://github.com/mono/mono/commit/9832bbb0ac059418c5edeb6388678be89e44f560

5 years ago[runtime] Add portable cached array creation functions and replace gcc-specific impl...
Jay Krell [Fri, 11 Oct 2019 23:47:20 +0000 (16:47 -0700)]
[runtime] Add portable cached array creation functions and replace gcc-specific impl. (mono/mono#16855)

* Remove unused mono_class_get_field_from_name_cached.

* Replace gcc-specific:
  mono_array_class_get_cached
  mono_array_new_cached
  mono_array_new_cached_handle

with portable forms that are easy enough to use and general enough.

Before was "easier" because cache provided for you -- possibly multiple.
Before was more general because rank was a parameter -- and had to be a constant.
It was always 1.

Commit migrated from https://github.com/mono/mono/commit/33d62537d4f7ceeabd8439b26724450a88981d58

5 years agoEnable more hw intrinsics for AOT (mono/mono#17160)
Egor Bogatov [Fri, 11 Oct 2019 19:09:08 +0000 (22:09 +0300)]
Enable more hw intrinsics for AOT (mono/mono#17160)

* Enable more hw intrinsics for AOT

* Address feedback

* does it fix the failure?

* fix loadedllvm

* Address feedback

* fix copy-paste

* forgot MONO_LLVM_INTERNAL

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

5 years agoUpdate MERP event type to MonoAppCrash (mono/mono#17131)
Kyle White [Fri, 11 Oct 2019 15:15:21 +0000 (11:15 -0400)]
Update MERP event type to MonoAppCrash (mono/mono#17131)

* Update parameters in MERP WerReportMetadata xml

To enable backend analysis, we need to update our parameters to match our back end event type, which is MonoAppCrash.

It doesn't make sense to me that the previous implementation constructed the XML here in Mono, but depended on the user (VSMac in this case) to add the "correct" event type.  The parameters in the XML, must match exactly what is expected for the given EventType, and so we should ensure they are always in-sync by defining them here.  Thus, I removed the usage of `eventType` in `mono_merp_enable` and hard coded the expected eventType.

* [merp] Don't pass eventType from managed

The eventType must me MONO_MERP_EVENT_TYPE_STR ("MonoAppCrash") - the backend
determines the format of the other fields based on the event type, so it
doesn't make sense to pass other values from managed since the runtime controls
the other fields.

For compatability Mono.Runtime.EnableMicrosoftTelemetry will still take a
string parameter (now called "unused" instead of "eventType_str") but it will
not pass it down to the internal call.

* Bump corlib version

* [merp] Revert paramerters in WerReportMetadata.xml

Still need event type to be `MonoAppCrash` but the parameters will be the same as before.

Commit migrated from https://github.com/mono/mono/commit/481b3005c63daa38d163e46ef5bb43288b1403b7

5 years agoGenerate LLVM IR for OP_XEQUAL that is recognized by LLVM's vector pattern recognizers.
Imran Hameed [Thu, 10 Oct 2019 23:05:34 +0000 (16:05 -0700)]
Generate LLVM IR for OP_XEQUAL that is recognized by LLVM's vector pattern recognizers.

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

5 years ago[interp] Kill more instructions (mono/mono#17226)
Vlad Brezae [Thu, 10 Oct 2019 19:29:19 +0000 (22:29 +0300)]
[interp] Kill more instructions (mono/mono#17226)

* [interp] Replace STLOC to dead local with MINT_POP

* [interp] Optimize MINT_POP

It was only used for 0 and 1 values. The implementation for values larger than 1 was broken anyway.

* [interp] Remove unnecessary usage of MINT_POP1

When storing a static field from a CEE_STFLD instruction.

* [interp] Prevent optimizing away the stack, after a branch

We know the contents of the stack following a branch, so we could have optimized away some instructions preceding the branch. We shouldn't do this because the code we are branching to expects a certain stack size.

* [interp] Clear instructions which push unused values on stack

* [interp] Properly initialize stack when pushing local

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

5 years ago[eglib] Add newline for failure check prints (mono/mono#17262)
Ryan Lucia [Thu, 10 Oct 2019 13:23:16 +0000 (09:23 -0400)]
[eglib] Add newline for failure check prints (mono/mono#17262)

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

5 years agoIncorrect constrained virtual call in method using gsharedvt for reference type....
Johan Lorensson [Thu, 10 Oct 2019 13:22:54 +0000 (15:22 +0200)]
Incorrect constrained virtual call in method using gsharedvt for reference type. (mono/mono#17227)

* Incorrect constrained virtual call in method using gsharedvt for reference type.

For generic constrained virtual calls using reference type's, the
virtual call will be dispatched using instance vtable. When the same
virtual call is taking place in a gsharedvt method, mono_gsharedvt_constrained_call
gets called that will assist making the call, the problem is that it will
use the constrained class for reference types meaning that it will not call
the most derived implementation of the method. This difference in the behavior
compared to none gsharedvt versions of methods, gives inconsistent results.

One way this will reproduce is by using Dictionary<Type, EmptyStruct>. For
methods that will take both Type (reference type) and EmptyStruct (value type)
like Add, calling that through IDictionary (hiding details from compiler) will
use the gsharedvt version of the method. Internally that method will call
Type.GetHashCode (), and since Type really is a RuntimeType it overrides
GetHashCode. But since mono_gsharedvt_constrained_call will use the constrained
class instead of the instance class, the called method will be
Object.GetHashCode, that gives a different result. When later ContainsKey
is called using the same Type, it only takes a reference value, so not
using a gsharedvt version of the method, then the most derived version of
GetHashCode will be called, given a different hash, not finding item
in dictionary.

Fix is to make sure behavior in mono_gsharedvt_constrained_call match
behavior for regular constrained virtual calls when having a reference type.
This makes sure we always call the most derived version of the method.

Commit also adds a test for this specific scenario using a dictionary.

* Updated to a more low-level test.

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

5 years ago[mini] trace snippet should restore return value (mono/mono#17251)
Bernhard Urban-Forster [Thu, 10 Oct 2019 09:21:23 +0000 (11:21 +0200)]
[mini] trace snippet should restore return value (mono/mono#17251)

* [mini] trace snippet should restore return value

This is a problem on architectures with a floating point stack (x86).

Without this PR and without `--trace` the managed-to-native wrapper for `Math.Ceiling` has a basic block like this at the end:

```
AFTER LOWER-VTYPE-OPTS  4: [IN:  BB6(5) BB3(1), OUT:  BB1(3) ]
 fmove R34 <- R16
 ldaddr R35 <- R10
 load_membase R37 <- [R35 + 0x0]
 store_membase_reg [R36] <- R37
 il_seq_point il: 0x2d
```

`R16` contains the return value. `ldaddr`/`load_membase`/`store_membase_reg` is the sequence for LMF popping.  `mono_spill_global_vars` does this with it:

```
 SPILL BLOCK 4:
 fmove R34 <- R16
         ff  34 16
        0  loadr8_membase R34 <- [%ebp + 0xffffffd4]
        1  nop
 ldaddr R35 <- R10
         ii  35 5
        1  add_imm R35 <- %ebp [-36] clobbers: 1
 load_membase R37 <- [R35 + 0x0]
         ii  37 35
        1  load_membase R37 <- [R35 + 0x0]
 store_membase_reg [R36] <- R37
          ii -1 37
        1  store_membase_reg [%edi] <- R37
 il_seq_point il: 0x2d
             -1
        1  il_seq_point il: 0x2d
```

The local register allocator takes care of the FP stack handling:

```
processing:     0  loadr8_membase %fr0 <- [%ebp + 0xffffffd4]
        [%fr0]
processing:     0  load_membase %eax <- [%ebp + 0xffffffdc]
        [%fr0]
processing:     0  store_membase_reg [%edi] <- %eax
        [%fr0]
processing:     0  il_seq_point il: 0x2d
        [%fr0]
```

At the end of the basic block we have one value left on the FP stack. That's good as we are in the `cfg->bb_exit` basic block, so this is ought to be the return value.

Let's enable `--trace=M:System.Math:Ceiling`. It will insert some code in order to copy arguments/return value to some datastructure that can then be printed by the trace code:

```
processing:     0  loadr8_membase %fr0 <- [%ebp + 0xffffffd4]
        [%fr0]
processing:     0  iconst %eax <- [11116832]
        [%fr0]
processing:     0  iconst %eax <- [52]
        [%fr0]
processing:     0  localloc_imm %eax <-
        [%fr0]
processing:     0  localloc_imm %ecx <-
        [%fr0]
processing:     0  store_membase_reg [%eax + 0x30] <- %ecx
        [%fr0]
processing:     0  x86_lea_membase %edx <- %ebp
        [%fr0]
processing:     0  store_membase_reg [%ecx] <- %edx
        [%fr0]
processing:     0  store_membase_imm [%eax + 0x28] <- [11116832]
        [%fr0]
processing:     0  storer8_membase_reg [%ebp + 0xffffffcc] <- %fr0
        []
processing:     0  x86_lea_membase %ecx <- %ebp
        []
processing:     0  store_membase_reg [%eax + 0x2c] <- %ecx
        []
processing:     0  store_membase_reg [%esp + 0x4] <- %eax
        []
processing:     0  store_membase_imm [%esp] <- [11116832]
        []
processing:     0  voidcall [mono_trace_leave_method] clobbers: c
        []
processing:     0  x86_lea_membase %eax <- %ebp
        []
processing:     0  load_membase %eax <- [%ebp + 0xffffffdc]
        []
processing:     0  store_membase_reg [%edi] <- %eax
        []
processing:     0  il_seq_point il: 0x2d
        []
```

At the very beginning we push some value on the FP stack, same as before. However the code inserted by the tracing code will pop that value. Now, when returning to the, it will pop again something from the FP stack, but alas it's gonna be garbage.

With this PR it looks like this:

```
processing:     0  loadr8_membase %fr0 <- [%ebp + 0xffffffd4]
        [%fr0]
processing:     0  iconst %eax <- [11116832]
        [%fr0]
processing:     0  iconst %eax <- [52]
        [%fr0]
processing:     0  localloc_imm %eax <-
        [%fr0]
processing:     0  localloc_imm %ecx <-
        [%fr0]
processing:     0  store_membase_reg [%eax + 0x30] <- %ecx
        [%fr0]
processing:     0  x86_lea_membase %edx <- %ebp
        [%fr0]
processing:     0  store_membase_reg [%ecx] <- %edx
        [%fr0]
processing:     0  store_membase_imm [%eax + 0x28] <- [11116832]
        [%fr0]
processing:     0  storer8_membase_reg [%ebp + 0xffffffcc] <- %fr0
        []
processing:     0  x86_lea_membase %ecx <- %ebp
        []
processing:     0  store_membase_reg [%eax + 0x2c] <- %ecx
        []
processing:     0  loadr8_membase %fr0 <- [%ebp + 0xffffffcc]
        [%fr0]
processing:     0  store_membase_reg [%esp + 0x4] <- %eax
        [%fr0]
processing:     0  store_membase_imm [%esp] <- [11116832]
        [%fr0]
processing:     0  voidcall [mono_trace_leave_method] clobbers: c
        [%fr0]
processing:     0  x86_lea_membase %eax <- %ebp
        [%fr0]
processing:     0  load_membase %eax <- [%ebp + 0xffffffdc]
        [%fr0]
processing:     0  store_membase_reg [%edi] <- %eax
        [%fr0]
processing:     0  il_seq_point il: 0x2d
        [%fr0]
```

Leaving us the return value on the FP stack before returning.

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

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

5 years agoFix g_assert_not_reached message regression. (mono/mono#17263)
Jay Krell [Thu, 10 Oct 2019 08:26:14 +0000 (01:26 -0700)]
Fix g_assert_not_reached message regression. (mono/mono#17263)

Fix g_assert_not_reached message regression.

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

5 years agoRemove varargs from g_assert and g_assert_not_reachable. (mono/mono#17254)
Jay Krell [Wed, 9 Oct 2019 20:56:06 +0000 (13:56 -0700)]
Remove varargs from g_assert and g_assert_not_reachable. (mono/mono#17254)

Remove varargs from g_assert and g_assert_not_reachable (save 200+ bytes per frame in wasm interp).

g_assertf unchanged.

I have a strong suspicion, this will save approximately 432 - sizeof (InterpFrame) bytes of stack
per function call in the WebAssembly interpreter.

It will not significantly benefit or hurt any other system.
Systems with disabled asserts will receive a small size improvement.

WebAssembly has no provision for varargs.
Emscripten emulates it.
It appears the emulation allocates room in the frame per outgoing varargs call.
No stack packing.
So each g_assert takes space.

Alternative would be to discourage or disable or remove asserts.

Commit migrated from https://github.com/mono/mono/commit/8718b75b7a89f04e2423d11a009f11b37ef802df

5 years ago[mini] print inserted instruction in verbose logging (mono/mono#17249)
Bernhard Urban-Forster [Wed, 9 Oct 2019 18:16:04 +0000 (20:16 +0200)]
[mini] print inserted instruction in verbose logging (mono/mono#17249)

[mini] print inserted instruction in verbose logging

before:
```
 fmove R11 <- R9
         ff  11 9
        1  nop
```

after:
```
 fmove R11 <- R9
         ff  11 9
        0  loadr8_membase R11 <- [%ebp + 0x8]
        1  nop
```

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

5 years ago[mini] Fix check for FastAllocateString that used old name (mono/mono#17219)
Filip Navara [Wed, 9 Oct 2019 13:47:43 +0000 (15:47 +0200)]
[mini] Fix check for FastAllocateString that used old name (mono/mono#17219)

* Fix check for FastAllocateString that used old name

* Fix linker scripts

* Update the icall name for FastAllocateString to match managed name

* Update size check in managed allocator

* One more 64-bit target fix

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

5 years ago[sgen] Fix invalid value passed to write barrier (mono/mono#17236)
Vlad Brezae [Wed, 9 Oct 2019 11:37:41 +0000 (14:37 +0300)]
[sgen] Fix invalid value passed to write barrier (mono/mono#17236)

When doing memory copy dest is the destination address and src is the source address. If we are copying a single reference, we need to emit a write barrier and pass to the write barrier the value, not the pointer where the value is stored.

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

5 years agoRunning --enable-msvc-only didn't find jay.vcxproj. (mono/mono#17228)
Johan Lorensson [Wed, 9 Oct 2019 08:06:09 +0000 (10:06 +0200)]
Running --enable-msvc-only didn't find jay.vcxproj. (mono/mono#17228)

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

5 years ago[netcore] Fix NULL dereference when running LLVM JIT
Filip Navara [Tue, 8 Oct 2019 21:37:34 +0000 (23:37 +0200)]
[netcore] Fix NULL dereference when running LLVM JIT

Commit migrated from https://github.com/mono/mono/commit/28b3446d9eb433a23b595996d4a32dcea5f46b14

5 years agoRevert mono_runtime_set_main_args in mono/mono@44ff0597b835d0af62f526169dba3b365c9c34...
Jay Krell [Wed, 9 Oct 2019 04:54:44 +0000 (21:54 -0700)]
Revert mono_runtime_set_main_args in mono/mono@44ff0597b835d0af62f526169dba3b365c9c3411. (mono/mono#17233)

It breaks Xamarin.Android.

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

5 years ago[interp] Small cleanups (mono/mono#17229)
Vlad Brezae [Tue, 8 Oct 2019 22:08:44 +0000 (01:08 +0300)]
[interp] Small cleanups (mono/mono#17229)

* [intepr] Add define for constant

* [interp] Pass separately pop_vt_sp argument

Cleans up the code a bit. There is no need to do fancy bit operations for such a slow opcode.

Commit migrated from https://github.com/mono/mono/commit/579e385b96c5fd4d9e0b597d4820e3bd2e6cd24a

5 years ago[netcore] Port CoreCLR implementation of Exception.SetCurrentStackTrace (mono/mono...
Filip Navara [Tue, 8 Oct 2019 21:45:17 +0000 (23:45 +0200)]
[netcore] Port CoreCLR implementation of Exception.SetCurrentStackTrace (mono/mono#17243)

* Port CoreCLR implementation of Exception.SetCurrentStackTrace

* Update SerializationRemoteStackTraceString

* Update Exception.cs

Commit migrated from https://github.com/mono/mono/commit/63025d93fd36e834a5f0aca46b659cad0d01d2a2

5 years ago[netcore] Disable some SafeWaitHandle tests everywhere, not just Linux (mono/mono...
Alexander Köplinger [Tue, 8 Oct 2019 15:39:41 +0000 (17:39 +0200)]
[netcore] Disable some SafeWaitHandle tests everywhere, not just Linux (mono/mono#17230)

The tests are kinda bogus since they create a SafeWaitHandle from `new IntPtr(1)` which causes a crash during finalization when releasing that handle.

See https://github.com/mono/mono/issues/17224

Commit migrated from https://github.com/mono/mono/commit/209c4bae3ec1827d1b0e4799b12a51e88012554c

5 years agoFix check in fix_libc_name to trigger only for libc, not or other names with same...
Filip Navara [Tue, 8 Oct 2019 11:06:38 +0000 (13:06 +0200)]
Fix check in fix_libc_name to trigger only for libc, not  or other names with same prefix (mono/mono#17222)

See https://github.com/mono/mono/pull/17210#pullrequestreview-298663220

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

5 years agoClean up map.c /map.h (mono/mono#16746)
Steffen Kieß [Tue, 8 Oct 2019 10:04:45 +0000 (12:04 +0200)]
Clean up map.c /map.h (mono/mono#16746)

* [Mono.Posix] Move Mono_Posix_{From,To}MremapFlags() to support/sys-mman.c

Since mono/mono@b522eab5ff5466debaacf9e971e26cfc464ebba5 Mono_Posix_FromMremapFlags()
and Mono_Posix_ToMremapFlags() contain manual changes for NetBSD. Move the
functions from support/map.c to support/sys-mman.c so that they won't be
overwritten when create-native-map is rerun.

* [Mono.Posix] Fix prototypes in support/stdio.c

In mono/mono@ed892ccf27849c082ce6ca46fa8b96d86ca7c329 wrapper functions for several
stdio functions were added, but the prototypes in map.h were manually
written, not using create-native-map. This commit changes the prototypes so
that they match the output of create-native-map.

* [Mono.Posix] Undefine HAVE_STRUCT_SOCKADDR_IN6 in support/map.c on MSVC

In mono/mono@22b6b9581418260397b701c17b16c3eb55136de7 a manual change to support/map.c
was added to prevent Mono_Posix_FromSockaddrIn6() and
Mono_Posix_ToSockaddrIn6() from being built for windows even if
HAVE_STRUCT_SOCKADDR_IN6 is defined. Instead undefine it in a header file
to avoid manual changes to map.c.

With this commit map.c, map.h and NativeConvert.generated.cs contain no
manual changes anymore.

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

5 years ago[netcore] Add libc name transition
Ryan Lucia [Mon, 7 Oct 2019 18:16:10 +0000 (14:16 -0400)]
[netcore] Add libc name transition

Commit migrated from https://github.com/mono/mono/commit/3355d2dd8115b3b2a412acc6efacd43fe0d63093

5 years agoRemove unused variable
Alexis Christoforides [Mon, 7 Oct 2019 22:05:13 +0000 (18:05 -0400)]
Remove unused variable

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

5 years ago[merp] Print missing status marker file for stage 1 (setup)
Alexis Christoforides [Mon, 7 Oct 2019 20:58:18 +0000 (16:58 -0400)]
[merp] Print missing status marker file for stage 1 (setup)

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

5 years agoZeroing is not necessary, snprintf() always null-terminates in this case
Alexis Christoforides [Mon, 7 Oct 2019 20:59:52 +0000 (16:59 -0400)]
Zeroing is not necessary, snprintf() always null-terminates in this case

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

5 years ago[interp] Rerun cprop pass if stloc.np intructions were eliminated
Vlad Brezae [Fri, 4 Oct 2019 11:22:13 +0000 (14:22 +0300)]
[interp] Rerun cprop pass if stloc.np intructions were eliminated

If we eliminate these instructions, it means we removed instructions that use the top of stack. Without them we might be able to optimize away that stack slot usage. If we retraverse the instruction stream, then we must handle movloc and stloc.np separately.

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

5 years ago[interp] Handle more cases for stloc.np optimization
Vlad Brezae [Fri, 4 Oct 2019 08:18:42 +0000 (11:18 +0300)]
[interp] Handle more cases for stloc.np optimization

We emit stloc.np if we have "stloc local; ldloc local". Bu we can also emit if we have "stloc loc1; ldloc loc2" and loc2 == loc1.

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

5 years ago[interp] Skip NOPs when checking previous instruction
Vlad Brezae [Fri, 4 Oct 2019 07:13:27 +0000 (10:13 +0300)]
[interp] Skip NOPs when checking previous instruction

When emitting stloc.np, which looks for stloc/ldloc pair.

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

5 years agodladdr shim for gmodule; try to enable crash reporter on AIX (mono/mono#15808)
Calvin Buckley [Mon, 7 Oct 2019 22:19:28 +0000 (19:19 -0300)]
dladdr shim for gmodule; try to enable crash reporter on AIX (mono/mono#15808)

* Introduce new dladdr wrapper in glib, AIX reimpl, and convert usage

Provides a wrapper around dladdr that should be platform-neutral.

Also provided is a reimplementation for AIX, which should enable
that platform to get some previously dladdr-specific functions like
the crash reporter. It is somewhat flawed in that it only gets info
for symbols in .text, returns non-constant allocated strings, and
allocates heap memory for buffers.

Then convert usages (except a macOS specific one) of dladdr to the
new eglib function. It has a different signature, which should
simplify intent and reduce structiness. Also free memory on AIX due
to limitations of its reimplmenetation.

* Enable (and fix build of) crash reporter on AIX

So far crashes don't seem any different, but the code for it is
built.

* typo fix (guess this isn't compiled on aix)

* attempt to fix macOS and win32 builds

* Implement more of g_module_address on Win32

Implements the filename stuff. Untested; don't have Windows.

* Look for backtrace_symbols in an IBM compat library for i

Enables i to natively dump a stack trace. (AIX "works" too if you
copy the compat lib's code and hack it in - it probably needs to be
in EGlib.) Unfortunately, it's not perfect. The backchain from the
signal handler is empty on i, and AIX sometimes mangles the stack
frame in a way that severely confuses the backtrace code, causing
it to dereference invalid memory by interpreting instructions as a
pointer. (I have seen somewhat similar for the sigaltstack case,
where the native memory dump attempts to read something it should
not.) Perhaps mincore could be used, but that feels like a sloppy
workaround, especially in the "AIX making an invalid stack frame"
case.

* If the file isn't an archive, don't format its name like one

* Fix up search for backtrace_symbols to look in libexecinfo

FreeBSD ships it in base and Haiku has a package; likely others too.

* Win32 suffers in g_module_address as well

* That should habe been guarded with AIX due to limitations

Otherwise seems to free things that shouldn't be freed

* Casting for win32

* Fix up Win32 impl of module address

* Free HMODULE to lower reference count after using it

* Change dladdr based impl to always dup for impl consistency

Means freeing afterwards shouldn't be ifdefable.

* probably shouldn't strdup NULL

Likely why macOS has failures.

* Don't dup/return const strs, but copy to caller-provided buffers

...which can be on the stack. This makes it far less risky to use
in a crash reporter scenario, because malloc can be hosed then.

Also fix profiler up better to work with this new reality.

Commit migrated from https://github.com/mono/mono/commit/01dd63c440d0ad09542b8d3b9301658a6e8a0d30

5 years agoBump version to 6.9 (mono/mono#17207)
Jo Shields [Mon, 7 Oct 2019 20:36:13 +0000 (16:36 -0400)]
Bump version to 6.9 (mono/mono#17207)

* Bump version to 6.9

* Add missing new linker source file

* [csproj] Update project files

* No monolinker on MCS mode, new linker version needs Roslyn

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

5 years agoDon't declare mono_get_module* on non-win32
Ryan Lucia [Thu, 3 Oct 2019 21:15:33 +0000 (17:15 -0400)]
Don't declare mono_get_module* on non-win32

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

5 years agoUse eglib win32 helper functions without MAX_PATH limit
Ryan Lucia [Wed, 18 Sep 2019 19:56:37 +0000 (15:56 -0400)]
Use eglib win32 helper functions without MAX_PATH limit

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

5 years agoEscape type namespaces, document that we aren't escaping names for now
Ryan Lucia [Tue, 17 Sep 2019 23:47:29 +0000 (19:47 -0400)]
Escape type namespaces, document that we aren't escaping names for now

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

5 years agoMake the mono identifier escape function work like unescape and public
Ryan Lucia [Tue, 17 Sep 2019 23:46:38 +0000 (19:46 -0400)]
Make the mono identifier escape function work like unescape and public

Commit migrated from https://github.com/mono/mono/commit/8760cd446cca20c8ba7f9a49cfacb20e653cc3dd