Compare commits

...
6 Commits
6 changed files with 66 additions and 8 deletions

No files matched your search

+6
View File
@@ -111,6 +111,11 @@
#include "icall-def-netcore.h"
#else
ICALL_TYPE(MONOEXT, "BepInEx.MonoExtensions", MONOEXT_1)
HANDLES(MONOEXT_1, "GetFunctionPointerForDelegateInternal2", ves_icall_BepInEx_MonoExtensions_GetFunctionPointerForDelegateInternal2, gpointer, 2, (MonoDelegate, gint32))
ICALL_TYPE(CLR_INTEROP_SYS, "Interop/Sys", CLR_INTEROP_SYS_1)
NOHANDLES(ICALL(CLR_INTEROP_SYS_1, "DoubleToString", ves_icall_Interop_Sys_DoubleToString))
@@ -747,6 +752,7 @@ NOHANDLES(ICALL(GCH_3, "GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAdd
HANDLES(GCH_4, "GetTarget", ves_icall_System_GCHandle_GetTarget, MonoObject, 1, (gpointer))
HANDLES(GCH_5, "GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle, gpointer, 3, (MonoObject, gpointer, gint32))
#if !defined(DISABLE_COM) || defined (HOST_WIN32)
ICALL_TYPE(MARSHAL, "System.Runtime.InteropServices.Marshal", MARSHAL_1)
NOHANDLES(ICALL(MARSHAL_1, "AddRefInternal", ves_icall_System_Runtime_InteropServices_Marshal_AddRefInternal))
+31 -5
View File
@@ -288,9 +288,16 @@ mono_marshal_unlock_internal (void)
mono_marshal_unlock ();
}
// This is a JIT icall, it sets the pending exception (in wrapper) and return NULL on error.
gpointer
mono_delegate_to_ftnptr_impl (MonoDelegateHandle delegate, MonoError *error)
{
return mono_delegate_to_ftnptr_impl_ext(delegate, -1, error);
}
// This is a JIT icall, it sets the pending exception (in wrapper) and return NULL on error.
gpointer
mono_delegate_to_ftnptr_impl_ext (MonoDelegateHandle delegate, gint32 callConv, MonoError *error)
{
gpointer result = NULL;
MonoMethod *method, *wrapper;
@@ -334,7 +341,8 @@ mono_delegate_to_ftnptr_impl (MonoDelegateHandle delegate, MonoError *error)
target_handle = mono_gchandle_new_weakref_from_handle (delegate_target);
}
wrapper = mono_marshal_get_managed_wrapper (method, klass, target_handle, error);
wrapper = mono_marshal_get_managed_wrapper_2 (method, klass, target_handle, callConv, error);
goto_if_nok (error, leave);
MONO_HANDLE_SETVAL (delegate, delegate_trampoline, gpointer, mono_compile_method_checked (wrapper, error));
@@ -4006,6 +4014,13 @@ method_signature_is_blittable (MonoMethodSignature *sig)
return TRUE;
}
MonoMethod *
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle target_handle, MonoError *error)
{
return mono_marshal_get_managed_wrapper_2(method, delegate_klass, target_handle, -1, error);
}
/**
* mono_marshal_get_managed_wrapper:
* Generates IL code to call managed methods from unmanaged code
@@ -4015,7 +4030,7 @@ method_signature_is_blittable (MonoMethodSignature *sig)
* UnamangedCallersOnlyAttribute.
*/
MonoMethod *
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle target_handle, MonoError *error)
mono_marshal_get_managed_wrapper_2 (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle target_handle, gint32 callConv, MonoError *error)
{
MonoMethodSignature *sig, *csig, *invoke_sig;
MonoMethodBuilder *mb;
@@ -4039,9 +4054,10 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
* could be called with different delegates, thus different marshalling
* options.
*/
cache = get_cache (&mono_method_get_wrapper_cache (method)->managed_wrapper_cache, mono_aligned_addr_hash, NULL);
if (!target_handle && (res = mono_marshal_find_in_cache (cache, method)))
if (callConv < 0 && !target_handle && (res = mono_marshal_find_in_cache (cache, method)))
return res;
if (G_UNLIKELY (!delegate_klass)) {
@@ -4136,6 +4152,7 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
/* typed args */
call_conv = *(gint32*)typed_args [0];
/* named args */
for (i = 0; i < num_named_args; ++i) {
CattrNamedArg *narg = &arginfo [i];
@@ -4170,6 +4187,9 @@ mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass,
mono_custom_attrs_free (cinfo);
}
if (callConv > -1)
csig->call_convention = callConv - 1;
mono_marshal_emit_managed_wrapper (mb, invoke_sig, mspecs, &m, method, target_handle);
if (!target_handle) {
@@ -5927,7 +5947,13 @@ ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerIn
gpointer
ves_icall_System_Runtime_InteropServices_Marshal_GetFunctionPointerForDelegateInternal (MonoDelegateHandle delegate, MonoError *error)
{
return mono_delegate_to_ftnptr_impl (delegate, error);
return mono_delegate_to_ftnptr_impl_ext (delegate, -1, error);
}
gpointer
ves_icall_BepInEx_MonoExtensions_GetFunctionPointerForDelegateInternal2 (MonoDelegateHandle delegate, gint32 callConv, MonoError *error)
{
return mono_delegate_to_ftnptr_impl_ext (delegate, callConv, error);
}
MonoBoolean
+6
View File
@@ -444,9 +444,15 @@ mono_marshal_get_runtime_invoke_for_sig (MonoMethodSignature *sig);
MonoMethodSignature*
mono_marshal_get_string_ctor_signature (MonoMethod *method);
gpointer
mono_delegate_to_ftnptr_impl_ext (MonoDelegateHandle delegate, gint32 callConv, MonoError *error);
MonoMethod *
mono_marshal_get_managed_wrapper (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle this_loc, MonoError *exernal_error);
MonoMethod *
mono_marshal_get_managed_wrapper_2 (MonoMethod *method, MonoClass *delegate_klass, MonoGCHandle this_loc, gint32 callConv, MonoError *exernal_error);
gpointer
mono_marshal_get_vtfixup_ftnptr (MonoImage *image, guint32 token, guint16 type);
+15 -3
View File
@@ -930,6 +930,14 @@ addprefix(mini_public_headers ../mini "${mini_public_headers_base}")
set(mini_sources "${CMAKE_CURRENT_BINARY_DIR}/buildver-sgen.h;main-core.c;${mini_common_sources};${arch_sources};${os_sources};${mini_interp_sources};${llvm_sources};${debugger_sources};${llvm_runtime_sources}")
if(LLVM_LIBDIR)
link_directories(${LLVM_LIBDIR})
endif()
if(HOST_DARWIN)
set(OS_LIBS "-framework CoreFoundation" "-framework Foundation")
endif()
add_library(monosgen-objects OBJECT "${eglib_sources};${metadata_sources};${utils_sources};${sgen_sources};${icu_shim_sources};${eventpipe_sources};${mini_sources}")
add_library(monosgen-static STATIC $<TARGET_OBJECTS:monosgen-objects>)
set_target_properties(monosgen-static PROPERTIES OUTPUT_NAME monosgen-2.0)
@@ -942,6 +950,8 @@ install(FILES ${mini_public_headers}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/jit)
if(NOT DISABLE_SHARED_LIBS)
add_library(monosgen SHARED $<TARGET_OBJECTS:monosgen-objects>)
set_target_properties(monosgen PROPERTIES OUTPUT_NAME monosgen-2.0)
target_link_libraries(monosgen ${OS_LIBS} "iconv" ${LLVM_LIBS} ${ICU_LIBS})
install(TARGETS monosgen LIBRARY)
endif()
@@ -979,8 +989,10 @@ add_custom_command(
if(NOT DISABLE_EXECUTABLES)
add_executable(mono-sgen "main-sgen.c")
target_link_libraries(mono-sgen monosgen-static "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS} ${ICU_LIBS})
target_link_libraries(monosgen "-framework CoreFoundation" "-framework Foundation" "iconv" ${LLVM_LIBS} ${ICU_LIBS})
set_target_properties(mono-sgen monosgen PROPERTIES LINK_FLAGS ${ICU_LDFLAGS})
target_link_libraries(mono-sgen monosgen-static ${OS_LIBS} "iconv" ${LLVM_LIBS} ${ICU_LIBS})
target_link_libraries(monosgen ${OS_LIBS} "iconv" ${LLVM_LIBS} ${ICU_LIBS})
if(ICU_LDFLAGS)
set_target_properties(mono-sgen monosgen PROPERTIES LINK_FLAGS ${ICU_LDFLAGS})
endif()
install(TARGETS mono-sgen RUNTIME)
endif()
+5
View File
@@ -130,6 +130,11 @@ class OffsetsTool:
self.target = Target ("TARGET_X86", "", IOS_DEFINES)
self.target_args += ["-arch", "i386"]
self.target_args += ["-isysroot", args.sysroot]
elif "x86_64-apple-darwin10" == args.abi:
require_sysroot (args)
self.target = Target ("TARGET_AMD64", "", IOS_DEFINES)
self.target_args += ["-arch", "x86_64"]
self.target_args += ["-isysroot", args.sysroot]
# watchOS
elif "armv7k-apple-darwin" == args.abi:
+3
View File
@@ -305,6 +305,9 @@ mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type)
}
if ((flags & MONO_MMAP_JIT) && (use_mmap_jit || is_hardened_runtime == 1))
mflags |= MAP_JIT;
/* Patching code on apple silicon seems to cause random crashes without this flag */
if (__builtin_available (macOS 11, *))
mflags |= MAP_JIT;
}
#endif