platform/upstream/dotnet/runtime.git
5 years ago[arm] align stack pointer in throw trampoline (mono/mono#14078)
Bernhard Urban [Tue, 16 Apr 2019 22:36:05 +0000 (00:36 +0200)]
[arm] align stack pointer in throw trampoline (mono/mono#14078)

This is a regression introduced by mono/mono@e46fa20466010a18b9b9a8130f6d8c62899780b3

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

Commit migrated from https://github.com/mono/mono/commit/98a1d40584b5e40052c93d0e4059f821ee1609fa

5 years ago[aot] Change how the context is computed in init_aot_method (). Instead of (mono...
Zoltan Varga [Tue, 16 Apr 2019 15:30:16 +0000 (11:30 -0400)]
[aot] Change how the context is computed in init_aot_method (). Instead of (mono/mono#14026)

getting it from the caller, save it in the aot image and read it back.
This will make it possible to emit direct calls to gshared methods later.

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

5 years agoRegister mono_gc_wbarrier_generic_nostore_internal regular with its own name, not...
Jay Krell [Tue, 16 Apr 2019 11:34:46 +0000 (04:34 -0700)]
Register mono_gc_wbarrier_generic_nostore_internal regular with its own name, not dynamic with a special name. (mono/mono#14042)

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

5 years agoRegister g_free icall regular, as monoeg_g_free. (mono/mono#14044)
Jay Krell [Tue, 16 Apr 2019 11:34:29 +0000 (04:34 -0700)]
Register g_free icall regular, as monoeg_g_free. (mono/mono#14044)

The point here is that register_dyn is a bit obscure and could use clarification.

Commit migrated from https://github.com/mono/mono/commit/6225a9b031fd9d70d23cbb0139b471238e7616f5

5 years ago[netcore] Fix WaitHandle.SignalAndWait (mono/mono#13809)
Egor Bogatov [Tue, 16 Apr 2019 10:04:02 +0000 (13:04 +0300)]
[netcore] Fix WaitHandle.SignalAndWait (mono/mono#13809)

* fix failing tests

* Add build-corefx-test-for- rule

* Update WaitHandle.cs

* fix S.T.T.rsp file

* fix build

* bump corlib version

* handle new errors in old mono

* Update w32handle.c

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

5 years ago[netcore] Fix System.Tests.PseudoCustomAttributeTests.* tests (mono/mono#14065)
Egor Bogatov [Tue, 16 Apr 2019 09:51:26 +0000 (12:51 +0300)]
[netcore] Fix System.Tests.PseudoCustomAttributeTests.* tests (mono/mono#14065)

* fix Custom Attribute tests

* fix CA

* fix CA

* Update MonoCustomAttrs.cs

* fix MarshalAsAttribute

* Update MarshalAsAttribute.cs

* Update MarshalAsAttribute.cs

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

5 years ago[netcore] Add linker descriptor for corelib. (mono/mono#14064)
Zoltan Varga [Tue, 16 Apr 2019 09:48:12 +0000 (05:48 -0400)]
[netcore] Add linker descriptor for corelib. (mono/mono#14064)

* [netcore] Add linker descriptor. This is just a copy of the mscorlib descriptor.

* [netcore] Update linker descriptor for netcore.

* Remove com/remoting related classes.
* Other smaller changes.

* [netcore] Allow loading corlib from MONO_PATH.

* Update System.Private.CoreLib.xml

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

5 years ago[llvmonly] Fix a buffer overflow. (mono/mono#14057)
Zoltan Varga [Mon, 15 Apr 2019 23:23:05 +0000 (19:23 -0400)]
[llvmonly] Fix a buffer overflow. (mono/mono#14057)

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

5 years ago[aot] change method table generation so that it works for larger assemblies on ARM...
Bernhard Urban [Mon, 15 Apr 2019 22:25:51 +0000 (00:25 +0200)]
[aot] change method table generation so that it works for larger assemblies on ARM (mono/mono#14043)

[aot] change method table generation so that it works for larger assemblies on ARM

At the end of the AOT compilation, we dump a table containing all method
entrypoints using the toolchain linker to resolve the addresses. Previously
we used `bl` for that, however on larger assemblies the offset might
overflow the 24bit immediate (thus, the linker bailing out with
"Error: branch out of range"). Instead, using `ldr pc,=<label>` followed
by `.ltorg` emits the full 32bit address to a method. That takes 8 bytes
for each method instead of 4 bytes.

( I couldn't reopen https://github.com/mono/mono/pull/3486 anymore)

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

5 years ago[netcore] Misc. fixes (mono/mono#14050)
Filip Navara [Mon, 15 Apr 2019 13:02:47 +0000 (15:02 +0200)]
[netcore] Misc. fixes (mono/mono#14050)

* Check for lower bounds on non-zero-based arrays

* Grab correct version of System.Reflection.Context

* Move Attribute type validation to fix checking for custom attributes using interface types

* Fix parameter checks

Commit migrated from https://github.com/mono/mono/commit/012ac05aa9de47ae421af4c0e7d0724de2d18d82

5 years ago[interp] Static field access fixes (mono/mono#14009)
Vlad Brezae [Mon, 15 Apr 2019 12:35:34 +0000 (15:35 +0300)]
[interp] Static field access fixes (mono/mono#14009)

* [interp] Further optimize static vt field access

We don't require any write barrier checking since we always copy between interpreter vt_stack and static data. We can also include the vt size in the code stream. Makes it over 1.5x times faster.

* [interp] Fix static field access using ldfld/stfld

Static field access using the ldfld/stfld instructions was not updated when stsfld/ldsfld were optimized.

* [interp] Fix special static vtype field access

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

5 years ago[netcore] Switch to msbuild nuget which is available for all platforms (mono/mono...
Filip Navara [Mon, 15 Apr 2019 09:30:46 +0000 (11:30 +0200)]
[netcore] Switch to msbuild nuget which is available for all platforms (mono/mono#13989)

* Switch to msbuild nuget which is available for all platforms

* Remove check-env rule dependency

* Add missing reference to System.Composition.TypedParts

* Sort references by name

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

5 years ago[netcore] Do not inline if [DynamicSecurityMethod] exists (mono/mono#14032)
Egor Bogatov [Mon, 15 Apr 2019 06:34:23 +0000 (09:34 +0300)]
[netcore] Do not inline if [DynamicSecurityMethod] exists (mono/mono#14032)

* fix crash

* fix build

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

5 years agoRemove redundant check of llvm_acfg->aot_opts.direct_icalls. (mono/mono#14028)
Jay Krell [Sun, 14 Apr 2019 19:58:17 +0000 (12:58 -0700)]
Remove redundant check of llvm_acfg->aot_opts.direct_icalls. (mono/mono#14028)

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

5 years ago[netcore] Make System.Private.CoreLib and host APIs compilable on Windows (mono/mono...
Filip Navara [Sun, 14 Apr 2019 16:58:40 +0000 (18:58 +0200)]
[netcore] Make System.Private.CoreLib and host APIs compilable on Windows (mono/mono#13943)

* Fix Windows builds of CLR hosting API

* Make System.Private.CoreLib compilable on Windows

* Remove accidental change

* Fix Unix build

* Update GlobalizationMode.cs

* Update GlobalizationMode.Unix.cs

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

5 years agoRemove constant parameter to mono_tls_get_tls_setter and mono_tls_get_tls_getter...
Jay Krell [Sun, 14 Apr 2019 14:24:18 +0000 (07:24 -0700)]
Remove constant parameter to mono_tls_get_tls_setter and mono_tls_get_tls_getter. (mono/mono#13894)

It doesn't matter, but for code clarity.
Also strengthen the types of both of these, though rarely enough to avoid casts.

Commit migrated from https://github.com/mono/mono/commit/568c822ae9c23acecff478a2deaeb81e942ffbc1

5 years ago[interp] Optimize ldobj/stobj (mono/mono#13761)
Vlad Brezae [Fri, 12 Apr 2019 18:50:05 +0000 (21:50 +0300)]
[interp] Optimize ldobj/stobj (mono/mono#13761)

* [interp] Remove dead code

It doesn't make sense to dereference a value type

* [interp] Emit faster instructions for ldobj

* [interp] Emit faster instructions for stobj

* [interp] Simply ldobj vt

This makes it 10x faster

* [interp] Make ldind.r8 unaligned friendly

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

5 years agoIncrease gsharedvt trampolines by 10% from 4000 to 4400.
Jay Krell [Thu, 11 Apr 2019 10:03:52 +0000 (03:03 -0700)]
Increase gsharedvt trampolines by 10% from 4000 to 4400.

There are many minor arguments here.

Where this matters most -- iOS -- the pool is already dynamic.

Other platforms could use a dynamic pool or JIT (despite FullAOT).
Using JIT would defeat the test coverage.

Mitigates https://github.com/mono/mono/issues/13888.
If this feels too tenative, go bigger.

Commit migrated from https://github.com/mono/mono/commit/22bbf4416a64beb12ec2b0b5c7293892a12f0660

5 years ago[w32error] Add ENONET error case
Maxim Lipnin [Thu, 11 Apr 2019 12:51:27 +0000 (15:51 +0300)]
[w32error] Add ENONET error case

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

5 years ago[jit] Make dlmalloc use mono_valloc so it picks up the MAP_JIT flag on osx. (mono...
Zoltan Varga [Thu, 11 Apr 2019 13:19:42 +0000 (09:19 -0400)]
[jit] Make dlmalloc use mono_valloc so it picks up the MAP_JIT flag on osx. (mono/mono#13979)

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

Commit migrated from https://github.com/mono/mono/commit/5036336df811fe55d4721c2ef9b1152456ddb32a

5 years ago[debugger-agent]: Print error if the socket can not be created, remove assert that...
Miguel de Icaza [Thu, 11 Apr 2019 12:38:17 +0000 (08:38 -0400)]
[debugger-agent]: Print error if the socket can not be created, remove assert that probed the wrong value, Coverity 1307166 (mono/mono#13860)

Commit migrated from https://github.com/mono/mono/commit/56db577988d3b2244d64d32e5f885126641b2332

5 years ago[jit] Disable inlining for methods with [System.Security.DynamicSecurityMethod],...
Zoltan Varga [Sun, 7 Apr 2019 21:20:31 +0000 (17:20 -0400)]
[jit] Disable inlining for methods with [System.Security.DynamicSecurityMethod], its used to make methods which contain a StackCrawlMark.

Also check that the attribute is present for StackMaekMark locals.

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

5 years agoMerge pull request mono/mono#13815 from radical/nuget-5
Marek Safar [Thu, 11 Apr 2019 09:08:41 +0000 (11:08 +0200)]
Merge pull request mono/mono#13815 from radical/nuget-5

[nuget] Bump to nuget 5.0.0

Commit migrated from https://github.com/mono/mono/commit/995bbb998c638b3fe563dbaa5aff6c5198d1d5ce

5 years ago[netcore] Implement Assembly.GetExecutingAssembly with stack mark parameter (mono...
Filip Navara [Thu, 11 Apr 2019 08:31:22 +0000 (10:31 +0200)]
[netcore] Implement Assembly.GetExecutingAssembly with stack mark parameter (mono/mono#13903)

* Implement Assembly.GetExecutingAssembly with stack mark parameter

* Address PR feedback

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

5 years ago[netcore] Fix marshalling of ref ptr return types (mono/mono#13914)
Filip Navara [Thu, 11 Apr 2019 08:31:11 +0000 (10:31 +0200)]
[netcore] Fix marshalling of ref ptr return types (mono/mono#13914)

* Fix marshalling of ref ptr return types

* Revert assert -> exception change

Commit migrated from https://github.com/mono/mono/commit/847296f1f0f71468fb08d1c6b48a4a1775f94c5c

5 years agoDo not crash the runtime in System.Reflection.Emit.ILGeneration tests (mono/mono...
Filip Navara [Thu, 11 Apr 2019 08:30:59 +0000 (10:30 +0200)]
Do not crash the runtime in System.Reflection.Emit.ILGeneration tests (mono/mono#13917)

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

5 years agoMerge pull request mono/mono#13959 from filipnavara/link-windows
Johan Lorensson [Thu, 11 Apr 2019 08:18:47 +0000 (04:18 -0400)]
Merge pull request mono/mono#13959 from filipnavara/link-windows

[windows] Link libgcc statically on Windows

Commit migrated from https://github.com/mono/mono/commit/562ac284e4e4705384b129712f8c1fbb897bf69e

5 years agoMerge pull request mono/mono#13946 from lateralusX/lateralusX/merge-icall-hash-maps
Johan Lorensson [Thu, 11 Apr 2019 06:58:59 +0000 (02:58 -0400)]
Merge pull request mono/mono#13946 from lateralusX/lateralusX/merge-icall-hash-maps

Merge icall_hash and icall_hash_foreign into one.

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

5 years agoCleaning exceptions during static constructor loading (mono/mono#13962)
Thays Grazia [Wed, 10 Apr 2019 22:25:49 +0000 (19:25 -0300)]
Cleaning exceptions during static constructor loading (mono/mono#13962)

Cleaning exceptions during static constructor loading

Reset the stack_trace and trace_ips because the type initialization exception is reused.
Fixes mono/mono#13714

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

5 years agoMerge pull request mono/mono#13976 from directhex/another-llvm-symbol
Jo Shields [Wed, 10 Apr 2019 19:46:09 +0000 (15:46 -0400)]
Merge pull request mono/mono#13976 from directhex/another-llvm-symbol

Add another symbol for loadedllvm

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

5 years agoAdd another symbol for loadedllvm
Jo Shields [Wed, 10 Apr 2019 19:45:30 +0000 (15:45 -0400)]
Add another symbol for loadedllvm

Closes https://github.com/mono/mono/issues/13974

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

5 years agoMerge pull request mono/mono#13972 from filipnavara/netcore-nullability
Marek Safar [Wed, 10 Apr 2019 17:08:07 +0000 (19:08 +0200)]
Merge pull request mono/mono#13972 from filipnavara/netcore-nullability

[netcore] Disable nullability-related warnings

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

5 years agoMerge pull request mono/mono#13963 from Dotnet-GitSync-Bot/mirror-merge-10135517
Marek Safar [Wed, 10 Apr 2019 17:07:08 +0000 (19:07 +0200)]
Merge pull request mono/mono#13963 from Dotnet-GitSync-Bot/mirror-merge-10135517

Mirror changes from mono/corefx,coreclr,corert

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

5 years agoMerge pull request mono/mono#13973 from directhex/netcore-pipeline
Jo Shields [Wed, 10 Apr 2019 16:44:50 +0000 (12:44 -0400)]
Merge pull request mono/mono#13973 from directhex/netcore-pipeline

[netcore] Add a Pipeline yaml for Core build

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

5 years agoMerge pull request mono/mono#13961 from directhex/makedist_again
Jo Shields [Wed, 10 Apr 2019 16:08:11 +0000 (12:08 -0400)]
Merge pull request mono/mono#13961 from directhex/makedist_again

[netcore] Fix `make dist`

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

5 years agoMake nullable embedding API's public. (mono/mono#13950)
Johan Lorensson [Wed, 10 Apr 2019 15:29:00 +0000 (11:29 -0400)]
Make nullable embedding API's public. (mono/mono#13950)

Currently we have two nullable API's that will have value in the public
embedding API (already requestsed by users), eliminating the needs to go
from native->managed and back to get nullable information about a type.

mono_class_is_nullable
mono_class_get_nullable_param

This PR moves them from class-internals.h into class.h and mark them
with MONO_API and when needed include GC UNSAFE/SAFE transition.

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

5 years ago[configure] Add failsafe for missing submodules (mono/mono#13957)
Alexander Köplinger [Wed, 10 Apr 2019 13:26:28 +0000 (15:26 +0200)]
[configure] Add failsafe for missing submodules (mono/mono#13957)

GitHub provides a way to download a .zip/.tar.gz of the repository content in their UI, however the archive doesn't contain git submodules.

The mono build then fails with confusing "missing file" errors.

Since GitHub doesn't let us disable the archive download we should at least add some logic to detect this broken case and bail out.

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

5 years agoMerge icall_hash and icall_hash_foreign into one.
lateralusX [Tue, 2 Apr 2019 12:16:20 +0000 (14:16 +0200)]
Merge icall_hash and icall_hash_foreign into one.

icalls registered with mono_add_internal_call, mono_add_internal_call_with_flags
or mono_add_internal_call_internal ended up in two different hash tables
depending if they were "foreign" or not. This caused double lookups in
mono_lookup_internal_call_full. There are also use cases where it could be
interesting to keep additional flags related to the icall, that could be
used by codegen for various optimization.

This PR merge the two hash tables into one and add a flag describing icall
details. The flag could later be extended with additional behaviors going
forward if needed.

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

5 years ago[utils] stub mono_setmmapjit on Win32 and Wasm
Aleksey Kliger [Tue, 9 Apr 2019 15:54:38 +0000 (11:54 -0400)]
[utils] stub mono_setmmapjit on Win32 and Wasm

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

5 years agoDo not use MAP_JIT by default, instead make this something that is toggled by Xamarin...
Miguel de Icaza [Wed, 13 Mar 2019 17:38:29 +0000 (13:38 -0400)]
Do not use MAP_JIT by default, instead make this something that is toggled by Xamarin.Mac which needs it

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

5 years ago[aot] use g_malloc () instead of malloc () (mono/mono#13953)
Bernhard Urban [Tue, 9 Apr 2019 20:25:53 +0000 (22:25 +0200)]
[aot] use g_malloc () instead of malloc () (mono/mono#13953)

[aot] use g_malloc () instead of malloc ()

Unbreaks jemalloc support as it hooks into `g_malloc ()` instead of replacing `malloc ()`.

```
%4  0x000055ee6af0d27b in sigabrt_signal_handler (_dummy=6, _info=0x7ffc7b0c4ff0, context=0x7ffc7b0c4ec0) at mini-posix.c:232
%5  <signal handler called>
%6  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
%7  0x00007f4ae0d73801 in __GI_abort () at abort.c:79
%8  0x000055ee6b2ab6ed in rtree_child_leaf_tryread (elm=0x55ee6b75b028 <je_extents_rtree+704104>, dependent=true) at src/rtree.c:205
%9  0x000055ee6b2ab95f in je_rtree_leaf_elm_lookup_hard (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, init_missing=false) at src/rtree.c:292
%10 0x000055ee6b242f70 in rtree_leaf_elm_lookup (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, init_missing=false) at include/jemalloc/internal/rtree.h:369
%11 0x000055ee6b242fb5 in rtree_read (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true) at include/jemalloc/internal/rtree.h:394
%12 0x000055ee6b2431ee in rtree_szind_slab_read (tsdn=0x7f4ae1f05738, rtree=0x55ee6b6af1c0 <je_extents_rtree>, rtree_ctx=0x7f4ae1f05758, key=94482510772944, dependent=true, r_szind=0x7ffc7b0c6000, r_slab=0x7ffc7b0c6004) at include/jemalloc/internal/rtree.h:446
%13 0x000055ee6b24d468 in ifree (tsd=0x7f4ae1f05738, ptr=0x55ee6c7dfad0, tcache=0x7f4ae1f058f0, slow_path=true) at src/jemalloc.c:2126
%14 0x000055ee6b24de06 in mono_jefree (ptr=0x55ee6c7dfad0) at src/jemalloc.c:2290
%15 0x000055ee6b2c6c68 in monoeg_g_free (ptr=0x55ee6c7dfad0) at gmem.c:83
%16 0x000055ee6adefafa in emit_method_code (acfg=0x7f4ae0986000, cfg=0x7f4ae0ad4e00) at aot-compiler.c:6243
%17 0x000055ee6adf9534 in emit_code (acfg=0x7f4ae0986000) at aot-compiler.c:9704
%18 0x000055ee6ae04a9d in emit_aot_image (acfg=0x7f4ae0986000) at aot-compiler.c:13535
%19 0x000055ee6ae03b7c in mono_compile_assembly (ass=0x7f4ae09a9300, opts=374434303, aot_options=0x7f4ae093c000 "bind-to-runtime-version,outfile=./../../class/lib/build-linux//Microsoft.CodeAnalysis.CSharp.dll.so", global_aot_state=0x7ffc7b0c6438) at aot-compiler.c:13357

```

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

5 years agoLink libgcc statically on Windows
Filip Navara [Tue, 9 Apr 2019 16:52:12 +0000 (18:52 +0200)]
Link libgcc statically on Windows

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

5 years ago[netcore] Runtime nupkg fixes (mono/mono#13934)
Jo Shields [Tue, 9 Apr 2019 15:41:46 +0000 (11:41 -0400)]
[netcore] Runtime nupkg fixes (mono/mono#13934)

We can now build `--with-core=only` on Linux or Mac with the same makefile, and have a functional `make nupkg` rule which attempts to produce a .nupkg of the runtime in the format consumed by core-setup.

Commit migrated from https://github.com/mono/mono/commit/430307e24ba62668a54a77216f6a80b460067307

5 years agoMerge pull request mono/mono#13955 from directhex/more-loadedllvm-magic
Jo Shields [Tue, 9 Apr 2019 15:28:34 +0000 (11:28 -0400)]
Merge pull request mono/mono#13955 from directhex/more-loadedllvm-magic

Make sure mini_method_is_default_method is in loaded LLVM

Commit migrated from https://github.com/mono/mono/commit/6544999e86535ce353e2d5ab6e27c962b1b3bea7

5 years agoMake sure mini_method_is_default_method is in loaded LLVM
Jo Shields [Tue, 9 Apr 2019 14:53:53 +0000 (10:53 -0400)]
Make sure mini_method_is_default_method is in loaded LLVM

mono: symbol lookup error: /usr/lib/libmono-llvm.so: undefined symbol: mini_method_is_default_method

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

5 years agoMerge pull request mono/mono#13928 from lateralusX/lateralusX/use-tls-key-lmf-add...
Johan Lorensson [Tue, 9 Apr 2019 09:26:35 +0000 (05:26 -0400)]
Merge pull request mono/mono#13928 from lateralusX/lateralusX/use-tls-key-lmf-add-windows

Use TLS_KEY_LMF_ADDR on Windows when pusing lmf frame.

Commit migrated from https://github.com/mono/mono/commit/00b8b21e729c3c18838bc331c17124be076026d7

5 years ago[netcore] Allow reflection invocation of methods with ByRef return types (mono/mono...
Filip Navara [Tue, 9 Apr 2019 08:42:18 +0000 (10:42 +0200)]
[netcore] Allow reflection invocation of methods with ByRef return types (mono/mono#13901)

CoreCLR allows reflection on methods with ByRef return types under certain conditions. The PR implementing it is https://github.com/dotnet/coreclr/pull/17639.

Mono already implemented most of it in the marshalling code but artificially blocked it in `ves_icall_InternalInvoke`. I changed the condition for the exception to match the condition in `emit_invoke_call` (marshal-ilgen.c). It's similar to the condition in CoreCLR, but it may not handle byref-like types correctly. It would have to fixed on both places if it turns out to be the case.

The remaining issue is that null references returned in ByRef are not checked and converted to correct exception. It should result in `NullReferenceException` with special message that doesn't get wrapped in `TargetInvocationException`. I put a TODO marker at a place where I think it should be handled, but it's a bit over my head to implement it.

/cc @vargaz

Commit migrated from https://github.com/mono/mono/commit/444946325661fb1b76be77ae8398c3978eaf01c3

5 years agoMerge pull request mono/mono#13930 from lateralusX/lateralusX/add-supported-additiona...
Johan Lorensson [Tue, 9 Apr 2019 08:16:44 +0000 (04:16 -0400)]
Merge pull request mono/mono#13930 from lateralusX/lateralusX/add-supported-additional-defines-windows

Make sure additional supported enable defines ends up in config.h on Windows.

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

5 years ago[merp] Restore non-assertion behavior in debugger-engine.c (mono/mono#13865)
Alexander Kyte [Tue, 9 Apr 2019 02:23:35 +0000 (22:23 -0400)]
[merp] Restore non-assertion behavior in debugger-engine.c (mono/mono#13865)

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

5 years ago[llvm] If a true/false branch of a conditional branch is marked as out-of-line, emit...
Zoltan Varga [Tue, 9 Apr 2019 01:57:44 +0000 (21:57 -0400)]
[llvm] If a true/false branch of a conditional branch is marked as out-of-line, emit an llvm.expect call. (mono/mono#13915)

Commit migrated from https://github.com/mono/mono/commit/69b6667e2fbddaf15fa670b2c4b7ef1a9ddb7f8c

5 years agoMerge pull request mono/mono#13759 from kjpou1/wasm-update-sdk
Larry Ewing [Mon, 8 Apr 2019 18:23:55 +0000 (13:23 -0500)]
Merge pull request mono/mono#13759 from kjpou1/wasm-update-sdk

[wasm] Update to emscripten 1.38.30

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

5 years agoMake sure additional supported enable defines ends up in config.h on Windows.
lateralusX [Mon, 8 Apr 2019 14:59:10 +0000 (16:59 +0200)]
Make sure additional supported enable defines ends up in config.h on Windows.

Commit migrated from https://github.com/mono/mono/commit/03071d5acaa171442d7a65fdc4a877c9d85a9ec1

5 years agoUse TLS_KEY_LMF_ADDR on Windows when pusing lmf frame.
lateralusX [Tue, 2 Apr 2019 12:01:38 +0000 (14:01 +0200)]
Use TLS_KEY_LMF_ADDR on Windows when pusing lmf frame.

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

5 years ago[AOT] fix winaot LLVM profile (mono/mono#13909)
Bernhard Urban [Mon, 8 Apr 2019 14:16:37 +0000 (16:16 +0200)]
[AOT] fix winaot LLVM profile (mono/mono#13909)

[AOT] fix winaot LLVM profile

Regression due to https://github.com/mono/mono/pull/13877

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

5 years ago[jit] Avoid adding a needless zext which confuses abcrem. (mono/mono#13890)
Zoltan Varga [Mon, 8 Apr 2019 13:06:11 +0000 (09:06 -0400)]
[jit] Avoid adding a needless zext which confuses abcrem. (mono/mono#13890)

[jit] Avoid adding a needless zext which confuses abcrem.

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

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

5 years agoRevert "[image] Create MonoImageStorage to own the image raw data (mono/mono#13892...
Alexander Köplinger [Mon, 8 Apr 2019 11:09:46 +0000 (13:09 +0200)]
Revert "[image] Create MonoImageStorage to own the image raw data (mono/mono#13892)" (mono/mono#13916)

This reverts commit mono/mono@a56573fb7c61adc4a0629a540d0ba093c1f951d8.

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

5 years ago[llvm] do not emit safe points for simple methods (mono/mono#13887)
Egor Bogatov [Mon, 8 Apr 2019 08:53:52 +0000 (11:53 +0300)]
[llvm] do not emit safe points for simple methods (mono/mono#13887)

* do not emit sp on method entry for simple methods

* do not emit sp on method entry for simple methods

* address feedback

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

5 years agoReenable working Enum tests
Filip Navara [Sun, 7 Apr 2019 19:01:57 +0000 (21:01 +0200)]
Reenable working Enum tests

Commit migrated from https://github.com/mono/mono/commit/194c27587828223fb863caa863580e986be397b2

5 years ago[netcore] Remove an assertion which is no longer needed.
Zoltan Varga [Sun, 7 Apr 2019 06:23:12 +0000 (02:23 -0400)]
[netcore] Remove an assertion which is no longer needed.

Commit migrated from https://github.com/mono/mono/commit/8170457d4fde93c601a5ee41d621b9cd3f477100

5 years ago[image] Create MonoImageStorage to own the image raw data (mono/mono#13892)
Aleksey Kliger (λgeek) [Sun, 7 Apr 2019 09:23:29 +0000 (05:23 -0400)]
[image] Create MonoImageStorage to own the image raw data (mono/mono#13892)

Create a new data structure: MonoImageStorage.

It is an object that will have the responsibility for the raw data of a
MonoImage.  It has a string key and a refcount that is used to share a
MonoImageStorage between multiple MonoImage objects.

The reason we need this is because the current MonoAssembly/MonoImage design is
broken for multiple domains and (more evidently) it will be broken when we add
AssemblyLoadContext support.  The issue is that a MonoImage may be shared
between multiple domains (or ALCs), but it has a 'references' field which
points to a single other MonoAssembly.

This is a problem because the references of an image may be resolved
differently in different domains (or ALCs).

The eventual solution will be to stop sharing MonoImages based on path name (or
in the case of in-memory images based on a name made up from the address of the
byte blob).

However we still don't want to open the same data more than once (if we're on a
config where we don't have mmap, we malloc some memory and dump the data in
there - we don't want to do that multiple times for the same file).

So the solution is to create this MonoImageStorage object and make it possible
to share it based on path name, but don't give it any responsibilities except
for owning the memory.  It doesn't know anything about metadata or assemblies
or any of that stuff - it just owns a chunk of memory and knows when and how to
free it.

This commit just adds the MonoImageStorage object and wires it up in MonoImage
loading.  There should be no observable behavioral changes from this commit.

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

5 years agoPropagate System.Globalization.Invariant from runtimeconfig.json to GlobalizationMode
Filip Navara [Sat, 6 Apr 2019 16:35:00 +0000 (18:35 +0200)]
Propagate System.Globalization.Invariant from runtimeconfig.json to GlobalizationMode

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

5 years agoUpdate CoreFX / Runtime versions, download the CoreFX binaries and use them for runni...
Filip Navara [Sat, 6 Apr 2019 15:31:35 +0000 (17:31 +0200)]
Update CoreFX / Runtime versions, download the CoreFX binaries and use them for running the tests

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

5 years agoRemove obsolete AOT relocations for code clarity, assuming no need to support old...
Jay Krell [Sun, 7 Apr 2019 06:21:36 +0000 (23:21 -0700)]
Remove obsolete AOT relocations for code clarity, assuming no need to support old AOT images. (mono/mono#13893)

Remove mono_get_throw_exception_by_name declaration.

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

5 years ago[metadata] Fix memory leak for the last iteration of the loop, Coverity mono/mono...
Miguel de Icaza [Sat, 6 Apr 2019 09:46:27 +0000 (05:46 -0400)]
[metadata] Fix memory leak for the last iteration of the loop, Coverity mono/mono#1444258 (mono/mono#13856)

Commit migrated from https://github.com/mono/mono/commit/7116ecaf4eeceed143023352d597e4d09f1dfc95

5 years ago[Coverity] Ensure that we never return -1 from pagesize operation, helps eliminate...
Miguel de Icaza [Sat, 6 Apr 2019 09:41:28 +0000 (05:41 -0400)]
[Coverity] Ensure that we never return -1 from pagesize operation, helps eliminate many false positives (mono/mono#13863)

Commit migrated from https://github.com/mono/mono/commit/8567415aea784cff65c51d5347870a14c2605956

5 years ago[metadata] Handle condition in ftell, Coverity 1307192 (mono/mono#13862)
Miguel de Icaza [Sat, 6 Apr 2019 09:35:07 +0000 (05:35 -0400)]
[metadata] Handle condition in ftell, Coverity 1307192 (mono/mono#13862)

ftell can be a negative value, handle that scenario.

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

5 years ago[netcore] Implement RuntimeImports.RhBulkMoveWithWriteBarrier (mono/mono#13840)
Filip Navara [Sat, 6 Apr 2019 09:26:55 +0000 (11:26 +0200)]
[netcore] Implement RuntimeImports.RhBulkMoveWithWriteBarrier (mono/mono#13840)

* [netcore] Implement RuntimeImports.RhBulkMoveWithWriteBarrier

* Add the actual write barrier to RhBulkMoveWithWriteBarrier

* Rename ves_icall_System_Runtime_RuntimeImports_Memmove_wbarrier to ves_icall_System_Runtime_RuntimeImports_RhBulkMoveWithWriteBarrier

Fixes 15 failures in System.Memory.Tests.

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

5 years ago[netcore] Fix Marshal.IsPinnable regression (mono/mono#13876)
Filip Navara [Sat, 6 Apr 2019 09:21:07 +0000 (11:21 +0200)]
[netcore] Fix Marshal.IsPinnable regression (mono/mono#13876)

Fix regression from https://github.com/mono/mono/pull/13807/files#diff-e881a4d9491559282e7ae2021f8ad3a4R54.

CoreCLR code for reference: https://github.com/dotnet/coreclr/blob/mono/mono@2f4a7564beb6f8c1f4929504ee2221953d25fc39/src/vm/marshalnative.cpp#L276-L278

Fixes `System.Tests.StringTests.Ctor_CharPtr_DoesNotAccessInvalidPage` in `System.Runtime.Tests`.

My understanding is that IsPinnable should return `true` for:
- Any blittable type
- Any array of blittable types
- Any array of primitive types (covers bool[])
- String, Utf8String (handled separately in managed code in Mono)

It should not return `true` for:
- Primitive non-blittable type
- Value types that are not blittable (eg. contain pointers to other GC objects)

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

5 years ago[AOT] remove confusing llcopts flag (mono/mono#13877)
Bernhard Urban [Fri, 5 Apr 2019 20:05:56 +0000 (22:05 +0200)]
[AOT] remove confusing llcopts flag (mono/mono#13877)

[AOT] remove confusing llcopts flag

Introduced by
https://github.com/mono/mono/commit/mono/mono@2eeaf888c1d0a681c8705bd609f76196d8fb82ed

Commit migrated from https://github.com/mono/mono/commit/61100b24e09be5e9ed125d4ac0126ca52f8bcbc5

5 years agoMerge pull request mono/mono#13866 from lambdageek/fix-no-gc-unsafe-dl-fallback-register
Jo Shields [Fri, 5 Apr 2019 19:50:57 +0000 (15:50 -0400)]
Merge pull request mono/mono#13866 from lambdageek/fix-no-gc-unsafe-dl-fallback-register

[mono-dl] Don't do thread state transitions in mono_dl_fallback_register

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

5 years ago[merp] Fix image size reported (mono/mono#13847)
Alexander Kyte [Fri, 5 Apr 2019 19:26:13 +0000 (15:26 -0400)]
[merp] Fix image size reported (mono/mono#13847)

* [merp] Point managed image_size at correct size field

* [merp] Bump merp version number

Fixes mono/mono#13834

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

5 years ago[llvm] Make GOT a typed struct (mono/mono#13803)
Alexander Kyte [Fri, 5 Apr 2019 19:25:09 +0000 (15:25 -0400)]
[llvm] Make GOT a typed struct (mono/mono#13803)

Commit migrated from https://github.com/mono/mono/commit/715d33c46e6d6669fbdadcdf1203f59e5ad4e2f4

5 years ago[interp] Add intrinsics for common object methods (mono/mono#13762)
Vlad Brezae [Fri, 5 Apr 2019 19:10:16 +0000 (22:10 +0300)]
[interp] Add intrinsics for common object methods (mono/mono#13762)

GetHashCode is 2x faster while GetType is 10x faster.

Commit migrated from https://github.com/mono/mono/commit/47a0ad469b3961f75890fcca5bf1b80cc7881f84

5 years ago[netcore] Avoid loading the globalization native lib in invariant mode. (mono/mono...
Zoltan Varga [Fri, 5 Apr 2019 18:48:00 +0000 (14:48 -0400)]
[netcore] Avoid loading the globalization native lib in invariant mode. (mono/mono#13853)

* [netcore] Avoid loading the globalization native lib in invariant mode.

* Fix a c++-ism.

Commit migrated from https://github.com/mono/mono/commit/25157c4ccdbf94a7ade368031aed17e9673cba31

5 years agoRemove -noappdomain and -noshadow too
Filip Navara [Fri, 5 Apr 2019 11:16:45 +0000 (13:16 +0200)]
Remove -noappdomain and -noshadow too

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

5 years agoKeep the xunit parallelization setting at default value to allow 'Xunit.CollectionBeh...
Filip Navara [Fri, 5 Apr 2019 09:54:59 +0000 (11:54 +0200)]
Keep the xunit parallelization setting at default value to allow 'Xunit.CollectionBehavior(DisableTestParallelization = true)' override

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

5 years ago[llvm] Give LLVM noalias info about alloc functions (mono/mono#13801)
Alexander Kyte [Fri, 5 Apr 2019 15:12:34 +0000 (11:12 -0400)]
[llvm] Give LLVM noalias info about alloc functions (mono/mono#13801)

From: https://llvm.org/docs/LangRef.html

```
Furthermore, the semantics of the noalias attribute on return values are stronger than the semantics of the attribute when used on function arguments. On function return values, the noalias attribute indicates that the function acts like a system memory allocation function, returning a pointer to allocated storage disjoint from the storage for any other object accessible to the caller.
```

Think this probably helps LLVM reorder the method calls, telling it that allocating won't return a pointer to something else on the stack.

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

5 years ago[metadata] Don't free_aggregate_modifiers in mono_metadata_free_type (mono/mono#13785)
Aleksey Kliger (λgeek) [Fri, 5 Apr 2019 15:01:24 +0000 (11:01 -0400)]
[metadata] Don't free_aggregate_modifiers in mono_metadata_free_type (mono/mono#13785)

The aggregate modifiers container is owned by a MonoImageSet.  The aggregate
modifiers may be shared by more than one MonoType that happen to need the same
modifiers. (Similar to how generic instantiations are shared)

When the image set is cleaned up the aggregate modifier cleanup will free the
types in the aggregate modifiers container (the call to
free_aggregate_modifiers in mono_metadata_clean_for_image).

With this extra call to free_aggregate_modifiers in mono_metadata_free_type may
cause the same memory to be freed twice.

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

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

5 years agoAdd MONO_PATCH_INFO_TRAMPOLINE_FUNC_ADDR and MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY...
Jay Krell [Fri, 5 Apr 2019 07:43:28 +0000 (00:43 -0700)]
Add MONO_PATCH_INFO_TRAMPOLINE_FUNC_ADDR and MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR. (mono/mono#13794)

* Add MONO_PATCH_INFO_LAZY_FETCH_ADDR and MONO_PATCH_INFO_TRAMP_ADDR.
These are int-based alternatives to MONO_PATCH_INFO_JIT_ICALL_ADDR + sprintf.

This clarifies work to remove the JIT icall hash tables that are used with:
 MONO_PATCH_INFO_JIT_ICALL
 MONO_PATCH_INFO_JIT_ICALL_ADDR
 MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL

making it easier to make those enum-based, indexing a fixed size dense array.

As a related side effect, that could be achieved otherwise,
this fixes apparent leaks.

And clarify MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL slightly, by making
searches for it find one more hit.

That is, those three enums are mostly used with a fixed set of strings.
Except for as in this PR where they are used with indefinite strings.
The removal of the indefinite strings eases replacement of the fixed
set of strings with an enum.

* Bump MONO_AOT_FILE_VERSION.

* PR feedback: Remove unused code and historical commentary.
Also updated PR title with more verbose actual names of the new symbols:
  `MONO_PATCH_INFO_TRAMPOLINE_FUNC_ADDR`
  `MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR`

* Add missing break.

Commit migrated from https://github.com/mono/mono/commit/36c5f3f3704c86ed67673afdfe74268e0337b1f0

5 years ago[netcore] System.Runtime.InteropServices test fixes. (mono/mono#13807)
Zoltan Varga [Fri, 5 Apr 2019 06:13:52 +0000 (02:13 -0400)]
[netcore] System.Runtime.InteropServices test fixes. (mono/mono#13807)

* [netcore] Fix Marshal test failures.

* [netcore] Add exclusions for System.Runtime.InteropServices.Tests.

* [netcore] Make an icall internal.

* Add more test exclusions.

* Address review comments.

Commit migrated from https://github.com/mono/mono/commit/3344bd64c894d20fd13c4b81c4f7e01bc2a62795

5 years ago[interp] Add more netcore intrinsics. (mono/mono#13849)
Zoltan Varga [Fri, 5 Apr 2019 06:13:34 +0000 (02:13 -0400)]
[interp] Add more netcore intrinsics. (mono/mono#13849)

* [interp] Add more netcore intrinsics.

* Address review comments.

* Fix a warning.

Commit migrated from https://github.com/mono/mono/commit/22e2cd87a727188b04bb43c8b73f8edb6531e3e9

5 years agoFix .vscode/c_cpp_properties.json
Alexander Köplinger [Thu, 4 Apr 2019 23:04:12 +0000 (01:04 +0200)]
Fix .vscode/c_cpp_properties.json

Commit migrated from https://github.com/mono/mono/commit/7030a95c84a5a971b3bc6361de27c4c9c055c23b

5 years ago[mono-dl] Don't do thread state transitions in mono_dl_fallback_register
Aleksey Kliger [Thu, 4 Apr 2019 22:09:41 +0000 (18:09 -0400)]
[mono-dl] Don't do thread state transitions in mono_dl_fallback_register

1. it doesn't touch the managed runtime

2. it may be called (arguably it ought to be called only) before the runtime is
initialized (and in particular before the current thread is attached).

Commit migrated from https://github.com/mono/mono/commit/275d1f5d16ae23d8edb071ea82f1893226889aa8

5 years ago[interp] Fix GetFunctionPointer (mono/mono#13708)
Vlad Brezae [Thu, 4 Apr 2019 20:19:50 +0000 (23:19 +0300)]
[interp] Fix GetFunctionPointer (mono/mono#13708)

This method returns a function pointer that can be called with a calli instruction. On interpreter we use a pointer to InterpMethod while on jit we use the native code address. Normally, GetFunctionPointer should return the InterpMethod pointer if called from interp or the native code address if called from jit. Since we don't have any information about the execution engine of the caller, we solve this by intrinsifying all these calls, that happen in the interpreter.

Passing such function pointers between jitted and interp code is probably still unreliable.

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

Commit migrated from https://github.com/mono/mono/commit/474305cbce2eaba12186d61583ab358bc5957abe

5 years agoMerge pull request mono/mono#13858 from kg/disable-llvmjit-on-ci
Jo Shields [Thu, 4 Apr 2019 20:14:54 +0000 (16:14 -0400)]
Merge pull request mono/mono#13858 from kg/disable-llvmjit-on-ci

Disable llvmjit in the packaging test ci lane so we can turn the lane back on

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

5 years ago[DIM] Do not order implemented interfaces (mono/mono#13721)
Thays Grazia [Thu, 4 Apr 2019 18:38:21 +0000 (15:38 -0300)]
[DIM] Do not order implemented interfaces (mono/mono#13721)

This test https://github.com/dotnet/coreclr/blob/mono/mono@1649da12db73c8c07513c9168cb30ec70c310063/tests/src/Regressions/coreclr/20452/twopassvariance.il

On mono we were ordering the list of implemented interfaces and shouldn't do this as it's described on ECMA-335 Section II.12.2.1 and II.12.2.2.
The ordering was removed on ilasm and some changes were needed on metadata either because it's not ordered anymore.

There were two bugs, one on ilasm and other on class initialization on mono.

### ILAsm ###

If we get the .exe generated by .net Framework it doesn't execute on mono without modifications because we ordered the implemented interfaces list by id. And doing that the order defined on source code is ignored.

If we get the .exe generated by Mono it doesn't execute on .net Framework because on IlAsm we order the list and loose the order defined on source code.

The interfaces on metadata before these changes on IlAsm were like this:
```
1: Fooer1 implements class IFoo<class Derived>
2: Fooer1 implements class IFoo<class Base>
3: Fooer2 implements class IFoo<class Base>
4: Fooer2 implements class IFoo<class Derived>
5: Fooer3 implements class IFoo<object>
6: Fooer3 implements class IBar<class Derived>
7: Fooer3 implements class IBaz<class Base>
8: IBar implements class IFoo<!0>
9: IBaz implements class IFoo<!0>
10: Fooer4 implements IQux
11: Fooer4 implements class IBar<class Derived>
12: IQux implements class IFoo<class Base>
13: IQux implements class IFoo<class Derived>
14: Fooer5 implements IQux
15: Fooer5 implements class IBar<class Derived>
16: Fooer6 implements class IBar<class Base>
17: Fooer6 implements class IFoo<class Base>
18: Fooer7 implements class IFoo<class Base>
19: Fooer7 implements class IBar<class Base>
```

And After the changes they follow the definition order which is the same order of IlAsm for .net framework and .net core.
```
1: IBar implements class IFoo<!0>
2: IBaz implements class IFoo<!0>
3: IQux implements class IFoo<class Base>
4: IQux implements class IFoo<class Derived>
5: Fooer1 implements class IFoo<class Base>
6: Fooer1 implements class IFoo<class Derived>
7: Fooer2 implements class IFoo<class Derived>
8: Fooer2 implements class IFoo<class Base>
9: Fooer3 implements class IBaz<class Base>
10: Fooer3 implements class IBar<class Derived>
11: Fooer3 implements class IFoo<object>
12: Fooer4 implements IQux
13: Fooer4 implements class IBar<class Derived>
14: Fooer5 implements class IBar<class Derived>
15: Fooer5 implements IQux
16: Fooer6 implements class IFoo<class Base>
17: Fooer6 implements class IBar<class Base>
18: Fooer7 implements class IBar<class Base>
19: Fooer7 implements class IFoo<class Base>
```

### Mono vtable layout ###

Internally when Mono computes the interface table for each class, it would previously sort the interfaces by `MonoClass:interface_id` which is a unique id assigned (roughly) in load order.  This was incorrect because the order of the interfaces determines the final vtable for the class.  This PR changes the interface table computation so that the interfaces of a single class are ordered in declaration order, following ECMA.

One consequence is that we can no longer use binary search with the interface id as the key to find out if a class implements an interface.  We have to do a linear scan. On the other hand, we expect that the number of interfaces implemented by a single class is small in practice.

This is how the Vtable for Fooer1 and Fooer2 looks like after the changes:
```
*** Vtable for class 'Fooer1' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fd78681db20]
[O][001][INDEX 001] object:GetHashCode () [0x7fd78681daf8]
[O][002][INDEX 002] object:Finalize () [0x7fd78681dad0]
[O][003][INDEX 003] object:Equals (object) [0x7fd78681daa8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fd786503800]
[I][005][INDEX 000] IFoo:Gimme () [0x7fd7865038c0]
Packed interface table for class Fooer1 has size 2
[000][UUID 078][SLOT 004][SIZE 001] interface IFoo[Base]
[001][UUID 079][SLOT 005][SIZE 001] interface IFoo[Derived]
```
and
```
*** Vtable for class 'Fooer2' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fd78681db20]
[O][001][INDEX 001] object:GetHashCode () [0x7fd78681daf8]
[O][002][INDEX 002] object:Finalize () [0x7fd78681dad0]
[O][003][INDEX 003] object:Equals (object) [0x7fd78681daa8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fd7865038c0]
[I][005][INDEX 000] IFoo:Gimme () [0x7fd786503800]
Packed interface table for class Fooer2 has size 2
[000][UUID 079][SLOT 004][SIZE 001] interface IFoo[Derived]
[001][UUID 078][SLOT 005][SIZE 001] interface IFoo[Base]
```

This is how the VTable for Fooer1 and Fooer2 looks like before the changes, as you can see Packed interface table are the same in Fooer1 and Fooer2, so the behavior of both classes was the same:

```
Vtable for class 'Fooer1' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fcf3801d920]
[O][001][INDEX 001] object:GetHashCode () [0x7fcf3801d8f8]
[O][002][INDEX 002] object:Finalize () [0x7fcf3801d8d0]
[O][003][INDEX 003] object:Equals (object) [0x7fcf3801d8a8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fcf37c29880]
[I][005][INDEX 000] IFoo:Gimme () [0x7fcf37c29940]
Packed interface table for class Fooer1 has size 2
[000][UUID 076][SLOT 004][SIZE 001] interface IFoo[Base]
[001][UUID 077][SLOT 005][SIZE 001] interface IFoo[Derived]
```

```
Vtable for class 'Fooer2' at "FINALLY" (size 6)
[O][000][INDEX 000] object:ToString () [0x7fcf3801d920]
[O][001][INDEX 001] object:GetHashCode () [0x7fcf3801d8f8]
[O][002][INDEX 002] object:Finalize () [0x7fcf3801d8d0]
[O][003][INDEX 003] object:Equals (object) [0x7fcf3801d8a8]
[I][004][INDEX 000] IFoo:Gimme () [0x7fcf37c29940]
[I][005][INDEX 000] IFoo:Gimme () [0x7fcf37c29880]
Packed interface table for class Fooer2 has size 2
[000][UUID 076][SLOT 005][SIZE 001] interface IFoo[Base]
[001][UUID 077][SLOT 004][SIZE 001] interface IFoo[Derived]
```

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

5 years ago[llvm] Fix llvm JIT. (mono/mono#13835)
Zoltan Varga [Thu, 4 Apr 2019 13:46:06 +0000 (09:46 -0400)]
[llvm] Fix llvm JIT. (mono/mono#13835)

[llvm] Fix llvm JIT.

<!--
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/aba1bac992971a1784fdf1db9a346bc7a305876c

5 years ago[netcore] Improve support for rare enum types (mono/mono#13825)
Filip Navara [Thu, 4 Apr 2019 09:08:07 +0000 (11:08 +0200)]
[netcore] Improve support for rare enum types (mono/mono#13825)

* [netcore] Improve support for rare enum types (IntPtr, UIntPtr, Single, Double, Char, Boolean backing types)

* Add back Intrinsic attribute

* Update Enum.cs

Commit migrated from https://github.com/mono/mono/commit/9270f159bf33f6f692222375ecf771225d8280b4

5 years ago[netcore] Implement missing Math and MathF methods (mono/mono#13833)
Egor Bogatov [Thu, 4 Apr 2019 08:37:05 +0000 (11:37 +0300)]
[netcore] Implement missing Math and MathF methods (mono/mono#13833)

* Add missing Math(f) methods

* remove extra empty line

Commit migrated from https://github.com/mono/mono/commit/271c4448b440e5f0385f6f2c78679158fa311ce4

5 years ago[interp] Optimize static vtype field access (mono/mono#13769)
Vlad Brezae [Thu, 4 Apr 2019 08:06:19 +0000 (11:06 +0300)]
[interp] Optimize static vtype field access (mono/mono#13769)

We want to avoid calling stackval_to/from methods. Also include the field address in the instruction stream. This makes static vtype field access 10x faster.

Refactor the code a bit.

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

5 years ago[gsharedvt] Fix sizeof opcode (mono/mono#13817)
Vlad Brezae [Wed, 3 Apr 2019 18:26:00 +0000 (21:26 +0300)]
[gsharedvt] Fix sizeof opcode (mono/mono#13817)

[gsharedvt] Fix sizeof opcode

We were setting the stack type by using another global local named ins.

This lead to missing methods in the aot image due to invalid IL. Fixes https://github.com/mono/mono/issues/13479.

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

5 years agoMerge pull request mono/mono#13828 from directhex/loadedllvmaot
Jo Shields [Wed, 3 Apr 2019 18:09:29 +0000 (14:09 -0400)]
Merge pull request mono/mono#13828 from directhex/loadedllvmaot

Add MONO_LLVM_INTERNAL to re-fix LLVM AOT with loadedllvm

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

5 years agoMerge pull request mono/mono#13750 from directhex/test-installed-prefix-mono
Jo Shields [Wed, 3 Apr 2019 17:38:20 +0000 (13:38 -0400)]
Merge pull request mono/mono#13750 from directhex/test-installed-prefix-mono

Add tests to ensure `make install` prefix is functional

Commit migrated from https://github.com/mono/mono/commit/124025fc4de5c1fdcacf80b728fab4a48157b96b

5 years agoAdd MONO_LLVM_INTERNAL to re-fix LLVM AOT with loadedllvm
Jo Shields [Wed, 3 Apr 2019 17:19:57 +0000 (13:19 -0400)]
Add MONO_LLVM_INTERNAL to re-fix LLVM AOT with loadedllvm

Commit migrated from https://github.com/mono/mono/commit/656208c0047eee2d21319ed249f306680b913da7

5 years ago[interp] Add intrinsics for Math operations (mono/mono#13635)
Vlad Brezae [Wed, 3 Apr 2019 16:56:35 +0000 (19:56 +0300)]
[interp] Add intrinsics for Math operations (mono/mono#13635)

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

5 years ago[netcore] Simplify runtime and tests synchronization
Marek Safar [Wed, 3 Apr 2019 13:27:48 +0000 (15:27 +0200)]
[netcore] Simplify runtime and tests synchronization

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

5 years ago[netcore] Bump SDK version
Filip Navara [Tue, 2 Apr 2019 22:15:14 +0000 (00:15 +0200)]
[netcore] Bump SDK version

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

5 years agoRename cabs/cimag/creal to mono_cabs/mono_cimag/mono_creal without macro to rename...
Jay Krell [Wed, 3 Apr 2019 07:26:28 +0000 (00:26 -0700)]
Rename cabs/cimag/creal to mono_cabs/mono_cimag/mono_creal without macro to rename. (mono/mono#13663)

Also make cimag/creal macros for guaranteed inlining -- instead of passing structs by value.
And add spaces before parens to follow coding convention (which is designed
to ease low tech searches for entire words).

This was agreed to when the code was first ported to C++ but got dropped.
The compromise though was to put the defines relatively late to limit their impact.

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

5 years agoMerge pull request mono/mono#13797 from directhex/remove-csc-dim-some-more
Jo Shields [Tue, 2 Apr 2019 18:04:55 +0000 (14:04 -0400)]
Merge pull request mono/mono#13797 from directhex/remove-csc-dim-some-more

Remove csc-dim script, since csc-dim is gone

Commit migrated from https://github.com/mono/mono/commit/688ac23fb69edb61995369d162b90b1bfc73ebb3

5 years ago[netcore] Cleanup + test fixes (mono/mono#13795)
Filip Navara [Tue, 2 Apr 2019 15:49:20 +0000 (17:49 +0200)]
[netcore] Cleanup + test fixes (mono/mono#13795)

Avoid using `wget` since it's not installed on macOS by default.

Commit migrated from https://github.com/mono/mono/commit/02be9aeba324089a46a10a1cecddf40826e71f64