Commit Graph
37130 Commits
Author SHA1 Message Date
Zoltan Varga 0ee94de6de [wasm] Avoid emitting gsharedvt versions of the Vector<T> simd fallback code, its large and unlikely to be used.
Commit migrated from https://github.com/mono/mono/commit/994aaa7c2bf653ceae7175f1851913de32e0edcd
2018-11-04 23:48:34 -05:00
Zoltan Varga 175e499314 [jit] Implement Vector.IsHardwareAccelerated () as an intrinsics even if SIMD is not enabled to help deadce.
Commit migrated from https://github.com/mono/mono/commit/8e1a4e2702ef483acce136e3462a51163957d02b
2018-11-04 23:47:48 -05:00
Zoltan Varga 96e9e0e918 [aot] Avoid AOTing ref instances of methods with valuetype constraints, they will never be used.
Commit migrated from https://github.com/mono/mono/commit/daf92b9e62a847d521ae314c320d3502fefe217e
2018-11-04 18:09:34 -05:00
Zoltan Varga 517bbf6be9 [runtime] Add a --enable-minimal=assert_messages option to remove assertion messages, only file/line numbers are retained. Enable it for wasm.
Commit migrated from https://github.com/mono/mono/commit/ed19b6eb6fbae9c5ba5d18b9fbfd2e69b9a5269e
2018-11-03 23:19:46 -04:00
Zoltan Varga 4cdfbf7546 [wasm] Restrict the set of methods dedup-ed to a set which works.
Commit migrated from https://github.com/mono/mono/commit/0ea592b81279432acdf20a1dd5b555d57025cc3d
2018-11-03 04:39:37 +01:00
Zoltan Varga 03cc44adc6 [jit] Use mono_method_get_full_name () in a few places since it includes return types.
Commit migrated from https://github.com/mono/mono/commit/52471e886b5ffe3dd9326a5c22817f80f41cfcef
2018-11-03 04:39:14 +01:00
Zoltan Varga 9f3de33d42 [llvm] Fix the build.
Commit migrated from https://github.com/mono/mono/commit/4ba22e2c788cfdda1fa1f28857c4f2e200f03d33
2018-11-01 13:18:56 +01:00
Zoltan Varga 7946d95981 [aot] Add some comments.
Commit migrated from https://github.com/mono/mono/commit/761398d0809527fb992e758ae7207f06087dc206
2018-11-01 03:02:13 +01:00
Zoltan Varga 69d5f73b14 [llvmonly] Rework the handling of direct calls.
Move the allocation of got offsets for calls to a separate pass after all methods have been compiled. This means
that got offsets do not need to be allocated for calls which can be turned into direct calls.


Commit migrated from https://github.com/mono/mono/commit/9960c5b4199543af499a4046ceac0837eaf0324f
2018-10-31 19:55:59 +01:00
Zoltan Varga fed4a23827 [aot] Remove unused got_offset arguments from a few functions. Fix a warning. NFC.
Commit migrated from https://github.com/mono/mono/commit/7ef033cf8dd94624407bd93733304c5654f18c14
2018-10-30 04:29:25 +01:00
Vlad Brezae a92c261fee [interp] Init also vtstack value types when allocated (mono/mono#11425)
Commit migrated from https://github.com/mono/mono/commit/4ab5d5398fd7904b940d9ca46e95700d636deb49
2018-10-29 22:37:52 +02:00
Zoltan Varga f4c42af7bc [wasm] Bitcode code generation improvements (mono/mono#11413)
* [llvm] Rewrite the bitcode get_method () generated method to load the result from a table on wasm instead of a huge
switch statement.

This might be usable on other platforms in the future but having a table full of function pointers might lead to linking
problems.

* [llvm] Make direct calls to jit icalls without wrappers as well.

* [llvm] Export mono_llvm_clear_exception () with G_EXTERN_C, its called from llvm generated code.

* [wasm] Emit target layout/target triple into bitcode files.

* [aot] Allow the decoding of references to icall wrappers, so compiled code can reference them directly using a MONO_PATCH_INFO_METHOD.

* [llvm] Call icall wrappers directly from corlib code in llvmonly mode instead of going through the GOT.

* [llvm] Instance methods without got accesses don't need initialization in llvmonly mode.


Commit migrated from https://github.com/mono/mono/commit/c0da2a5126514ab4136e537e2dea59670df5f0e2
2018-10-29 20:06:01 +01:00
Jay Krell 273ef0e0ce [Coop] Convert ves_icall_System_Environment_InternalSetEnvironmentVariable. (mono/mono#11408)
Commit migrated from https://github.com/mono/mono/commit/985be3e594fed42d2708daaef67fe6e34b409972
2018-10-29 08:46:47 -07:00
Johan Lorensson cdcab10cb0 Add option to integrate msvc build into regular make build. (mono/mono#11343)
* Integrate msvc build into make build system.

Add support to perform msvc build as part of regular make build. By default
msvc build will not automatically be done and needs to be enabled using
--with-msvc argument passed to ./autogen.sh. Doing msvc build as part of
regular make will automatically set MONO_EXECUTABLE to build msvc build
Mono runtime used in BCL and Test build as well as runtime used when running
tests.

* Add support to install msvc build mono runtime.

* Disable --with-msvc argument for none Windows builds.

* Fix VS2015 Build Tools build environment.

* Updated with review feedback switching to --enable-msvc.


Commit migrated from https://github.com/mono/mono/commit/1ec7ac543849ebf1e91aeb47890c91041d3fc27a
2018-10-28 18:18:28 -04:00
Jay Krell 43eba5747b Remove dead mono_signature_get_managed_fmt_string prototype. (mono/mono#11409)
Commit migrated from https://github.com/mono/mono/commit/668933de7f65767d17dcf684f78d2f17824575f9
2018-10-28 18:07:46 -04:00
Jay Krell 9b843ae05a [w32file] Restrict mono_w32file_get_volume_information interface to its actual implementation and usage.
On all platforms, mono_w32file_get_volume_information is only asked for its last parameter.
So replace mono_w32file_get_volume_information with mono_w32file_get_file_system_type that
only takes that parameter.

Commit migrated from https://github.com/mono/mono/commit/7b5cac0539e0dd0555a0f0f2b8467d61bf2980cd
2018-10-28 18:07:13 -04:00
Marek Safar cb268b52a7 [runtime] Fixes threadpool tests not to rely on arbitrary sleep timeout (mono/mono#11348)
Commit migrated from https://github.com/mono/mono/commit/ea967a071845bca2cf31909b5bcfb54ffc0d5810
2018-10-27 23:42:10 +02:00
Jay Krell 3e8e9e3a29 Update some comments. (mono/mono#11382)
Commit migrated from https://github.com/mono/mono/commit/31473ac156b14346d890effdd0c0a2cf0ac622e8
2018-10-27 16:58:12 -04:00
Jay Krell 22ffe01555 Disable flaky tests finalizer-abort.exe, process-stress-2.exe, process-stress-3.exe. (mono/mono#11418)
Commit migrated from https://github.com/mono/mono/commit/c299a9943187eb34b56df80e56175b76efd354fe
2018-10-27 16:49:52 -04:00
Aleksey Kliger (λgeek) a9c5f52a5a [reflection] Implement RuntimeType.IsByRefLike (mono/mono#11111)
* [reflection] Implement RuntimeType.IsByRefLike

* [runtime] Add MonoClass:is_byreflike bit

Not set anywhere yet.

* [custom_attrs] Add mono_class_metadata_foreach_custom_attr

Unlike mono_custom_attrs_from_class_checked, this iterator function iterates
over the metadata without taking the loader lock or constructing class
instances, so it is safe to use during assembly loading or class initialization.

* [class-init] Set is_byreflike from attributes in mono_class_create_from_typedef

* [class-init] Set is_byreflike for generic instances

* [class-init] fail arrays of IsByRefLike elements

* [class-init] Check for ByRefLike struct fields

ByRefLike types only allowed as instance fields of structs that are
themselves ByRefLike.

* [runtime] Disallow instantiating generics with ByRefLike types

Instantiating a generic with a `ref struct` is not allowed.

* [runtime] Disallow instantiating generics with TypedReference

Reverts mono/mono@f457a01416. That was a hack to support
gsharedvt (gsharedvt worked by hijacking TypedReference to instantiate generic
vars since it's a lightly used class) that we no longer rely on (we now
instantiate generic vars by types that are synthesized for purpose).

* [mini] Don't box IsByRefLike types

* [runtime] Disallow boxing IsByRefLike types

* Bump corlib version

* [tests] Test that JIT won't box or instantiate IsByRefLike types

* [metadata] Don't inflate methods with invalid generic arguments

* [metadata] Make mono_is_valid_generic_argument non-static

Make it callable from other translation units.

* [class-init] Check for invalid generic instantiations

Disallow instantiations that contain void, TypedReference or IsByRefLike structs.

* [interp] Don't box IsByRefLike structs


Commit migrated from https://github.com/mono/mono/commit/ab51a8172e7eba2ddf45acae4b53dc8ffd43f69d
2018-10-27 11:03:42 -05:00
Jay Krell 20ca68d5c2 [icalls] Dial back a few functions from HANDLES to NOHANDLES, (mono/mono#11386)
* [icalls] Dial back a few functions from HANDLES to NOHANDLES,
that take/return no objects, nor have error paths.

Commit migrated from https://github.com/mono/mono/commit/12b2b4850494b27aff303f3200e3aa35e6daf650
2018-10-27 07:48:57 -07:00
Jay Krell 7ba0f63016 [Coop] Convert mono_custom_attrs_from_builders. (mono/mono#11394)
Commit migrated from https://github.com/mono/mono/commit/e75c972ef83d3432f926e9a449a3d1a99e6542db
2018-10-27 07:03:35 -07:00
Zoltan Varga 02c18f3ff0 [llvm] Fix passing vtypes received by value as arguments, they need to be copied. Fixes https://github.com/mono/mono/issues/11378. (mono/mono#11389)
Commit migrated from https://github.com/mono/mono/commit/ec1c08afa5744fbaf337b35b2dfa05147fc45d98
2018-10-27 12:42:46 +02:00
Alexander Köplinger c2c5a6668a [profiler] Add xunit xml profiler tests output and allow tests to run from outside the build tree (mono/mono#11383)
We need xunit xml output for Helix.

The new mode which doesn't rely on build tree paths can be enabled by passing the special value "out-of-tree" as the build dir.

Respects the MONO_EXECUTABLE env variable and bases everything off of that.

Also unified run_test and run_test_sgen since we only have sgen nowadays and we only need one.

Commit migrated from https://github.com/mono/mono/commit/73afc0361a56029d837d77e1bde8bb3acc12ea72
2018-10-27 00:32:58 +02:00
Bernhard Urban 391612b94b [interp] throw overflow exception when {float,double}.NaN is converted to an int type (mono/mono#11380)
[interp] throw overflow exception when {float,double}.NaN is converted to an int type

A comparison with NaN is always `false`.



Commit migrated from https://github.com/mono/mono/commit/f8f574ded58bf77a617255f37b9d7d1d44eb076e
2018-10-26 17:45:32 -04:00
Aleksey Kliger (λgeek) 133a9da001 [marshal] Delete unused locals in emit_managed_wrapper_ilgen (mono/mono#11379)
[marshal] Delete unused locals in emit_managed_wrapper_ilgen

`ex_local` and `e_local` were used prior to
https://github.com/mono/mono/commit/mono/mono@b20d5ce1e5d69512242dd42ae6ff1afc2483c16d
in order to store an exception raised by the managed method before passing it
to `ftnptr_eh_callback`.  After that commit, we invoke the callback from the
stack unwinder, rather than from the method wrapper.  As a result both of the
locals are now dead code.


Commit migrated from https://github.com/mono/mono/commit/e522b00d40108832e8f1f93aca662ca6f8050e38
2018-10-26 16:35:26 -04:00
Alexander Köplinger c2ac838225 [profiler] Reenable tests when using hybrid suspend (mono/mono#11402)
They got disabled with https://github.com/mono/mono/commit/mono/mono@282ee4bfd7ea91dc0015891010c71d8bd1421bc8 but now that hybrid suspend is the default on multiple platforms we should reenable them.


Commit migrated from https://github.com/mono/mono/commit/d34dfd46d027eb0a8f4b3ff80bb66242cac327de
2018-10-26 22:23:45 +02:00
Marek Safar b90001a317 [runtime] Disables crashing appdomain-threadpool-unload.exe test (mono/mono#11393)
Commit migrated from https://github.com/mono/mono/commit/16db2720aa5ecc08eecef57fb86fc9ef706ff7f5
2018-10-26 11:45:55 -04:00
Katelyn Gadd b87bb321ec Partially exclude custom modifiers from metadata type equality (mono/mono#11134)
Fixes mono/mono#10945
Reverts fix for mono/mono#6936

https://github.com/mono/mono/issues/10945 appears to have been introduced by https://github.com/mono/mono/commit/mono/mono@9dc6c344ac34a470fa0f4fc411e357f7eaf577fd. Unfortunately it is not possible to revert the commit at this point using git revert, but manually disabling the equality change fixes BinaryFormatter. This should be sufficient to get a lot of the broken roslyn tests working again.

Commit migrated from https://github.com/mono/mono/commit/786f58bf83cb4df61e0caf6fbc44b3d115b2266d
2018-10-26 12:35:12 +02:00
Jay Krell 9d1d438f69 [Coop/icalls] Convert a few, nohandles() a few, cleanup a few. (mono/mono#11355)
* [Coop] Convert ves_icall_System_Object_MemberwiseClone.
[Coop] Convert ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue.
[Coop] Convert ves_icall_MonoField_get_core_clr_security_level.
[Coop] Convert ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor.
[Coop] Convert ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor.
[coop] Remove redundant declarations.
[Coop] Nohandles ves_icall_System_Environment_Exit.
[Coop] Nohandles ves_icall_System_Environment_GetIs64BitOperatingSystem.
[Coop] Nohandles mono_pagesize.
[Coop] Nohandles mono_environment_exitcode_get.
[Coop] Nohandles ves_icall_System_Environment_get_HasShutdownStarted.
[Coop] Nohandles ves_icall_System_Environment_get_Platform.
[Coop] Nohandles ves_icall_System_Environment_get_ProcessorCount.
[Coop] Nohandles ves_icall_System_Environment_get_TickCount.
[Coop] Nohandles mono_environment_exitcode_set.
[Coop] Nohandles ves_icall_System_Reflection_AssemblyName_GetNativeName.
[Coop] Nohandles ves_icall_System_Reflection_AssemblyName_ParseAssemblyName.
[Coop] Nohandles mono_digest_get_public_token.
[Coop] Nohandles ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData.
[icalls] Cleanup ves_icall_System_Environment_get_HasShutdownStarted.
[icalls] Cleanup ves_icall_System_Environment_BroadcastSettingChange.
[icalls] Cleanup ves_icall_IsTransparentProxy.
[icalls] Cleanup ves_icall_Remoting_RemotingServices_GetVirtualMethod.
[icalls] Cleanup ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation.
[icalls] Cleanup ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance.
[icalls] Cleanup ves_icall_RuntimeMethodHandle_GetFunctionPointer.
[icalls] Cleanup ves_icall_System_Configuration_DefaultConfig_get_machine_config_path.
[icalls] Cleanup ves_icall_System_Configuration_InternalConfigurationHost_get_bundled_app_config.
[icalls] Cleanup ves_icall_System_Web_Util_ICalls_get_machine_install_dir.
[icalls] Cleanup ves_icall_get_resources_ptr
[icalls] Cleanup ves_icall_System_Diagnostics_Debugger_IsLogging.
[icalls] Cleanup ves_icall_System_Activator_CreateInstanceInternal.
[icalls] Cleanup ves_icall_MonoMethod_get_base_method.
[icalls] Cleanup ves_icall_MonoMethod_get_name.

* Replace mono_error_ok with is_ok.
* Remove outdated comment.
* Use return_if_nok where applicable.
* Use return_val_if_nok where applicable.
* Use NULL_HANDLE_ARRAY where applicable.

Commit migrated from https://github.com/mono/mono/commit/5b8b0f20ac7c555a3b2d5e436e49a759fd76de5a
2018-10-26 01:41:32 -07:00
Zoltan Varga e5fcf0a5e1 [wasm] WASM work. (mono/mono#11314)
* [wasm] Handle the /dev/random problems by defining 'crypto' in runtime-tests.js instead of in the runtime/library_mono.js.
Print a	stack trace if runtime_invoke () throws	a JS exception.

* [wasm] Add a mono_wasm_setenv () function to the MONO module.

* [wasm] Mark some corlib tests as MultiThreaded/NotWasm.


Commit migrated from https://github.com/mono/mono/commit/c1e21d488af86d70a954e53c90edb23e6d75d797
2018-10-25 17:40:38 -04:00
Jay Krell e7820b8b47 [cxx] Fix WebAssembly/C++ (ICALL_EXPORT) (mono/mono#11359)
Remove ICALL_EXPORT on all implementations.
Add ICALL_EXPORT on two declarations.

ICALL_EXPORT is on declarations, correctly,
  and either isn't needed on implementations, or is incorrect.
On non-handles() implementations, it isn't needed but is ok.
On handles() implementations, it is incorrect.

Add ICALL_EXPORT on mono_object_hash_internal and mono_monitor_exit_internal.

Previously many declarations were missing, which was a reason we put it on implementations.

Commit migrated from https://github.com/mono/mono/commit/8fba63a2a3b214dc2725d977df5cd64ed395fbb9
2018-10-25 13:07:05 -07:00
Neale Ferguson a12cb2896d A couple of missing mono_class_from_mono_type_internal changes (mono/mono#11372)
A couple of missing mono_class_from_mono_type_internal changes

Two instances were missed when mono_class_from_mono_type was changed to mono_class_from_mono_type_internal 


Commit migrated from https://github.com/mono/mono/commit/8e44a7fa0c5d1937f518243a29756fe40389b9b6
2018-10-25 14:35:33 -04:00
Bernhard Urban efab18d916 [interp] fix unused variable warnings (mono/mono#11365)
```
interp/interp.c:2337:17: warning: unused variable 'entry_funcs_static' [-Wunused-variable]
static gpointer entry_funcs_static [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static) };
                ^

interp/interp.c:2338:17: warning: unused variable 'entry_funcs_static_ret' [-Wunused-variable]
static gpointer entry_funcs_static_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (static_ret) };
                ^

interp/interp.c:2339:17: warning: unused variable 'entry_funcs_instance' [-Wunused-variable]
static gpointer entry_funcs_instance [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance) };
                ^

interp/interp.c:2340:17: warning: unused variable 'entry_funcs_instance_ret' [-Wunused-variable]
static gpointer entry_funcs_instance_ret [MAX_INTERP_ENTRY_ARGS + 1] = { INTERP_ENTRY_FUNCLIST (instance_ret) };
                ^

4 warnings generated.
```

Commit migrated from https://github.com/mono/mono/commit/cb467ff359737f5468f7c6104749e34c69f0dc9f
2018-10-25 15:07:45 +02:00
Jay Krell fc62829837 Remove errant character from mono/mono@3bf5c2bd10 that breaks compile. (mono/mono#11360)
Commit migrated from https://github.com/mono/mono/commit/0c229900fe7fcba9b396fd3272dd82fbcb9d9794
2018-10-25 02:38:00 +02:00
Bernhard Urban a3afd00a9a [aot] add unbox_arbitrary_trampoline for fullaot/interp mixed mode (mono/mono#11321)
* [aot] add unbox_arbitrary_trampoline for fullaot/interp mixed mode

On a virtual call where the receiver is a value type, the value type is
boxed at the caller's site, but must be unboxed before passed to the
callee. In FullAOT this happens with the help of the `unbox_trampoline`,
which is attached to the AOT'd assembly for every virtual method with a
value type as receiver, so we have a specific `unbox_trampoline` for
each such `MonoMethod`.

In mixed mode it can happen that an FullAOT'd method is calling such a
method which is _not_ FullAOT compiled, therefore it has to be executed
by the interpreter. We have to insert a trampoline between AOT caller
and interp callee (being a native-to-interp entry), that does the
unboxing and has a configurable target address at run-time. So that:

  AOT caller -> unbox_arbitrary_trampoline -> native-to-interp entry

Note on testing: Tested on three different configurations
* amd64/macos with --full-aot-interp and `make -C mcs/class/corlib TESTNAME=MonoTests.System.ArrayTest.BinarySearch_ArgPassingOrder`. This will be covered soon by https://github.com/mono/mono/pull/11307.
* arm64/linux, same as above.
* arm64/iOS which has a different code path due to trampoline pages being used. Tested with `monotouch-tests` mixed mode (i.e. mscorlib.dll FullAOT, rest is interpreter).

armv7 isn't implemented yet.

* fix llvm aot compiler

* unbox_arbitrary_trampoline support for ARM


Commit migrated from https://github.com/mono/mono/commit/3bf5c2bd10ff05874ad5e94a8ef98eae61484243
2018-10-25 01:20:12 +02:00
Jay Krell 7d5f9f3c40 Remove GetOffsetToStringData (but leave ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData, it is used). (mono/mono#11353)
Commit migrated from https://github.com/mono/mono/commit/1ac2c5218e495f05ef66fee028c97dde78c7e7ce
2018-10-25 01:15:50 +02:00
Aleksey Kliger (λgeek) 8bac61699c [tests] Regression test for mono/mono#11123 (mono/mono#11312)
Loading a type that has a field from an assembly that cannot be loaded should
still leave the type usable for some operations such as IsSubclassOf.

Commit migrated from https://github.com/mono/mono/commit/0c8fbcd9706b7f66e31240bbedc62913b2469ecc
2018-10-25 00:21:24 +02:00
Jay Krell d49076fc1b Stack-based icall parameter handles and only one managed/native transition per icall. (mono/mono#11294)
Handles for icall parameters allocated in managed (but not native), can just be pointers to locals or parameters.

Currently the managed stack is scanned conservatively.
When this changes, there will be metadata provided to find these, so this approach will just keep working and should still be ideal (aside from nohandles or staying in managed).

For ObjIn, use pointer to parameter.
For ObjOut/ObjInOut, the parameter might, though it is far fetched, point to a native frame, which isn't convincing. Therefore for those, use a pointer to a managed volatile local, closer to how handles looked like.
For ValueTypeRef, make the parameter volatile so it is sure to survive.

We use volatile instead of merely address-taken because 1. a hypothetical aggressive whole program compiler/optimizer could see through address-taken (runtime and wrappers and corlib compiled together).  2. ValuetypeRef is even easier to optimize/break because the address-taken is  dead.

FIXME: Tests that exercise every icall, coop and otherwise.
FIXME: Gcstress.

Collateral damage: The one rarely run assert that handles are not out of scope
cannot be so easily implemented so is removed. It might come back though, if we type tag the handles.

Furthermore, the handle stack setup/cleanup can be done in native instead of managed.
Furthermore, the error check can either be done in native instead of managed, or the fast path inlined in the JIT. Here we just move it to native (and inline the fast path in native).

Therefore coop icalls go from 3 + handle-count managed/native transitions, to just always one,  *and* at least some of their handle allocation is exceedingly fast and free of TLS.

The typed handle wrappers change from returning a handle to returning a raw pointer.
Because previously the handle would be allocated in the handle frame setup by the JIT.
Now the JIT doesn't setup a handle frame.

There is a weakreference test that is seemingly very sensitive to stack layout.
For this reason at least, the MonoError is still allocated on the managed side.
 Moving it to native broke the test.
This might also be preferable for the public interface.

Coop icalls retain some costs:
  - The volatile might cost a little -- lack of enregistration.
  - Native code allocating handles.
  - Still TLS access.
  - JIT icalls (vs. metadata-driven) still native-only handle allocation, and still fully manual conversion.
  - Coop icalls that return an object always allocate a handle -- could be more efficient out or inout handle instead, though inout is currently very rare.

Some of this can be further mitigated.
Mainly, the metadata icall signatures could move the "local" handles  to be out parameters, in order for managed to allocate them.

The JIT icalls could have richer signatures than just "ptr" and gain these wrappers, or previous (ref parameters, retyped as handles).

Commit migrated from https://github.com/mono/mono/commit/e8b037642104527bd9b9ba70d502210b9c12d2b8
2018-10-24 09:38:19 -07:00
Zoltan Varga 392564ef6e [jit] Remove unused mono_arch_instrument_prolog ()/epilog () functions. (mono/mono#11304)
Commit migrated from https://github.com/mono/mono/commit/38caaf67b1048273326139b2200f69ad45229638
2018-10-24 12:18:47 -04:00
Aleksey Kliger (λgeek) 51a2c94e28 [wasm] Add missing include (mono/mono#11335)
Fixup for
https://github.com/mono/mono/commit/mono/mono@5e961c6deb27c6bfc46cdba99274bbe02f8f0562

Commit migrated from https://github.com/mono/mono/commit/1680235bda26395b23329e7c8560e261fa511c32
2018-10-23 22:28:55 +02:00
Maxim Lipnin 4b4f89bbbf [Reflection] Fix ParameterInfo's custom modifiers order (mono/mono#11308)
* [Reflection] Reverse custom modifiers order in ParameterInfo's  GetRequiredCustomModifiers and GetOptionalCustomModifiers methods to follow NetFX/CoreFX behavior.

* Move reversing custom modifiers from managed code to native one.

* Small refactoring

* Disable System.Reflection.Emit related test on Full AOT mode.


Commit migrated from https://github.com/mono/mono/commit/5392af120bf306dfe71839086deab5c468e0ee42
2018-10-23 19:08:48 +02:00
Aleksey Kliger (λgeek) 28f9d7d641 [marshal] Emit GC Safe transitions around foreign internal calls. (mono/mono#11183)
* [threads] Make mono_add_internal_call external only

The runtime should use mono_add_internal_call_internal or
mono_add_internal_call_with_flags.

The thread suspend mechanism needs to know if an icall is added via the legacy
mono_add_internal_call API (which is not coop-aware, and so the registered
icalls must run in GC Safe mode), or if it is added by the runtime or by a
cooperative client (currently either the profiler or the System.Native PAL)
which knows to add GC transitions and safepoints and not to block indefinitely.

* [marshal] Factor out GCSafeTransitionBuilder

Make a local builder for creating the GC Safe transition calls for a method wraper.

* [sgen] Add coop GC transitions in mono_gc_toggleref_add

Also mark it external only. It's not used inside the runtime.

* [marshal] Emit GC Safe transitions around foreign icalls.

A foreign icall is added using mono_add_internal_call and that is not coop GC
aware.  (The runtime uses mono_add_internal_call_with_flags or
mono_add_internal_call_internal)

Under hybrid suspend, foreign icalls will run in GC Safe mode and transition to
GC Unsafe only when the call back into the runtime or invoke managed code.

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

* [cxx] function type overloads for mono_add_internal_call_internal

and mono_add_internal_call_with_flags

* [runtime] Add new API call mono_dangerous_add_raw_internal_call

Under hybrid suspend, this adds an icall that is assumed to run in GC Unsafe
mode.  As such it has additional requirements for correct operation: it must
not run loops without periodically polling the runtime, and it must not perform
blocking operations such as blocking I/O or taking locks without manually
switching to GC Safe mode.


Commit migrated from https://github.com/mono/mono/commit/5e961c6deb27c6bfc46cdba99274bbe02f8f0562
2018-10-23 11:42:45 -05:00
Alexander Kyte ee1454b524 [crash] Add mono_crash uploader for Sentry (mono/mono#10840)
* [crash] Report which thread was crashing

* [crash] Added upload-to-sentry tool

* [crash] Add sentry uploader step to telemetry


Commit migrated from https://github.com/mono/mono/commit/109563930d6559e3ade2c8f652f21574ea43ad1d
2018-10-23 17:24:26 +02:00
Jay Krell 7af8d9ec92 Remove two accidentally added functions from old version of a commited PR. (mono/mono#11289)
Commit migrated from https://github.com/mono/mono/commit/c1e5e1d395350b61226b1d543f653cf21cea2b3b
2018-10-22 15:29:48 -07:00
Jay Krell 95fc0f66aa [coop] Transition all functions in object.h to MONO_RT_EXTERNAL_ONLY (mono/mono#11188)
In general this is achieved by renaming mono_foo to mono_foo_internal,
and mono_foo_bar calls mono_foo_bar_internal, possibly adding a GC mode change
to mono_foo_bar and removing from mono_foo_bar_internal.

We can also consider other names like m_foo_bar, mi_foo_bar, m.foo_bar, m->foo_bar, m::foo_bar, using mi = mono_internal; mi::foo, foo.bar(), etc.

* [test] Report dlsym failure with an assertion failure and give the symbol.

* Compilation of external-only.c/.o needs special care.
Because it is dead code, except for exports, the linker does not necessarily eagerly look into it (.o within .a), and export anything. This is the usual behavior of Windows linker. Unix linker I guess it varies between programs and shared libraries, but it was observed and broke a test, and a small case was constructed to demonstrate the behavior (i.e. where the dlsym assert is added), even though I assumed the opposite -- so must be program vs. sharedlibrary.

Therefore, we `#include external-only.c` in object.c.

Longer term we should probably use Windows .def files and their Unix equivalent, and/or be sure to list external-only.o directly on the link command line, instead of burying it in a static library.

.def files were used in the past and have other advantages/differences.

Other than guaranteeably reaching into .a/.lib files to find exports, they also export on NT/x86 as plain "mono_foo" instead of "_mono_foo", easing portability of LoadLibrary / GetProcAddress.
The loss of the x86 C name mangling *could* be viewed as a loss, of a tiny amount of safety.

They also make declspec(dllimport) and declspec(dllexport) both pointless, at least for C functions -- dllimport remains significant for data and C++ (no need to list mangled names in .def file), and to microoptimize one instruction out of some calls on non-LTCG builds.


Commit migrated from https://github.com/mono/mono/commit/3c74df566776f468366d96dd164dd1a6b3d780cc
2018-10-22 14:03:05 -07:00
Johan Lorensson 6a81eee0e1 Windows BTLS assembler build support (cygwin/msvc). (mono/mono#11234)
* Add support for BTLS assembler build on Windows (cygwin/msvc).

Building BTLS with assembler support on Windows requires several
additional build tools (except cmake) for both cygwin/msvc builds.
On cygwin, perl and yasm will be needed and on msvc, ninja, perl
and yasm. On msvc builds BTLS doesn’t support Visual Studio generator
when building with assembler support, so this commit adds support for
ninja build system covering that scenario. This commit adds support for
auto detection of needed build tools and enable assembler builds if all
needed tools have been identified as available. Commit also fixes the
execution of msbuild on CI to just use the original PATH variable instead
of the cygwin PATH to make sure correct version of identified build tools
gets used (Windows version of git, ninja, perl and yasm). Both cygwin and
msvc build will use nasm compiler (through use of yasm) since generated
assembler won’t compile with mingw’s gcc version.

* Bump BTLS commit.

* Fix a couple of warnings on BTLS build.

* Fix failing certificate import test using BTLS on Windows.

Mono BTLS library assumes all passwords are ANSI encoded strings since
SafePasswordHandle gets passed directly through pinvokes. This is only true for
SafePasswordHandle implemented on Unix:es. On Windows, SafePasswordHandle stores
passwords as Unicode, most likely due to Windows Crypto API accepting Unicode
passwords. When using BTLS on Windows this difference submerged since passwords
passed to BTLS will be Unicode encoded failing the decryption of PCKS12 structure.

Keeping the pattern already in place, passing SafePasswordHandler all the way
through pinvokes, the needed conversion will be done just before calling into OpenSSL
library as part of mono's BTLS library adapter.


Commit migrated from https://github.com/mono/mono/commit/f2d67cd299e7730819f6838b77de8a061621cce1
2018-10-22 15:58:52 -04:00
Jay Krell 48f2d906f7 Fix warnings about unprototyped icalls and duplicate typedefs. (mono/mono#11298)
Commit migrated from https://github.com/mono/mono/commit/ab17f4555d080bb07e668ad6ab00368cfbb91000
2018-10-22 11:03:06 -07:00
Alexis Christoforides bf11589445 [class] Ensure 'cast_class' is initialized for array type classes. (mono/mono#11268)
* [class] Ensure 'cast_class' is initialized for array type classes.

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

Background: Monoclass:cast_class is used internally to allow for some interfaces to be assignable to each other if they share a "storage class" instead of the class's element class. This is used to i.e. implement IList<ulong> being assignable from IList<long> (IList<ulong> has cast_class=long)

Consider a GenericClass<T> with a T[] field. On instantiation with e.g. GenericClass<ulong> , the ulong[] array class will be generated. As above, ulong[] has cast_class=long
When mono_class_init() is called on an array class, its element_class is also initialized.
If GenericClass<T>:Method() uses any type/subtype checking (e.g. if (field is double[]) ), those may attempt to use cast_class, which is not ensured as initialized.

* Fix typo

Co-Authored-By: alexischr <[email protected]>


Commit migrated from https://github.com/mono/mono/commit/412d35bd7914a71099af7af9846a38fceebd9281
2018-10-22 13:16:11 -04:00
Zoltan Varga a04adc06b5 [jit] Profiler argument handling changes (mono/mono#10885)
* [jit] Add support for accessing method arguments in the profiler in llvmonly mode, by generating code to store them into the MonoProfilerCallContext.args array.

* [jit] Use ctx->args instead of ctx->context for accessing arguments in the profiler.

* Update after review comments.

* [jit] Switch --trace to use the profiler infrastructure.

* Fix a rebase problem.

* Fix c++ failures.


Commit migrated from https://github.com/mono/mono/commit/2b029b3df4a1816880e3f02bacd35cf9a0835e4e
2018-10-22 02:20:39 +02:00