diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2021-11-20 00:37:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 00:37:14 +0300 |
commit | 0339fe117122821856d94dcaa0b08ab966b7ecb2 (patch) | |
tree | fb7472e199222f8819ea14f194d895141fe9c936 /mono | |
parent | f11a3a4bbc36b2a18af0077cc53e7cee517615f7 (diff) |
Remove netcore sources and arcade eng/common files (#21315)
They are no longer needed here.
Diffstat (limited to 'mono')
112 files changed, 19 insertions, 9240 deletions
diff --git a/mono/Makefile.am b/mono/Makefile.am index 7e3be9d7047..257c5bb2209 100644 --- a/mono/Makefile.am +++ b/mono/Makefile.am @@ -12,20 +12,9 @@ if MONO_NATIVE native_dirs = native endif -if ENABLE_NETCORE -btls_dirs = -managed_unit_test_dirs = -native_unit_test_dirs = -culture_dirs = -else managed_unit_test_dirs = tests native_unit_test_dirs = unit-tests culture_dirs = culture -endif - -if ENABLE_NETCORE -SUBDIRS = eglib arch utils sgen zlib metadata mini profiler $(native_unit_test_dirs) -else if CROSS_COMPILING SUBDIRS = $(btls_dirs) $(culture_dirs) eglib arch utils cil zlib $(sgen_dirs) metadata mini dis profiler $(native_dirs) @@ -36,6 +25,5 @@ else SUBDIRS = $(btls_dirs) $(culture_dirs) eglib arch utils cil zlib $(sgen_dirs) metadata mini dis $(managed_unit_test_dirs) $(native_unit_test_dirs) benchmark profiler $(native_dirs) endif endif -endif DIST_SUBDIRS = btls $(culture_dirs) native eglib arch utils cil zlib $(sgen_dirs) metadata mini dis $(managed_unit_test_dirs) $(native_unit_test_dirs) benchmark profiler diff --git a/mono/culture/locales.c b/mono/culture/locales.c index ca0fbd21e9d..005ccd9cf28 100644 --- a/mono/culture/locales.c +++ b/mono/culture/locales.c @@ -16,7 +16,6 @@ #include <config.h> -#if !ENABLE_NETCORE #include <glib.h> #include <string.h> @@ -791,4 +790,3 @@ ves_icall_System_Text_Normalization_load_normalization_resource (guint8 **argPro #endif } -#endif /* !ENABLE_NETCORE */ diff --git a/mono/culture/w32process-unix-language.c b/mono/culture/w32process-unix-language.c index da8a4e6c452..e9f8d403a5d 100644 --- a/mono/culture/w32process-unix-language.c +++ b/mono/culture/w32process-unix-language.c @@ -8,7 +8,7 @@ #include <mono/utils/mono-publib.h> #include <mono/metadata/w32process-internals.h> -#if !defined(ENABLE_NETCORE) && !defined(DISABLE_PROCESSES) +#if !defined(DISABLE_PROCESSES) static guint32 copy_lang (gunichar2 *lang_out, guint32 lang_len, const gchar *text) @@ -791,6 +791,6 @@ mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 la return copy_lang (lang_out, lang_len, name); } -#endif /* ENABLE_NETCORE && DISABLE_PROCESSES */ +#endif /* !defined(DISABLE_PROCESSES) */ MONO_EMPTY_SOURCE_FILE (culture_w32_process_unix_language); diff --git a/mono/eglib/glib.h b/mono/eglib/glib.h index 7bdace935e9..dbcc3997eff 100644 --- a/mono/eglib/glib.h +++ b/mono/eglib/glib.h @@ -959,14 +959,6 @@ GUnicodeBreakType g_unichar_break_type (gunichar c); #define g_assert_not_reached() G_STMT_START { mono_assertion_message_unreachable (__FILE__, __LINE__); eg_unreachable(); } G_STMT_END -#if ENABLE_NETCORE -#define g_assert_netcore() /* nothing */ -#define g_assert_not_netcore() g_assert (!"This function should only be called on mono-notnetcore.") -#else -#define g_assert_netcore() g_assert (!"This function should only be called on mono-netcore.") -#define g_assert_not_netcore() /* nothing */ -#endif - /* f is format -- like printf and scanf * Where you might have said: * if (!(expr)) diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am index 45392bbed42..d033b460270 100644 --- a/mono/metadata/Makefile.am +++ b/mono/metadata/Makefile.am @@ -129,41 +129,7 @@ libmonoruntime_support_la_SOURCES = support.c libmonoruntime_support_la_LDFLAGS = $(Z_LIBS) libmonoruntime_support_la_CFLAGS = $(filter-out @CXX_REMOVE_CFLAGS@, @CFLAGS@) @ZLIB_CFLAGS@ -if ENABLE_NETCORE -if HAVE_SYS_ICU - -# symlink ICU sources to a local dir so automake puts intermediates into the target-specific folder -icushim/%.c: @ICU_SHIM_PATH@/%.c - $(LN_S) $^ $@ - -shim_libraries = libmonoruntime-shimglobalization.la - -nodist_libmonoruntime_shimglobalization_la_SOURCES = \ - icushim/pal_calendarData.c \ - icushim/pal_casing.c \ - icushim/pal_collation.c \ - icushim/pal_idna.c \ - icushim/pal_locale.c \ - icushim/pal_localeNumberData.c \ - icushim/pal_localeStringData.c \ - icushim/pal_normalization.c \ - icushim/pal_timeZoneInfo.c \ - icushim/entrypoints.c - -libmonoruntime_shimglobalization_la_CFLAGS = @ICU_CFLAGS@ -I$(top_srcdir)/../libraries/Native/Unix/System.Globalization.Native/ -I$(top_srcdir)/../libraries/Native/Unix/Common/ - -if STATIC_ICU -nodist_libmonoruntime_shimglobalization_la_SOURCES += icushim/pal_icushim_static.c -else -nodist_libmonoruntime_shimglobalization_la_SOURCES += icushim/pal_icushim.c -endif # STATIC_ICU - -endif # HAVE_SYS_ICU -endif # ENABLE_NETCORE - -if !ENABLE_NETCORE culture_libraries = ../culture/libmono-culture.la -endif # # This library contains the icall tables if the runtime was configured with --disable-icall-tables @@ -297,7 +263,6 @@ common_sources = \ loaded-images-internals.h \ loaded-images.c \ loaded-images-global.c \ - loaded-images-netcore.c \ locales.h \ lock-tracer.c \ lock-tracer.h \ @@ -460,12 +425,12 @@ if !ENABLE_MSVC_ONLY libmonoruntime_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources) # Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342. -libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) $(GLOBALIZATION_SHIM_DEFINES) @CXX_ADD_CFLAGS@ +libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES) @CXX_ADD_CFLAGS@ libmonoruntime_la_LIBADD = libmonoruntime-config.la $(culture_libraries) $(support_libraries) $(shim_libraries) libmonoruntimesgen_la_SOURCES = $(common_sources) $(icall_tables_sources) $(ilgen_sources) $(gc_dependent_sources) $(sgen_sources) # Add CXX_ADD_CFLAGS per-library until/unless https://github.com/dotnet/corefx/pull/31342. -libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) $(GLOBALIZATION_SHIM_DEFINES) @CXX_ADD_CFLAGS@ +libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES) @CXX_ADD_CFLAGS@ libmonoruntimesgen_la_LIBADD = libmonoruntime-config.la $(culture_libraries) $(support_libraries) $(shim_libraries) endif # !ENABLE_MSVC_ONLY diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 92888ed7863..f2d62d217a6 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -93,18 +93,11 @@ typedef struct gchar *filename; } RuntimeConfig; -#ifndef ENABLE_NETCORE static gunichar2 process_guid [36]; static gboolean process_guid_set = FALSE; -#endif static gboolean no_exec = FALSE; -#ifdef ENABLE_NETCORE -static int n_appctx_props; -static gunichar2 **appctx_keys; -static gunichar2 **appctx_values; -#endif static const char * mono_check_corlib_version_internal (void); @@ -135,21 +128,13 @@ mono_domain_asmctx_from_path (const char *fname, MonoAssembly *requesting_assemb static void add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht); -#if ENABLE_NETCORE - -static void -add_assembly_to_alc (MonoAssemblyLoadContext *alc, MonoAssembly *ass); - -#endif -#ifndef ENABLE_NETCORE static MonoAppDomainHandle mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHandle setup, MonoError *error); static MonoDomain * mono_domain_create_appdomain_checked (char *friendly_name, char *configuration_file, MonoError *error); -#endif static void mono_context_set_default_context (MonoDomain *domain); @@ -161,20 +146,9 @@ static MonoLoadFunc load_function = NULL; /* Lazy class loading functions */ static GENERATE_GET_CLASS_WITH_CACHE (assembly, "System.Reflection", "Assembly"); -#ifdef ENABLE_NETCORE -static GENERATE_GET_CLASS_WITH_CACHE (app_context, "System", "AppContext"); -#endif -#ifndef ENABLE_NETCORE GENERATE_GET_CLASS_WITH_CACHE (appdomain, MONO_APPDOMAIN_CLASS_NAME_SPACE, MONO_APPDOMAIN_CLASS_NAME); GENERATE_GET_CLASS_WITH_CACHE (appdomain_setup, MONO_APPDOMAIN_SETUP_CLASS_NAME_SPACE, MONO_APPDOMAIN_SETUP_CLASS_NAME); -#else -MonoClass* -mono_class_get_appdomain_class (void) -{ - return mono_defaults.object_class; -} -#endif static MonoDomain * @@ -335,36 +309,28 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT mono_install_assembly_search_hook_v2 (mono_domain_assembly_postload_search, GUINT_TO_POINTER (FALSE), FALSE, TRUE, FALSE); mono_install_assembly_load_hook_v2 (mono_domain_fire_assembly_load, NULL, FALSE); -#ifndef ENABLE_NETCORE // refonly hooks mono_install_assembly_preload_hook_v2 (mono_domain_assembly_preload, GUINT_TO_POINTER (TRUE), TRUE, FALSE); mono_install_assembly_search_hook_v2 (mono_domain_assembly_search, GUINT_TO_POINTER (TRUE), TRUE, FALSE, FALSE); mono_install_assembly_search_hook_v2 (mono_domain_assembly_postload_search, GUINT_TO_POINTER (TRUE), TRUE, TRUE, FALSE); mono_install_assembly_asmctx_from_path_hook (mono_domain_asmctx_from_path, NULL); -#endif mono_thread_init (start_cb, attach_cb); if (!mono_runtime_get_no_exec ()) { MonoClass *klass; -#ifndef ENABLE_NETCORE klass = mono_class_get_appdomain_setup_class (); MonoAppDomainSetupHandle setup; setup = MONO_HANDLE_CAST (MonoAppDomainSetup, mono_object_new_pinned_handle (domain, klass, error)); goto_if_nok (error, exit); -#endif klass = mono_class_get_appdomain_class (); ad = MONO_HANDLE_CAST (MonoAppDomain, mono_object_new_pinned_handle (domain, klass, error)); goto_if_nok (error, exit); -#ifndef ENABLE_NETCORE MONO_HANDLE_SETVAL (ad, data, MonoDomain*, domain); -#endif domain->domain = MONO_HANDLE_RAW (ad); -#ifndef ENABLE_NETCORE domain->setup = MONO_HANDLE_RAW (setup); -#endif } mono_thread_internal_attach (domain); @@ -388,16 +354,10 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT mono_gc_init (); /* contexts use GC handles, so they must be initialized after the GC */ -#ifndef ENABLE_NETCORE mono_context_init_checked (domain, error); goto_if_nok (error, exit); mono_context_set_default_context (domain); -#endif -#ifdef ENABLE_NETCORE - if (!mono_runtime_get_no_exec ()) - mono_runtime_install_appctx_properties (); -#endif mono_network_init (); mono_console_init (); @@ -608,7 +568,6 @@ mono_runtime_quit_internal (void) quit_function (mono_get_root_domain (), NULL); } -#ifndef ENABLE_NETCORE /** * mono_domain_create_appdomain: @@ -644,7 +603,6 @@ mono_domain_create_appdomain_checked (char *friendly_name, char *configuration_f error_init (error); MonoDomain *result = NULL; -#ifndef ENABLE_NETCORE MonoClass *klass = mono_class_get_appdomain_setup_class (); MonoAppDomainSetupHandle setup = MONO_HANDLE_CAST (MonoAppDomainSetup, mono_object_new_handle (mono_domain_get (), klass, error)); goto_if_nok (error, leave); @@ -656,14 +614,9 @@ mono_domain_create_appdomain_checked (char *friendly_name, char *configuration_f config_file = MONO_HANDLE_NEW (MonoString, NULL); } MONO_HANDLE_SET (setup, configuration_file, config_file); -#endif MonoAppDomainHandle ad; -#ifndef ENABLE_NETCORE ad = mono_domain_create_appdomain_internal (friendly_name, setup, error); -#else - ad = MONO_HANDLE_CAST (MonoAppDomain, NULL_HANDLE); -#endif goto_if_nok (error, leave); result = mono_domain_from_appdomain_handle (ad); @@ -671,7 +624,6 @@ leave: HANDLE_FUNCTION_RETURN_VAL (result); } -#endif /** * mono_domain_set_config: @@ -688,7 +640,6 @@ leave: void mono_domain_set_config (MonoDomain *domain, const char *base_dir, const char *config_file_name) { -#ifndef ENABLE_NETCORE HANDLE_FUNCTION_ENTER (); MONO_ENTER_GC_UNSAFE; ERROR_DECL (error); @@ -696,12 +647,8 @@ mono_domain_set_config (MonoDomain *domain, const char *base_dir, const char *co mono_error_cleanup (error); MONO_EXIT_GC_UNSAFE; HANDLE_FUNCTION_RETURN (); -#else - g_assert_not_reached (); -#endif } -#ifndef ENABLE_NETCORE gboolean mono_domain_set_config_checked (MonoDomain *domain, const char *base_dir, const char *config_file_name, MonoError *error) { @@ -717,9 +664,7 @@ mono_domain_set_config_checked (MonoDomain *domain, const char *base_dir, const leave: return is_ok (error); } -#endif -#ifndef ENABLE_NETCORE static MonoAppDomainSetupHandle copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetupHandle setup, MonoError *error) { @@ -781,9 +726,7 @@ copy_app_domain_setup (MonoDomain *domain, MonoAppDomainSetupHandle setup, MonoE leave: HANDLE_FUNCTION_RETURN_REF (MonoAppDomainSetup, result); } -#endif -#ifndef ENABLE_NETCORE static MonoAppDomainHandle mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHandle setup, MonoError *error) { @@ -856,7 +799,6 @@ mono_domain_create_appdomain_internal (char *friendly_name, MonoAppDomainSetupHa leave: HANDLE_FUNCTION_RETURN_REF (MonoAppDomain, result); } -#endif /** * mono_domain_has_type_resolve: @@ -871,9 +813,6 @@ mono_domain_has_type_resolve (MonoDomain *domain) if (!domain->domain) return FALSE; -#ifdef ENABLE_NETCORE - return TRUE; -#else MonoObject *o; MONO_STATIC_POINTER_INIT (MonoClassField, field) @@ -885,7 +824,6 @@ mono_domain_has_type_resolve (MonoDomain *domain) mono_field_get_value_internal ((MonoObject*)(domain->domain), field, &o); return o != NULL; -#endif } /** @@ -917,13 +855,8 @@ mono_domain_try_type_resolve (MonoDomain *domain, char *name, MonoObject *typebu goto_if_nok (error, exit); ret = mono_domain_try_type_resolve_name (domain, NULL, name_handle, error); } else { -#ifndef ENABLE_NETCORE MONO_HANDLE_DCL (MonoObject, typebuilder); ret = mono_domain_try_type_resolve_typebuilder (domain, MONO_HANDLE_CAST (MonoReflectionTypeBuilder, typebuilder), error); -#else - // TODO: make this work on netcore when working on SRE.TypeBuilder - g_assert_not_reached (); -#endif } exit: @@ -931,58 +864,6 @@ exit: HANDLE_FUNCTION_RETURN_OBJ (ret); } -#ifdef ENABLE_NETCORE -MonoReflectionAssemblyHandle -mono_domain_try_type_resolve_name (MonoDomain *domain, MonoAssembly *assembly, MonoStringHandle name, MonoError *error) -{ - MonoObjectHandle ret; - MonoReflectionAssemblyHandle assembly_handle; - - HANDLE_FUNCTION_ENTER (); - - MONO_STATIC_POINTER_INIT (MonoMethod, method) - - static gboolean inited; - // avoid repeatedly calling mono_class_get_method_from_name_checked - if (!inited) { - ERROR_DECL (local_error); - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - method = mono_class_get_method_from_name_checked (alc_class, "OnTypeResolve", -1, 0, local_error); - mono_error_cleanup (local_error); - inited = TRUE; - } - - MONO_STATIC_POINTER_INIT_END (MonoMethod, method) - - if (!method) - goto return_null; - - g_assert (domain); - g_assert (MONO_HANDLE_BOOL (name)); - - if (mono_runtime_get_no_exec ()) - goto return_null; - - if (assembly) { - assembly_handle = mono_assembly_get_object_handle (domain, assembly, error); - goto_if_nok (error, return_null); - } - - gpointer args [2]; - args [0] = assembly ? MONO_HANDLE_RAW (assembly_handle) : NULL; - args [1] = MONO_HANDLE_RAW (name); - ret = mono_runtime_try_invoke_handle (method, NULL_HANDLE, args, error); - goto_if_nok (error, return_null); - goto exit; - -return_null: - ret = NULL_HANDLE; - -exit: - HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret)); -} -#else /** * mono_class_get_appdomain_do_type_resolve_method: * @@ -1102,7 +983,6 @@ return_null: exit: HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret)); } -#endif /** * mono_domain_owns_vtable_slot: @@ -1131,7 +1011,6 @@ mono_domain_set_fast (MonoDomain *domain, gboolean force) return TRUE; } -#ifndef ENABLE_NETCORE MonoObjectHandle ves_icall_System_AppDomain_GetData (MonoAppDomainHandle ad, MonoStringHandle name, MonoError *error) { @@ -1201,7 +1080,6 @@ ves_icall_System_AppDomain_SetData (MonoAppDomainHandle ad, MonoStringHandle nam mono_domain_unlock (add); } -#ifndef ENABLE_NETCORE MonoAppDomainSetupHandle ves_icall_System_AppDomain_getSetup (MonoAppDomainHandle ad, MonoError *error) { @@ -1212,7 +1090,6 @@ ves_icall_System_AppDomain_getSetup (MonoAppDomainHandle ad, MonoError *error) return MONO_HANDLE_NEW (MonoAppDomainSetup, domain->setup); } -#endif MonoStringHandle ves_icall_System_AppDomain_getFriendlyName (MonoAppDomainHandle ad, MonoError *error) @@ -1250,9 +1127,7 @@ ves_icall_System_CLRConfig_CheckThrowUnobservedTaskExceptions (MonoError *error) return domain->throw_unobserved_task_exceptions; } -#endif -#ifndef ENABLE_NETCORE static char* get_attribute_value (const gchar **attribute_names, const gchar **attribute_values, @@ -1391,9 +1266,7 @@ mono_domain_set_options_from_config (MonoDomain *domain) g_free (config_file_name); g_free (config_file_path); } -#endif -#ifndef ENABLE_NETCORE MonoAppDomainHandle ves_icall_System_AppDomain_createDomain (MonoStringHandle friendly_name, MonoAppDomainSetupHandle setup, MonoError *error) { @@ -1412,7 +1285,6 @@ ves_icall_System_AppDomain_createDomain (MonoStringHandle friendly_name, MonoApp #endif return ad; } -#endif static gboolean add_assembly_to_array (MonoDomain *domain, MonoArrayHandle dest, int dest_idx, MonoAssembly* assm, MonoError *error) @@ -1446,21 +1318,12 @@ leave: return res; } -#ifdef ENABLE_NETCORE -MonoArrayHandle -ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalGetLoadedAssemblies (MonoError *error) -{ - MonoDomain *domain = mono_domain_get (); - return get_assembly_array_from_domain (domain, FALSE, error); -} -#else MonoArrayHandle ves_icall_System_AppDomain_GetAssemblies (MonoAppDomainHandle ad, MonoBoolean refonly, MonoError *error) { MonoDomain *domain = MONO_HANDLE_GETVAL (ad, data); return get_assembly_array_from_domain (domain, refonly, error); } -#endif MonoAssembly* mono_try_assembly_resolve (MonoAssemblyLoadContext *alc, const char *fname_raw, MonoAssembly *requesting, gboolean refonly, MonoError *error) @@ -1486,7 +1349,6 @@ mono_try_assembly_resolve_handle (MonoAssemblyLoadContext *alc, MonoStringHandle if (mono_runtime_get_no_exec ()) goto leave; -#ifndef ENABLE_NETCORE static MonoMethod *method; MonoBoolean isrefonly; @@ -1526,42 +1388,6 @@ mono_try_assembly_resolve_handle (MonoAssemblyLoadContext *alc, MonoStringHandle ret = NULL; goto leave; } -#else - MONO_STATIC_POINTER_INIT (MonoMethod, method) - - ERROR_DECL (local_error); - static gboolean inited; - if (!inited) { - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - method = mono_class_get_method_from_name_checked (alc_class, "OnAssemblyResolve", -1, 0, local_error); - inited = TRUE; - } - mono_error_cleanup (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, method) - - if (!method) { - ret = NULL; - goto leave; - } - - MonoReflectionAssemblyHandle requesting_handle; - if (requesting) { - requesting_handle = mono_assembly_get_object_handle (domain, requesting, error); - goto_if_nok (error, leave); - } - - gpointer params [2]; - params [0] = requesting ? MONO_HANDLE_RAW (requesting_handle) : NULL; - params [1] = MONO_HANDLE_RAW (fname); - MonoReflectionAssemblyHandle result; - result = MONO_HANDLE_CAST (MonoReflectionAssembly, mono_runtime_try_invoke_handle (method, NULL_HANDLE, params, error)); - goto_if_nok (error, leave); - - if (MONO_HANDLE_BOOL (result)) - ret = MONO_HANDLE_GETVAL (result, assembly); -#endif leave: g_free (filename); @@ -1619,7 +1445,6 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht) mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly %s[%p] added to domain %s, ref_count=%d", ass->aname.name, ass, domain->friendly_name, ass->ref_count); } -#ifndef ENABLE_NETCORE if (ass->image->references) { for (int i = 0; i < ass->image->nreferences; i++) { MonoAssembly *ref = ass->image->references [i]; @@ -1629,7 +1454,6 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht) } } } -#endif if (destroy_ht) g_hash_table_destroy (ht); @@ -1638,30 +1462,6 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht) /* * LOCKING: assumes the ALC's assemblies lock is taken */ -#ifdef ENABLE_NETCORE -static void -add_assembly_to_alc (MonoAssemblyLoadContext *alc, MonoAssembly *ass) -{ - GSList *tmp; - - g_assert (ass != NULL); - - if (!ass->aname.name) - return; - - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - if (tmp->data == ass) { - return; - } - } - - mono_assembly_addref (ass); - // Prepending here will break the test suite with frequent InvalidCastExceptions, so we have to append - alc->loaded_assemblies = g_slist_append (alc->loaded_assemblies, ass); - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly %s[%p] added to ALC (%p), ref_count=%d", ass->aname.name, ass, (gpointer)alc, ass->ref_count); - -} -#endif static void mono_domain_fire_assembly_load_event (MonoDomain *domain, MonoAssembly *assembly, MonoError *error) @@ -1671,31 +1471,6 @@ mono_domain_fire_assembly_load_event (MonoDomain *domain, MonoAssembly *assembly g_assert (domain); g_assert (assembly); -#ifdef ENABLE_NETCORE - MONO_STATIC_POINTER_INIT (MonoMethod, method) - - static gboolean inited; - if (!inited) { - ERROR_DECL (local_error); - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - method = mono_class_get_method_from_name_checked (alc_class, "OnAssemblyLoad", -1, 0, local_error); - mono_error_cleanup (local_error); - inited = TRUE; - } - - MONO_STATIC_POINTER_INIT_END (MonoMethod, method) - if (!method) - goto exit; - - MonoReflectionAssemblyHandle assembly_handle; - assembly_handle = mono_assembly_get_object_handle (domain, assembly, error); - goto_if_nok (error, exit); - - gpointer args [1]; - args [0] = MONO_HANDLE_RAW (assembly_handle); - mono_runtime_try_invoke_handle (method, NULL_HANDLE, args, error); -#else MonoObjectHandle appdomain = MONO_HANDLE_NEW (MonoObject, &domain->domain->mbr.obj); MonoClass *klass = mono_handle_class (appdomain); @@ -1723,7 +1498,6 @@ mono_domain_fire_assembly_load_event (MonoDomain *domain, MonoAssembly *assembly void *params [1]; params [0] = MONO_HANDLE_RAW (reflection_assembly); mono_runtime_invoke_handle_void (assembly_load_method, appdomain, params, error); -#endif exit: HANDLE_FUNCTION_RETURN (); @@ -1747,14 +1521,7 @@ mono_domain_fire_assembly_load (MonoAssemblyLoadContext *alc, MonoAssembly *asse mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Loading assembly %s (%p) into domain %s (%p) and ALC %p", assembly->aname.name, assembly, domain->friendly_name, domain, alc); mono_domain_assemblies_lock (domain); -#ifdef ENABLE_NETCORE - mono_alc_assemblies_lock (alc); -#endif add_assemblies_to_domain (domain, assembly, NULL); -#ifdef ENABLE_NETCORE - add_assembly_to_alc (alc, assembly); - mono_alc_assemblies_unlock (alc); -#endif mono_domain_assemblies_unlock (domain); if (assembly->context.kind != MONO_ASMCTX_INTERNAL) @@ -1779,7 +1546,6 @@ mono_domain_asmctx_from_path (const char *fname, MonoAssembly *requesting_assemb return FALSE; } -#ifndef ENABLE_NETCORE /* * LOCKING: Acquires the domain assemblies lock. */ @@ -1930,7 +1696,6 @@ exit: mono_domain_assemblies_unlock (domain); HANDLE_FUNCTION_RETURN (); } -#endif #ifdef DISABLE_SHADOW_COPY gboolean @@ -2273,9 +2038,7 @@ mono_make_shadow_copy (const char *filename, MonoError *oerror) char *shadow_dir; gint32 copy_error; -#ifndef ENABLE_NETCORE set_domain_search_path (domain); -#endif if (!mono_is_shadow_copy_enabled (domain, dir_name)) { g_free (dir_name); @@ -2398,7 +2161,6 @@ mono_domain_from_appdomain (MonoAppDomain *appdomain_raw) MonoDomain * mono_domain_from_appdomain_handle (MonoAppDomainHandle appdomain) { -#ifndef ENABLE_NETCORE HANDLE_FUNCTION_ENTER (); MonoDomain *dom = NULL; if (MONO_HANDLE_IS_NULL (appdomain)) @@ -2414,9 +2176,6 @@ mono_domain_from_appdomain_handle (MonoAppDomainHandle appdomain) leave: HANDLE_FUNCTION_RETURN_VAL (dom); -#else - return mono_get_root_domain (); -#endif } @@ -2499,28 +2258,6 @@ real_load (gchar **search_path, const gchar *culture, const gchar *name, const M return result; } -#ifdef ENABLE_NETCORE -static char * -get_app_context_base_directory (MonoError *error) -{ - MONO_STATIC_POINTER_INIT (MonoMethod, get_basedir) - - ERROR_DECL (local_error); - MonoClass *app_context = mono_class_get_app_context_class (); - g_assert (app_context); - get_basedir = mono_class_get_method_from_name_checked (app_context, "get_BaseDirectory", -1, 0, local_error); - mono_error_assert_ok (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, get_basedir) - - HANDLE_FUNCTION_ENTER (); - - MonoStringHandle result = MONO_HANDLE_CAST (MonoString, mono_runtime_try_invoke_handle (get_basedir, NULL_HANDLE, NULL, error)); - char *base_dir = mono_string_handle_to_utf8 (result, error); - - HANDLE_FUNCTION_RETURN_VAL (base_dir); -} -#endif /* * Try loading the assembly from ApplicationBase and PrivateBinPath @@ -2538,14 +2275,8 @@ mono_domain_assembly_preload (MonoAssemblyLoadContext *alc, { MonoDomain *domain = mono_alc_domain (alc); MonoAssembly *result = NULL; -#ifdef ENABLE_NETCORE - g_assert (alc); - g_assert (domain == mono_domain_get ()); -#endif -#ifndef ENABLE_NETCORE set_domain_search_path (domain); -#endif MonoAssemblyCandidatePredicate predicate = NULL; void* predicate_ud = NULL; @@ -2558,20 +2289,6 @@ mono_domain_assembly_preload (MonoAssemblyLoadContext *alc, req.request.predicate = predicate; req.request.predicate_ud = predicate_ud; -#ifdef ENABLE_NETCORE - if (!mono_runtime_get_no_exec ()) { - char *search_path [2]; - search_path [1] = NULL; - - char *base_dir = get_app_context_base_directory (error); - search_path [0] = base_dir; - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Domain (%p) ApplicationBase is %s", domain, base_dir); - - result = real_load (search_path, aname->culture, aname->name, &req); - - g_free (base_dir); - } -#else if (domain->search_path && domain->search_path [0] != NULL) { if (mono_trace_is_traced (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY)) { mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Domain %s search path is:", domain->friendly_name); @@ -2583,7 +2300,6 @@ mono_domain_assembly_preload (MonoAssemblyLoadContext *alc, } result = real_load (domain->search_path, aname->culture, aname->name, &req); } -#endif if (result == NULL && assemblies_path && assemblies_path [0] != NULL) { result = real_load (assemblies_path, aname->culture, aname->name, &req); @@ -2607,22 +2323,6 @@ mono_domain_assembly_search (MonoAssemblyLoadContext *alc, MonoAssembly *request GSList *tmp; MonoAssembly *ass; -#ifdef ENABLE_NETCORE - const MonoAssemblyNameEqFlags eq_flags = MONO_ANAME_EQ_IGNORE_PUBKEY | MONO_ANAME_EQ_IGNORE_VERSION | MONO_ANAME_EQ_IGNORE_CASE; - - mono_alc_assemblies_lock (alc); - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - ass = (MonoAssembly *)tmp->data; - g_assert (ass != NULL); - // FIXME: Can dynamic assemblies match here for netcore? - if (assembly_is_dynamic (ass) || !mono_assembly_names_equal_flags (aname, &ass->aname, eq_flags)) - continue; - - mono_alc_assemblies_unlock (alc); - return ass; - } - mono_alc_assemblies_unlock (alc); -#else MonoDomain *domain = mono_alc_domain (alc); const gboolean strong_name = aname->public_key_token[0] != 0; @@ -2645,77 +2345,11 @@ mono_domain_assembly_search (MonoAssemblyLoadContext *alc, MonoAssembly *request return ass; } mono_domain_assemblies_unlock (domain); -#endif return NULL; } -#if ENABLE_NETCORE -MonoReflectionAssemblyHandle -ves_icall_System_Reflection_Assembly_InternalLoad (MonoStringHandle name_handle, MonoStackCrawlMark *stack_mark, gpointer load_Context, MonoError *error) -{ - error_init (error); - MonoAssembly *ass = NULL; - MonoAssemblyName aname; - MonoAssemblyByNameRequest req; - MonoAssemblyContextKind asmctx; - MonoImageOpenStatus status = MONO_IMAGE_OK; - gboolean parsed; - char *name; - - MonoAssembly *requesting_assembly = mono_runtime_get_caller_from_stack_mark (stack_mark); - MonoAssemblyLoadContext *alc = (MonoAssemblyLoadContext *)load_Context; - if (!alc) - alc = mono_assembly_get_alc (requesting_assembly); - if (!alc) - g_assert_not_reached (); - - MonoDomain *domain = mono_alc_domain (alc); - g_assert (alc); - asmctx = MONO_ASMCTX_DEFAULT; - mono_assembly_request_prepare_byname (&req, asmctx, alc); - req.basedir = NULL; - /* Everything currently goes through this function, and the postload hook (aka the AppDomain.AssemblyResolve event) - * is triggered under some scenarios. It's not completely obvious to me in what situations (if any) this should be disabled, - * other than for corlib satellite assemblies (which I've dealt with further down the call stack). - */ - //req.no_postload_search = TRUE; - req.requesting_assembly = requesting_assembly; - - name = mono_string_handle_to_utf8 (name_handle, error); - goto_if_nok (error, fail); - parsed = mono_assembly_name_parse (name, &aname); - g_free (name); - if (!parsed) - goto fail; - - MonoAssemblyCandidatePredicate predicate; - void* predicate_ud; - predicate = NULL; - predicate_ud = NULL; - if (mono_loader_get_strict_assembly_name_check ()) { - predicate = &mono_assembly_candidate_predicate_sn_same_name; - predicate_ud = &aname; - } - req.request.predicate = predicate; - req.request.predicate_ud = predicate_ud; - - ass = mono_assembly_request_byname (&aname, &req, &status); - if (!ass) - goto fail; - - MonoReflectionAssemblyHandle refass; - refass = mono_assembly_get_object_handle (domain, ass, error); - goto_if_nok (error, fail); - return refass; - -fail: - return MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE); -} -#endif - -#ifndef ENABLE_NETCORE MonoReflectionAssemblyHandle ves_icall_System_Reflection_Assembly_LoadFrom (MonoStringHandle fname, MonoBoolean refOnly, MonoStackCrawlMark *stack_mark, MonoError *error) { @@ -2760,7 +2394,6 @@ leave: g_free (name); return result; } -#endif static MonoAssembly * @@ -2799,7 +2432,6 @@ leave: HANDLE_FUNCTION_RETURN_VAL (ass); } -#ifndef ENABLE_NETCORE MonoReflectionAssemblyHandle ves_icall_System_Reflection_Assembly_LoadFile_internal (MonoStringHandle fname, MonoStackCrawlMark *stack_mark, MonoError *error) { @@ -2814,46 +2446,10 @@ ves_icall_System_Reflection_Assembly_LoadFile_internal (MonoStringHandle fname, leave: return result; } -#else -MonoReflectionAssemblyHandle -ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalLoadFile (gpointer alc_ptr, MonoStringHandle fname, MonoStackCrawlMark *stack_mark, MonoError *error) -{ - MonoReflectionAssemblyHandle result = MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE); - MonoAssemblyLoadContext *alc = (MonoAssemblyLoadContext *)alc_ptr; - MonoDomain *domain = mono_alc_domain (alc); - - MonoAssembly *executing_assembly; - executing_assembly = mono_runtime_get_caller_from_stack_mark (stack_mark); - MonoAssembly *ass = mono_alc_load_file (alc, fname, executing_assembly, mono_alc_is_default (alc) ? MONO_ASMCTX_LOADFROM : MONO_ASMCTX_INDIVIDUAL, error); - goto_if_nok (error, leave); - - result = mono_assembly_get_object_handle (domain, ass, error); - -leave: - return result; -} -#endif static MonoAssembly* mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *raw_assembly, guint32 raw_assembly_len, guint8 *raw_symbol_data, guint32 raw_symbol_len, gboolean refonly, MonoError *error); -#ifdef ENABLE_NETCORE -MonoReflectionAssemblyHandle -ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalLoadFromStream (gpointer native_alc, gpointer raw_assembly_ptr, gint32 raw_assembly_len, gpointer raw_symbols_ptr, gint32 raw_symbols_len, MonoError *error) -{ - MonoAssemblyLoadContext *alc = (MonoAssemblyLoadContext *)native_alc; - MonoDomain *domain = mono_alc_domain (alc); - MonoReflectionAssemblyHandle result = MONO_HANDLE_CAST (MonoReflectionAssembly, NULL_HANDLE); - MonoAssembly *assm = NULL; - assm = mono_alc_load_raw_bytes (alc, (guint8 *)raw_assembly_ptr, raw_assembly_len, (guint8 *)raw_symbols_ptr, raw_symbols_len, FALSE, error); - goto_if_nok (error, leave); - - result = mono_assembly_get_object_handle (domain, assm, error); - -leave: - return result; -} -#else MonoReflectionAssemblyHandle ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad, MonoArrayHandle raw_assembly, @@ -2886,7 +2482,6 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomainHandle ad, leave: return refass; } -#endif /* ENABLE_NETCORE */ static MonoAssembly* mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *assembly_data, guint32 raw_assembly_len, guint8 *raw_symbol_data, guint32 raw_symbol_len, gboolean refonly, MonoError *error) @@ -2903,7 +2498,6 @@ mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *assembly_data, gu if (raw_symbol_data) mono_debug_open_image_from_memory (image, raw_symbol_data, raw_symbol_len); -#ifndef ENABLE_NETCORE MonoAssembly* redirected_asm = NULL; MonoImageOpenStatus new_status = MONO_IMAGE_OK; // http://blogs.microsoft.co.il/sasha/2010/06/09/assemblyreflectiononlyload-ignores-assembly-binding-redirects/ @@ -2916,7 +2510,6 @@ mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *assembly_data, gu mono_error_set_bad_image_by_name (error, "In Memory assembly", "0x%p was assembly binding redirected to another assembly that failed to load", assembly_data); return ass; } -#endif MonoAssemblyLoadRequest req; mono_assembly_request_prepare_load (&req, refonly? MONO_ASMCTX_REFONLY : MONO_ASMCTX_INDIVIDUAL, alc); @@ -2934,7 +2527,6 @@ mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *assembly_data, gu return ass; } -#ifndef ENABLE_NETCORE MonoReflectionAssemblyHandle ves_icall_System_AppDomain_LoadAssembly (MonoAppDomainHandle ad, MonoStringHandle assRef, MonoObjectHandle evidence, MonoBoolean refOnly, MonoStackCrawlMark *stack_mark, MonoError *error) { @@ -3189,7 +2781,6 @@ ves_icall_System_AppDomain_InternalGetProcessGuid (MonoStringHandle newguid, Mon mono_domain_unlock (mono_root_domain); return newguid; } -#endif /** * mono_domain_is_unloading: @@ -3203,7 +2794,6 @@ mono_domain_is_unloading (MonoDomain *domain) return FALSE; } -#ifndef ENABLE_NETCORE static void clear_cached_vtable (MonoVTable *vtable) @@ -3531,55 +3121,4 @@ exit: HANDLE_FUNCTION_RETURN (); } -#endif /* ENABLE_NETCORE */ - -#ifdef ENABLE_NETCORE - -/* Remember properties so they can be be installed in AppContext during runtime init */ -void -mono_runtime_register_appctx_properties (int nprops, const char **keys, const char **values) -{ - n_appctx_props = nprops; - appctx_keys = g_new0 (gunichar2*, nprops); - appctx_values = g_new0 (gunichar2*, nprops); - for (int i = 0; i < nprops; ++i) { - appctx_keys [i] = g_utf8_to_utf16 (keys [i], strlen (keys [i]), NULL, NULL, NULL); - appctx_values [i] = g_utf8_to_utf16 (values [i], strlen (values [i]), NULL, NULL, NULL); - } -} - -static GENERATE_GET_CLASS_WITH_CACHE (appctx, "System", "AppContext") - -/* Install properties into AppContext */ -void -mono_runtime_install_appctx_properties (void) -{ - ERROR_DECL (error); - gpointer args [3]; - - MonoMethod *setup = mono_class_get_method_from_name_checked (mono_class_get_appctx_class (), "Setup", 3, 0, error); - g_assert (setup); - - // FIXME: TRUSTED_PLATFORM_ASSEMBLIES is very large - - /* internal static unsafe void Setup(char** pNames, char** pValues, int count) */ - args [0] = appctx_keys; - args [1] = appctx_values; - args [2] = &n_appctx_props; - - mono_runtime_invoke_checked (setup, NULL, args, error); - mono_error_assert_ok (error); - - /* No longer needed */ - for (int i = 0; i < n_appctx_props; ++i) { - g_free (appctx_keys [i]); - g_free (appctx_values [i]); - } - g_free (appctx_keys); - g_free (appctx_values); - appctx_keys = NULL; - appctx_values = NULL; -} - -#endif diff --git a/mono/metadata/assembly-internals.h b/mono/metadata/assembly-internals.h index 5b317165ec7..8a0f75dba1c 100644 --- a/mono/metadata/assembly-internals.h +++ b/mono/metadata/assembly-internals.h @@ -11,11 +11,7 @@ #include <mono/metadata/assembly.h> #include <mono/metadata/metadata-internals.h> -#ifndef ENABLE_NETCORE #define MONO_ASSEMBLY_CORLIB_NAME "mscorlib" -#else -#define MONO_ASSEMBLY_CORLIB_NAME "System.Private.CoreLib" -#endif #define MONO_ASSEMBLY_RESOURCE_SUFFIX ".resources" #define MONO_ASSEMBLY_CORLIB_RESOURCE_NAME (MONO_ASSEMBLY_CORLIB_NAME MONO_ASSEMBLY_RESOURCE_SUFFIX) @@ -139,10 +135,8 @@ mono_assembly_candidate_predicate_sn_same_name (MonoAssembly *candidate, gpointe gboolean mono_assembly_check_name_match (MonoAssemblyName *wanted_name, MonoAssemblyName *candidate_name); -#ifndef ENABLE_NETCORE MonoAssembly* mono_assembly_binding_applies_to_image (MonoAssemblyLoadContext *alc, MonoImage* image, MonoImageOpenStatus *status); -#endif MonoAssembly * mono_assembly_loaded_internal (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, gboolean refonly); diff --git a/mono/metadata/assembly-load-context.c b/mono/metadata/assembly-load-context.c index 3f5066dbed7..00c48712ea3 100644 --- a/mono/metadata/assembly-load-context.c +++ b/mono/metadata/assembly-load-context.c @@ -1,416 +1,5 @@ #include "config.h" #include "mono/utils/mono-compiler.h" -#ifdef ENABLE_NETCORE // MonoAssemblyLoadContext support only in netcore Mono - -#include "mono/metadata/assembly.h" -#include "mono/metadata/domain-internals.h" -#include "mono/metadata/exception-internals.h" -#include "mono/metadata/icall-decl.h" -#include "mono/metadata/loader-internals.h" -#include "mono/metadata/loaded-images-internals.h" -#include "mono/metadata/mono-private-unstable.h" -#include "mono/utils/mono-error-internals.h" -#include "mono/utils/mono-logger-internals.h" - -GENERATE_GET_CLASS_WITH_CACHE (assembly_load_context, "System.Runtime.Loader", "AssemblyLoadContext"); - -static void -mono_alc_init (MonoAssemblyLoadContext *alc, MonoDomain *domain, gboolean collectible) -{ - MonoLoadedImages *li = g_new0 (MonoLoadedImages, 1); - mono_loaded_images_init (li, alc); - alc->domain = domain; - alc->loaded_images = li; - alc->loaded_assemblies = NULL; - alc->memory_manager = mono_mem_manager_create_singleton (alc, domain, collectible); - alc->generic_memory_managers = g_ptr_array_new (); - mono_coop_mutex_init (&alc->memory_managers_lock); - alc->unloading = FALSE; - alc->collectible = collectible; - alc->pinvoke_scopes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); - mono_coop_mutex_init (&alc->assemblies_lock); - mono_coop_mutex_init (&alc->pinvoke_lock); -} - -static MonoAssemblyLoadContext * -mono_alc_create (MonoDomain *domain, gboolean is_default, gboolean collectible) -{ - MonoAssemblyLoadContext *alc = NULL; - - mono_domain_alcs_lock (domain); - if (is_default && domain->default_alc) - goto leave; - - alc = g_new0 (MonoAssemblyLoadContext, 1); - mono_alc_init (alc, domain, collectible); - - domain->alcs = g_slist_prepend (domain->alcs, alc); - if (is_default) - domain->default_alc = alc; - -leave: - mono_domain_alcs_unlock (domain); - return alc; -} - -void -mono_alc_create_default (MonoDomain *domain) -{ - if (domain->default_alc) - return; - mono_alc_create (domain, TRUE, FALSE); -} - -MonoAssemblyLoadContext * -mono_alc_create_individual (MonoDomain *domain, MonoGCHandle this_gchandle, gboolean collectible, MonoError *error) -{ - MonoAssemblyLoadContext *alc = mono_alc_create (domain, FALSE, collectible); - - alc->gchandle = this_gchandle; - - return alc; -} - -static void -mono_alc_cleanup_assemblies (MonoAssemblyLoadContext *alc) -{ - // The minimum refcount on assemblies is 2: one for the domain and one for the ALC. - // The domain refcount might be less than optimal on netcore, but its removal is too likely to cause issues for now. - GSList *tmp; - MonoDomain *domain = alc->domain; - - // Remove the assemblies from domain_assemblies - mono_domain_assemblies_lock (domain); - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - MonoAssembly *assembly = (MonoAssembly *)tmp->data; - domain->domain_assemblies = g_slist_remove (domain->domain_assemblies, assembly); - mono_assembly_decref (assembly); - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Unloading ALC [%p], removing assembly %s[%p] from domain_assemblies, ref_count=%d\n", alc, assembly->aname.name, assembly, assembly->ref_count); - } - mono_domain_assemblies_unlock (domain); - - // Release the GC roots - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - MonoAssembly *assembly = (MonoAssembly *)tmp->data; - mono_assembly_release_gc_roots (assembly); - } - - // Close dynamic assemblies - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - MonoAssembly *assembly = (MonoAssembly *)tmp->data; - if (!assembly->image || !image_is_dynamic (assembly->image)) - continue; - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Unloading ALC [%p], dynamic assembly %s[%p], ref_count=%d", domain, assembly->aname.name, assembly, assembly->ref_count); - if (!mono_assembly_close_except_image_pools (assembly)) - tmp->data = NULL; - } - - // Close the remaining assemblies - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - MonoAssembly *assembly = (MonoAssembly *)tmp->data; - if (!assembly) - continue; - if (!assembly->image || image_is_dynamic (assembly->image)) - continue; - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Unloading ALC [%p], non-dynamic assembly %s[%p], ref_count=%d", domain, assembly->aname.name, assembly, assembly->ref_count); - if (!mono_assembly_close_except_image_pools (assembly)) - tmp->data = NULL; - } - - // Complete the second closing pass on lingering assemblies - for (tmp = alc->loaded_assemblies; tmp; tmp = tmp->next) { - MonoAssembly *assembly = (MonoAssembly *)tmp->data; - if (assembly) - mono_assembly_close_finish (assembly); - } - - // Free the loaded_assemblies - g_slist_free (alc->loaded_assemblies); - alc->loaded_assemblies = NULL; - - mono_coop_mutex_destroy (&alc->assemblies_lock); - - mono_loaded_images_free (alc->loaded_images); - alc->loaded_images = NULL; - - // TODO: free mempool stuff/jit info tables, see domain freeing for an example -} - -static void -mono_alc_cleanup (MonoAssemblyLoadContext *alc) -{ - MonoDomain *domain = alc->domain; - - g_assert (alc != mono_domain_default_alc (domain)); - g_assert (alc->collectible == TRUE); - - // TODO: alc unloading profiler event - - // Remove from domain list - mono_domain_alcs_lock (domain); - domain->alcs = g_slist_remove (domain->alcs, alc); - mono_domain_alcs_unlock (domain); - - mono_alc_cleanup_assemblies (alc); - - mono_mem_manager_free_singleton (alc->memory_manager, FALSE); - alc->memory_manager = NULL; - - /*for (int i = 0; i < alc->generic_memory_managers->len; i++) { - MonoGenericMemoryManager *memory_manager = (MonoGenericMemoryManager *)alc->generic_memory_managers->pdata [i]; - mono_mem_manager_free_generic (memory_manager, FALSE); - }*/ - g_ptr_array_free (alc->generic_memory_managers, TRUE); - mono_coop_mutex_destroy (&alc->memory_managers_lock); - - mono_gchandle_free_internal (alc->gchandle); - alc->gchandle = NULL; - - g_hash_table_destroy (alc->pinvoke_scopes); - alc->pinvoke_scopes = NULL; - mono_coop_mutex_destroy (&alc->pinvoke_lock); - - // TODO: alc unloaded profiler event -} - -static void -mono_alc_free (MonoAssemblyLoadContext *alc) -{ - mono_alc_cleanup (alc); - g_free (alc); -} - -void -mono_alc_assemblies_lock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_lock (&alc->assemblies_lock); -} - -void -mono_alc_assemblies_unlock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_unlock (&alc->assemblies_lock); -} - -void -mono_alc_memory_managers_lock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_lock (&alc->memory_managers_lock); -} - -void -mono_alc_memory_managers_unlock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_unlock (&alc->memory_managers_lock); -} - -gpointer -ves_icall_System_Runtime_Loader_AssemblyLoadContext_InternalInitializeNativeALC (gpointer this_gchandle_ptr, MonoBoolean is_default_alc, MonoBoolean collectible, MonoError *error) -{ - /* If the ALC is collectible, this_gchandle is weak, otherwise it's strong. */ - MonoGCHandle this_gchandle = (MonoGCHandle)this_gchandle_ptr; - - MonoDomain *domain = mono_domain_get (); - MonoAssemblyLoadContext *alc = NULL; - - if (is_default_alc) { - alc = mono_domain_default_alc (domain); - g_assert (alc); - if (!alc->gchandle) - alc->gchandle = this_gchandle; - } else - alc = mono_alc_create_individual (domain, this_gchandle, collectible, error); - - return alc; -} - -void -ves_icall_System_Runtime_Loader_AssemblyLoadContext_PrepareForAssemblyLoadContextRelease (gpointer alc_pointer, gpointer strong_gchandle_ptr, MonoError *error) -{ - MonoGCHandle strong_gchandle = (MonoGCHandle)strong_gchandle_ptr; - MonoAssemblyLoadContext *alc = (MonoAssemblyLoadContext *)alc_pointer; - - g_assert (alc->collectible); - g_assert (!alc->unloading); - g_assert (alc->gchandle); - - alc->unloading = TRUE; - - // Replace the weak gchandle with the new strong one to keep the managed ALC alive - MonoGCHandle weak_gchandle = alc->gchandle; - alc->gchandle = strong_gchandle; - mono_gchandle_free_internal (weak_gchandle); -} - -gpointer -ves_icall_System_Runtime_Loader_AssemblyLoadContext_GetLoadContextForAssembly (MonoReflectionAssemblyHandle assm_obj, MonoError *error) -{ - MonoAssembly *assm = MONO_HANDLE_GETVAL (assm_obj, assembly); - MonoAssemblyLoadContext *alc = mono_assembly_get_alc (assm); - - return (gpointer)alc->gchandle; -} - -gboolean -mono_alc_is_default (MonoAssemblyLoadContext *alc) -{ - return alc == mono_alc_domain (alc)->default_alc; -} - -MonoAssemblyLoadContext * -mono_alc_from_gchandle (MonoGCHandle alc_gchandle) -{ - HANDLE_FUNCTION_ENTER (); - MonoManagedAssemblyLoadContextHandle managed_alc = MONO_HANDLE_CAST (MonoManagedAssemblyLoadContext, mono_gchandle_get_target_handle (alc_gchandle)); - MonoAssemblyLoadContext *alc = MONO_HANDLE_GETVAL (managed_alc, native_assembly_load_context); - HANDLE_FUNCTION_RETURN_VAL (alc); -} - -MonoGCHandle -mono_alc_get_default_gchandle (void) -{ - // Because the default domain is never unloadable, this should be a strong handle and never change - return mono_domain_default_alc (mono_domain_get ())->gchandle; -} - -static MonoAssembly* -invoke_resolve_method (MonoMethod *resolve_method, MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error) -{ - MonoAssembly *result = NULL; - char* aname_str = NULL; - - if (mono_runtime_get_no_exec ()) - return NULL; - - HANDLE_FUNCTION_ENTER (); - - aname_str = mono_stringify_assembly_name (aname); - - MonoStringHandle aname_obj = mono_string_new_handle (mono_alc_domain (alc), aname_str, error); - goto_if_nok (error, leave); - - MonoReflectionAssemblyHandle assm; - gpointer gchandle; - gchandle = (gpointer)alc->gchandle; - gpointer args [2]; - args [0] = &gchandle; - args [1] = MONO_HANDLE_RAW (aname_obj); - assm = MONO_HANDLE_CAST (MonoReflectionAssembly, mono_runtime_try_invoke_handle (resolve_method, NULL_HANDLE, args, error)); - goto_if_nok (error, leave); - - if (MONO_HANDLE_BOOL (assm)) - result = MONO_HANDLE_GETVAL (assm, assembly); - -leave: - g_free (aname_str); - HANDLE_FUNCTION_RETURN_VAL (result); -} - -static MonoAssembly* -mono_alc_invoke_resolve_using_load (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error) -{ - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve = mono_class_get_method_from_name_checked (alc_class, "MonoResolveUsingLoad", -1, 0, local_error); - mono_error_assert_ok (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - - g_assert (resolve); - - return invoke_resolve_method (resolve, alc, aname, error); -} - -MonoAssembly* -mono_alc_invoke_resolve_using_load_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname) -{ - MonoAssembly *result = NULL; - ERROR_DECL (error); - - result = mono_alc_invoke_resolve_using_load (alc, aname, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Error while invoking ALC Load(\"%s\") method: '%s'", aname->name, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -static MonoAssembly* -mono_alc_invoke_resolve_using_resolving_event (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error) -{ - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - static gboolean inited; - if (!inited) { - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve = mono_class_get_method_from_name_checked (alc_class, "MonoResolveUsingResolvingEvent", -1, 0, local_error); - inited = TRUE; - } - mono_error_cleanup (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - - if (!resolve) - return NULL; - - return invoke_resolve_method (resolve, alc, aname, error); -} - -MonoAssembly* -mono_alc_invoke_resolve_using_resolving_event_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname) -{ - MonoAssembly *result = NULL; - ERROR_DECL (error); - - result = mono_alc_invoke_resolve_using_resolving_event (alc, aname, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Error while invoking ALC Resolving(\"%s\") event: '%s'", aname->name, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -static MonoAssembly* -mono_alc_invoke_resolve_using_resolve_satellite (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, MonoError *error) -{ - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve = mono_class_get_method_from_name_checked (alc_class, "MonoResolveUsingResolveSatelliteAssembly", -1, 0, local_error); - mono_error_assert_ok (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - - g_assert (resolve); - - return invoke_resolve_method (resolve, alc, aname, error); -} - -MonoAssembly* -mono_alc_invoke_resolve_using_resolve_satellite_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname) -{ - MonoAssembly *result = NULL; - ERROR_DECL (error); - - result = mono_alc_invoke_resolve_using_resolve_satellite (alc, aname, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Error while invoking ALC ResolveSatelliteAssembly(\"%s\") method: '%s'", aname->name, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -#endif /* ENABLE_NETCORE */ MONO_EMPTY_SOURCE_FILE (assembly_load_context) diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index 8421df9f501..5a2ddad4e75 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -386,10 +386,6 @@ static GSList *loaded_assembly_bindings = NULL; static GENERATE_TRY_GET_CLASS_WITH_CACHE (internals_visible, "System.Runtime.CompilerServices", "InternalsVisibleToAttribute") static MonoAssembly* mono_assembly_invoke_search_hook_internal (MonoAssemblyLoadContext *alc, MonoAssembly *requesting, MonoAssemblyName *aname, gboolean refonly, gboolean postload); -#ifdef ENABLE_NETCORE -static MonoAssembly* -mono_assembly_request_byname_nosearch (MonoAssemblyName *aname, const MonoAssemblyByNameRequest *req, MonoImageOpenStatus *status); -#endif static MonoAssembly* mono_assembly_load_full_gac_base_default (MonoAssemblyName *aname, const char *basedir, MonoAssemblyLoadContext *alc, MonoAssemblyContextKind asmctx, MonoImageOpenStatus *status); static MonoAssembly* @@ -402,10 +398,8 @@ invoke_assembly_preload_hook (MonoAssemblyLoadContext *alc, MonoAssemblyName *an static MonoBoolean mono_assembly_is_in_gac (const gchar *filanem); -#ifndef ENABLE_NETCORE static MonoAssemblyName* mono_assembly_apply_binding (MonoAssemblyName *aname, MonoAssemblyName *dest_name); -#endif static MonoAssembly* prevent_reference_assembly_from_running (MonoAssembly* candidate, gboolean refonly); @@ -1553,7 +1547,6 @@ mono_assembly_get_assemblyref (MonoImage *image, int index, MonoAssemblyName *an } } -#ifndef ENABLE_NETCORE static MonoAssembly* load_reference_by_aname_refonly_asmctx (MonoAssemblyName *aname, MonoAssemblyLoadContext *alc, MonoAssembly *assm, MonoImageOpenStatus *status) { @@ -1666,179 +1659,6 @@ load_reference_by_aname_individual_asmctx (MonoAssemblyName *aname, MonoAssembly reference = (MonoAssembly*)REFERENCE_MISSING; return reference; } -#else -static MonoAssembly * -search_bundle_for_assembly (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname) -{ - if (bundles == NULL && satellite_bundles == NULL) - return NULL; - - MonoImageOpenStatus status; - MonoImage *image; - MonoAssemblyLoadRequest req; - image = mono_assembly_open_from_bundle (alc, aname->name, &status, FALSE, aname->culture); - if (!image && !g_str_has_suffix (aname->name, ".dll")) { - char *name = g_strdup_printf ("%s.dll", aname->name); - image = mono_assembly_open_from_bundle (alc, name, &status, FALSE, aname->culture); - } - if (image) { - mono_assembly_request_prepare_load (&req, MONO_ASMCTX_DEFAULT, alc); - return mono_assembly_request_load_from (image, aname->name, &req, &status); - } - return NULL; -} - -static MonoAssembly* -netcore_load_reference (MonoAssemblyName *aname, MonoAssemblyLoadContext *alc, MonoAssembly *requesting, gboolean postload) -{ - g_assert (alc != NULL); - - MonoAssemblyName mapped_aname; - - aname = mono_assembly_remap_version (aname, &mapped_aname); - - MonoAssembly *reference = NULL; - - gboolean is_satellite = !mono_assembly_name_culture_is_neutral (aname); - gboolean is_default = mono_alc_is_default (alc); - - /* - * Try these until one of them succeeds (by returning a non-NULL reference): - * 1. Check if it's already loaded by the ALC. - * - * 2. If it's a non-default ALC, call the Load() method. - * - * 3. If the ALC is not the default and this is not a satellite request, - * check if it's already loaded by the default ALC. - * - * 4. If we have a bundle registered and this is not a satellite request, - * search the images for a matching name. - * - * 5. If we have a satellite bundle registered and this is a satellite request, - * find the parent ALC and search the images for a matching name and culture. - * - * 6. If the ALC is the default or this is not a satellite request, - * check the TPA list, APP_PATHS, and ApplicationBase. - * - * 7. If this is a satellite request, call the ALC ResolveSatelliteAssembly method. - * - * 8. Call the ALC Resolving event. - * - * 9. Call the ALC AssemblyResolve event (except for corlib satellite assemblies). - * - * 10. Return NULL. - */ - - reference = mono_assembly_loaded_internal (alc, aname, FALSE); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly already loaded in the active ALC: '%s'.", aname->name); - goto leave; - } - - if (!is_default) { - reference = mono_alc_invoke_resolve_using_load_nofail (alc, aname); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found using Load method: '%s'.", aname->name); - goto leave; - } - } - - if (!is_default && !is_satellite) { - reference = mono_assembly_loaded_internal (mono_domain_default_alc (mono_alc_domain (alc)), aname, FALSE); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly already loaded in the default ALC: '%s'.", aname->name); - goto leave; - } - } - - if (bundles != NULL && !is_satellite) { - reference = search_bundle_for_assembly (mono_domain_default_alc (mono_alc_domain (alc)), aname); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found in the bundle: '%s'.", aname->name); - goto leave; - } - } - - if (satellite_bundles != NULL && is_satellite) { - // Satellite assembly byname requests should be loaded in the same ALC as their parent assembly - size_t name_len = strlen (aname->name); - char *parent_name = NULL; - MonoAssemblyLoadContext *parent_alc = NULL; - if (g_str_has_suffix (aname->name, MONO_ASSEMBLY_RESOURCE_SUFFIX)) - parent_name = g_strdup_printf ("%s.dll", g_strndup (aname->name, name_len - strlen (MONO_ASSEMBLY_RESOURCE_SUFFIX))); - - if (parent_name) { - MonoAssemblyOpenRequest req; - mono_assembly_request_prepare_open (&req, MONO_ASMCTX_DEFAULT, alc); - MonoAssembly *parent_assembly = mono_assembly_request_open (parent_name, &req, NULL); - parent_alc = mono_assembly_get_alc (parent_assembly); - } - - if (parent_alc) - reference = search_bundle_for_assembly (parent_alc, aname); - - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found in the satellite bundle: '%s'.", aname->name); - goto leave; - } - } - - if (is_default || !is_satellite) { - reference = invoke_assembly_preload_hook (mono_domain_default_alc (mono_alc_domain (alc)), aname, assemblies_path); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found with the filesystem probing logic: '%s'.", aname->name); - goto leave; - } - } - - if (is_satellite) { - reference = mono_alc_invoke_resolve_using_resolve_satellite_nofail (alc, aname); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found with ResolveSatelliteAssembly method: '%s'.", aname->name); - goto leave; - } - } - - reference = mono_alc_invoke_resolve_using_resolving_event_nofail (alc, aname); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found with the Resolving event: '%s'.", aname->name); - goto leave; - } - - // Looking up corlib resources here can cause an infinite loop - // See: https://github.com/dotnet/coreclr/blob/0a762eb2f3a299489c459da1ddeb69e042008f07/src/vm/appdomain.cpp#L5178-L5239 - if (!(strcmp (aname->name, MONO_ASSEMBLY_CORLIB_RESOURCE_NAME) == 0 && is_satellite) && postload) { - reference = mono_assembly_invoke_search_hook_internal (alc, requesting, aname, FALSE, TRUE); - if (reference) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly found with AssemblyResolve event: '%s'.", aname->name); - goto leave; - } - } - -leave: - return reference; -} - -static MonoImage * -open_from_satellite_bundle (MonoAssemblyLoadContext *alc, const char *filename, MonoImageOpenStatus *status, gboolean refonly, const char *culture) -{ - if (!satellite_bundles) - return NULL; - - MonoImage *image = NULL; - char *name = g_strdup (filename); - for (int i = 0; !image && satellite_bundles [i]; ++i) { - if (strcmp (satellite_bundles [i]->name, name) == 0 && strcmp (satellite_bundles [i]->culture, culture) == 0) { - image = mono_image_open_from_data_internal (alc, (char *)satellite_bundles [i]->data, satellite_bundles [i]->size, FALSE, status, refonly, FALSE, name, NULL); - break; - } - } - - g_free (name); - return image; -} - -#endif /* ENABLE_NETCORE */ /** * mono_assembly_get_assemblyref_checked: @@ -1946,7 +1766,6 @@ mono_assembly_load_reference (MonoImage *image, int index) aname_str); g_free (aname_str); } -#ifndef ENABLE_NETCORE switch (mono_asmctx_get_kind (&image->assembly->context)) { case MONO_ASMCTX_DEFAULT: reference = load_reference_by_aname_default_asmctx (&aname, mono_image_get_alc (image), image->assembly, &status); @@ -1964,20 +1783,9 @@ mono_assembly_load_reference (MonoImage *image, int index) g_error ("Unexpected assembly load context kind %d for image %s.", mono_asmctx_get_kind (&image->assembly->context), image->name); break; } -#else - MonoAssemblyByNameRequest req; - mono_assembly_request_prepare_byname (&req, MONO_ASMCTX_DEFAULT, mono_image_get_alc (image)); - req.requesting_assembly = image->assembly; - //req.no_postload_search = TRUE; // FIXME: should this be set? - reference = mono_assembly_request_byname (&aname, &req, NULL); -#endif } else { -#ifndef ENABLE_NETCORE /* FIXME: can we establish that image->assembly is never NULL and this code is dead? */ reference = load_reference_by_aname_default_asmctx (&aname, mono_image_get_alc (image), image->assembly, &status); -#else - g_assertf (image->assembly, "While loading reference %d MonoImage %s doesn't have a MonoAssembly", index, image->name); -#endif } if (reference == NULL){ @@ -2310,13 +2118,7 @@ invoke_assembly_preload_hook (MonoAssemblyLoadContext *alc, MonoAssemblyName *an if (hook->version == 2) assembly = hook->func.v2 (alc, aname, apath, FALSE, hook->user_data, error); else { // v3 -#ifdef ENABLE_NETCORE - MonoGCHandle strong_gchandle = mono_gchandle_from_handle (mono_gchandle_get_target_handle (alc->gchandle), TRUE); - assembly = hook->func.v3 (strong_gchandle, aname, apath, hook->user_data, error); - mono_gchandle_free_internal (strong_gchandle); -#else assembly = hook->func.v3 (NULL, aname, apath, hook->user_data, error); -#endif } /* TODO: propagage error out to callers */ mono_error_assert_ok (error); @@ -2593,12 +2395,7 @@ open_from_bundle_internal (MonoAssemblyLoadContext *alc, const char *filename, M char *name = is_satellite ? g_strdup (filename) : g_path_get_basename (filename); for (int i = 0; !image && bundles [i]; ++i) { if (strcmp (bundles [i]->name, name) == 0) { -#ifdef ENABLE_NETCORE - // Since bundled images don't exist on disk, don't give them a legit filename - image = mono_image_open_from_data_internal (alc, (char*)bundles [i]->data, bundles [i]->size, FALSE, status, refonly, FALSE, name, NULL); -#else image = mono_image_open_from_data_internal (alc, (char*)bundles [i]->data, bundles [i]->size, FALSE, status, refonly, FALSE, name, name); -#endif break; } } @@ -2624,7 +2421,6 @@ mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc, const char *filena * purpose assembly loading mechanism. */ MonoImage *image = NULL; -#ifndef ENABLE_NETCORE if (!bundles) return NULL; @@ -2632,13 +2428,6 @@ mono_assembly_open_from_bundle (MonoAssemblyLoadContext *alc, const char *filena gboolean is_satellite = g_str_has_suffix (lowercase_filename, ".resources.dll"); g_free (lowercase_filename); image = open_from_bundle_internal (alc, filename, status, refonly, is_satellite); -#else - gboolean is_satellite = culture && culture [0] != 0;; - if (is_satellite) - image = open_from_satellite_bundle (alc, filename, status, refonly, culture); - else - image = open_from_bundle_internal (alc, filename, status, refonly, FALSE); -#endif if (image) { mono_image_addref (image); @@ -2857,10 +2646,8 @@ mono_assembly_request_open (const char *filename, const MonoAssemblyOpenRequest if (!loaded_from_bundle) mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Assembly Loader loaded assembly from location: '%s'.", filename); -#ifndef ENABLE_NETCORE // no XML file loading on netcore if (!refonly) mono_config_for_assembly_internal (ass->image); -#endif } /* Clear the reference added by mono_image_open */ @@ -3034,13 +2821,11 @@ chain_redirections_loadfrom (MonoAssemblyLoadContext *alc, MonoImage *image, Mon MonoImageOpenStatus status = MONO_IMAGE_OK; MonoAssembly *redirected = NULL; -#ifndef ENABLE_NETCORE redirected = mono_assembly_binding_applies_to_image (alc, image, &status); if (redirected || status != MONO_IMAGE_OK) { *out_status = status; return redirected; } -#endif redirected = mono_problematic_image_reprobe (alc, image, &status); if (redirected || status != MONO_IMAGE_OK) { @@ -3052,7 +2837,6 @@ chain_redirections_loadfrom (MonoAssemblyLoadContext *alc, MonoImage *image, Mon return NULL; } -#ifndef ENABLE_NETCORE /** * mono_assembly_binding_applies_to_image: * \param alc AssemblyLoadContext to load into @@ -3116,7 +2900,6 @@ mono_assembly_binding_applies_to_image (MonoAssemblyLoadContext *alc, MonoImage* mono_assembly_name_free_internal (&probed_aname); return result_ass; } -#endif /** * mono_problematic_image_reprobe: @@ -3547,48 +3330,6 @@ build_assembly_name (const char *name, const char *version, const char *culture, memset (aname, 0, sizeof (MonoAssemblyName)); if (version) { -#ifdef ENABLE_NETCORE - int parts [4]; - int i; - int part_len; - - parts [2] = -1; - parts [3] = -1; - const char *s = version; - version_parts = 0; - for (i = 0; i < 4; ++i) { - int n = sscanf (s, "%u%n", &parts [i], &part_len); - if (n != 1) - return FALSE; - if (parts [i] < 0 || parts [i] > 65535) - return FALSE; - if (i < 2 && parts [i] == 65535) - return FALSE; - version_parts ++; - s += part_len; - if (s [0] == '\0') - break; - if (i < 3) { - if (s [0] != '.') - return FALSE; - s ++; - } - } - if (s [0] != '\0') - return FALSE; - if (version_parts < 2 || version_parts > 4) - return FALSE; - aname->major = parts [0]; - aname->minor = parts [1]; - if (version_parts >= 3) - aname->build = parts [2]; - else - aname->build = -1; - if (version_parts == 4) - aname->revision = parts [3]; - else - aname->revision = -1; -#else gint major, minor, build, revision; version_parts = sscanf (version, "%u.%u.%u.%u", &major, &minor, &build, &revision); @@ -3608,7 +3349,6 @@ build_assembly_name (const char *name, const char *version, const char *culture, aname->revision = revision; else aname->revision = 0; -#endif } aname->flags = flags; @@ -3838,9 +3578,6 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole goto cleanup_and_fail; } -#ifdef ENABLE_NETCORE - flags |= arch << 4; -#endif g_free (procarch_uq); tmp++; @@ -4492,7 +4229,6 @@ mono_domain_parse_assembly_bindings (MonoDomain *domain, int amajor, int aminor, mono_domain_unlock (domain); } -#ifndef ENABLE_NETCORE static MonoAssemblyName* mono_assembly_apply_binding (MonoAssemblyName *aname, MonoAssemblyName *dest_name) { @@ -4605,7 +4341,6 @@ return_aname: exit: HANDLE_FUNCTION_RETURN_VAL (result); } -#endif #ifndef DISABLE_GAC /** @@ -4699,24 +4434,6 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus * return corlib; } -#ifdef ENABLE_NETCORE - aname = mono_assembly_name_new (MONO_ASSEMBLY_CORLIB_NAME); - corlib = invoke_assembly_preload_hook (req.request.alc, aname, NULL); - /* MonoCore preload hook should know how to find it */ - /* FIXME: AOT compiler comes here without an installed hook. */ - if (!corlib) { - if (assemblies_path) { // Custom assemblies path set via MONO_PATH or mono_set_assemblies_path - char *corlib_name = g_strdup_printf ("%s.dll", MONO_ASSEMBLY_CORLIB_NAME); - corlib = load_in_path (corlib_name, (const char**)assemblies_path, &req, status); - } - } - if (!corlib) { - /* Maybe its in a bundle */ - char *corlib_name = g_strdup_printf ("%s.dll", MONO_ASSEMBLY_CORLIB_NAME); - corlib = mono_assembly_request_open (corlib_name, &req, status); - } - g_assert (corlib); -#else // A nonstandard preload hook may provide a special mscorlib assembly aname = mono_assembly_name_new ("mscorlib.dll"); corlib = invoke_assembly_preload_hook (req.request.alc, aname, assemblies_path); @@ -4748,7 +4465,6 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus * return_corlib_and_facades: if (corlib) // FIXME: stop hardcoding 4.5 here default_path [1] = g_strdup_printf ("%s/Facades", corlib->basedir); -#endif /*!ENABLE_NETCORE*/ return corlib; } @@ -4785,9 +4501,6 @@ mono_assembly_candidate_predicate_sn_same_name (MonoAssembly *candidate, gpointe g_free (s); } -#ifdef ENABLE_NETCORE - return mono_assembly_check_name_match (wanted_name, candidate_name); -#else /* Wanted name has no token, not strongly named: always matches. */ if (0 == wanted_name->public_key_token [0]) { mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Predicate: wanted has no token, returning TRUE"); @@ -4802,19 +4515,12 @@ mono_assembly_candidate_predicate_sn_same_name (MonoAssembly *candidate, gpointe return mono_assembly_check_name_match (wanted_name, candidate_name) || framework_assembly_sn_match (wanted_name, candidate_name); -#endif } gboolean mono_assembly_check_name_match (MonoAssemblyName *wanted_name, MonoAssemblyName *candidate_name) { -#if ENABLE_NETCORE - gboolean result = mono_assembly_names_equal_flags (wanted_name, candidate_name, MONO_ANAME_EQ_IGNORE_VERSION | MONO_ANAME_EQ_IGNORE_PUBKEY); - if (result && assembly_names_compare_versions (wanted_name, candidate_name, -1) > 0) - result = FALSE; -#else gboolean result = mono_assembly_names_equal_flags (wanted_name, candidate_name, MONO_ANAME_EQ_NONE); -#endif mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Predicate: candidate and wanted names %s", result ? "match, returning TRUE" : "don't match, returning FALSE"); @@ -4856,7 +4562,6 @@ framework_assembly_sn_match (MonoAssemblyName *wanted_name, MonoAssemblyName *ca return FALSE; } -#ifndef ENABLE_NETCORE static MonoAssembly* mono_assembly_request_byname_nosearch (MonoAssemblyName *aname, const MonoAssemblyByNameRequest *req, @@ -4887,7 +4592,6 @@ mono_assembly_request_byname_nosearch (MonoAssemblyName *aname, result = mono_assembly_load_full_gac_base_default (aname, req->basedir, req->request.alc, req->request.asmctx, status); return result; } -#endif /* Like mono_assembly_request_byname_nosearch, but don't ask the preload look (ie, * the appdomain) to run. Just looks in the gac, the specified base dir or the @@ -4987,7 +4691,6 @@ mono_assembly_request_byname (MonoAssemblyName *aname, const MonoAssemblyByNameR MonoAssembly *result; if (status) *status = MONO_IMAGE_OK; -#ifndef ENABLE_NETCORE result = mono_assembly_request_byname_nosearch (aname, req, status); const gboolean refonly = req->request.asmctx == MONO_ASMCTX_REFONLY; @@ -4996,9 +4699,6 @@ mono_assembly_request_byname (MonoAssemblyName *aname, const MonoAssemblyByNameR result = mono_assembly_invoke_search_hook_internal (req->request.alc, req->requesting_assembly, aname, refonly, TRUE); result = prevent_reference_assembly_from_running (result, refonly); } -#else - result = netcore_load_reference (aname, req->request.alc, req->requesting_assembly, !req->no_postload_search); -#endif return result; } @@ -5008,11 +4708,7 @@ mono_assembly_load_full_alc (MonoGCHandle alc_gchandle, MonoAssemblyName *aname, MonoAssembly *res; MONO_ENTER_GC_UNSAFE; MonoAssemblyByNameRequest req; -#ifdef ENABLE_NETCORE - MonoAssemblyLoadContext *alc = mono_alc_from_gchandle (alc_gchandle); -#else MonoAssemblyLoadContext *alc = mono_domain_default_alc (mono_domain_get ()); -#endif mono_assembly_request_prepare_byname (&req, MONO_ASMCTX_DEFAULT, alc); req.requesting_assembly = NULL; req.basedir = basedir; @@ -5416,9 +5112,6 @@ mono_create_new_bundled_satellite_assembly (const char *name, const char *cultur void mono_register_bundled_satellite_assemblies (const MonoBundledSatelliteAssembly **assemblies) { -#ifdef ENABLE_NETCORE - satellite_bundles = assemblies; -#endif } #define MONO_DECLSEC_FORMAT_10 0x3C diff --git a/mono/metadata/class-init.c b/mono/metadata/class-init.c index b849dca6b4e..9e0036d63d6 100644 --- a/mono/metadata/class-init.c +++ b/mono/metadata/class-init.c @@ -34,16 +34,9 @@ #undef REALLY_INCLUDE_CLASS_DEF #endif -#ifdef ENABLE_NETCORE -#define FEATURE_COVARIANT_RETURNS -#endif gboolean mono_print_vtable = FALSE; gboolean mono_align_small_structs = FALSE; -#ifdef ENABLE_NETCORE -/* Set by the EE */ -gint32 mono_simd_register_size; -#endif /* Statistics */ static gint32 classes_size; @@ -298,12 +291,6 @@ mono_class_setup_fields (MonoClass *klass) if (explicit_size) instance_size += real_size; -#ifdef ENABLE_NETCORE - if (mono_is_corlib_image (klass->image) && !strcmp (klass->name_space, "System.Numerics") && !strcmp (klass->name, "Register")) { - if (mono_simd_register_size) - instance_size += mono_simd_register_size; - } -#endif /* * This function can recursively call itself. @@ -643,11 +630,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token, MonoError /* reserve space to store vector pointer in arrays */ if (mono_is_corlib_image (image) && !strcmp (nspace, "System") && !strcmp (name, "Array")) { klass->instance_size += 2 * TARGET_SIZEOF_VOID_P; -#ifndef ENABLE_NETCORE g_assert (mono_class_get_field_count (klass) == 0); -#else - /* TODO: check that array has 0 non-const fields */ -#endif } if (klass->enumtype) { @@ -865,14 +848,6 @@ mono_class_create_generic_inst (MonoGenericClass *gclass) if (mono_type_is_primitive (gclass->context.class_inst->type_argv [0])) klass->simd_type = 1; } -#ifdef ENABLE_NETCORE - if (mono_is_corlib_image (gklass->image) && - (!strcmp (gklass->name, "Vector`1") || !strcmp (gklass->name, "Vector128`1") || !strcmp (gklass->name, "Vector256`1"))) { - MonoType *etype = gclass->context.class_inst->type_argv [0]; - if (mono_type_is_primitive (etype) && etype->type != MONO_TYPE_CHAR && etype->type != MONO_TYPE_BOOLEAN) - klass->simd_type = 1; - } -#endif klass->is_array_special_interface = gklass->is_array_special_interface; @@ -2165,34 +2140,6 @@ mono_class_layout_fields (MonoClass *klass, int base_instance_size, int packing_ } /* check for incorrectly aligned or overlapped by a non-object field */ -#ifdef ENABLE_NETCORE - guint8 *layout_check; - if (has_references) { - layout_check = g_new0 (guint8, real_size); - for (i = 0; i < top && !mono_class_has_failure (klass); i++) { - field = &klass->fields [i]; - if (!field) - continue; - if (mono_field_is_deleted (field)) - continue; - if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) - continue; - int align = 0; - int size = mono_type_size (field->type, &align); - MonoType *ftype = mono_type_get_underlying_type (field->type); - ftype = mono_type_get_basic_type_from_generic (ftype); - guint8 type = type_has_references (klass, ftype) ? 1 : 2; - for (int j = 0; j < size; j++) { - if (layout_check [field_offsets [i] + j] != 0 && layout_check [field_offsets [i] + j] != type) { - mono_class_set_type_load_failure (klass, "Could not load type '%s' because it contains an object field at offset %d that is incorrectly aligned or overlapped by a non-object field.", klass->name, field->offset); - break; - } - layout_check [field_offsets [i] + j] = type; - } - } - g_free (layout_check); - } -#endif instance_size = MAX (real_size, instance_size); if (!((layout == TYPE_ATTRIBUTE_EXPLICIT_LAYOUT) && explicit_size)) { diff --git a/mono/metadata/class-internals.h b/mono/metadata/class-internals.h index 0e9c76afb9f..8512770fc0d 100644 --- a/mono/metadata/class-internals.h +++ b/mono/metadata/class-internals.h @@ -1004,9 +1004,7 @@ typedef struct { MonoClass *iremotingtypeinfo_class; #endif MonoClass *mono_method_message_class; -#ifndef ENABLE_NETCORE MonoClass *appdomain_class; -#endif MonoClass *field_info_class; MonoClass *method_info_class; MonoClass *stack_frame_class; @@ -1021,13 +1019,7 @@ typedef struct { MonoClass *critical_finalizer_object; /* MAYBE NULL */ MonoClass *generic_ireadonlylist_class; MonoClass *generic_ienumerator_class; -#ifdef ENABLE_NETCORE - MonoClass *alc_class; - MonoClass *appcontext_class; -#endif -#ifndef ENABLE_NETCORE MonoMethod *threadpool_perform_wait_callback_method; -#endif } MonoDefaults; #ifdef DISABLE_REMOTING @@ -1101,9 +1093,7 @@ GENERATE_GET_CLASS_WITH_CACHE_DECL (variant) #endif MonoClass* mono_class_get_appdomain_class (void); -#ifndef ENABLE_NETCORE GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain_setup); -#endif GENERATE_GET_CLASS_WITH_CACHE_DECL (appdomain_unloaded_exception) GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL (appdomain_unloaded_exception) @@ -1112,10 +1102,6 @@ GENERATE_GET_CLASS_WITH_CACHE_DECL (valuetype) GENERATE_TRY_GET_CLASS_WITH_CACHE_DECL(handleref) -#ifdef ENABLE_NETCORE -GENERATE_GET_CLASS_WITH_CACHE_DECL (assembly_load_context) -GENERATE_GET_CLASS_WITH_CACHE_DECL (native_library) -#endif /* If you need a MonoType, use one of the mono_get_*_type () functions in class-inlines.h */ extern MonoDefaults mono_defaults; @@ -1614,12 +1600,7 @@ m_field_get_offset (MonoClassField *field) static inline MonoMemoryManager* m_class_get_mem_manager (MonoDomain *domain, MonoClass *klass) { -#ifdef ENABLE_NETCORE - // FIXME: return mono_domain_memory_manager (domain); -#else - return mono_domain_memory_manager (domain); -#endif } static inline void * @@ -1637,12 +1618,7 @@ m_class_alloc0 (MonoDomain *domain, MonoClass *klass, guint size) static inline MonoMemoryManager* m_method_get_mem_manager (MonoDomain *domain, MonoMethod *method) { -#ifdef ENABLE_NETCORE - // FIXME: return mono_domain_memory_manager (domain); -#else - return mono_domain_memory_manager (domain); -#endif } static inline void * diff --git a/mono/metadata/class-setup-vtable.c b/mono/metadata/class-setup-vtable.c index 486fed9f60c..4017e73fea6 100644 --- a/mono/metadata/class-setup-vtable.c +++ b/mono/metadata/class-setup-vtable.c @@ -23,9 +23,6 @@ #undef REALLY_INCLUDE_CLASS_DEF #endif -#ifdef ENABLE_NETCORE -#define FEATURE_COVARIANT_RETURNS -#endif static void mono_class_setup_vtable_full (MonoClass *klass, GList *in_setup); diff --git a/mono/metadata/class.c b/mono/metadata/class.c index 7835e5ad11e..c2abf0e582d 100644 --- a/mono/metadata/class.c +++ b/mono/metadata/class.c @@ -6286,10 +6286,6 @@ gboolean mono_type_is_valid_enum_basetype (MonoType * type) { case MONO_TYPE_U8: case MONO_TYPE_I: case MONO_TYPE_U: -#if ENABLE_NETCORE - case MONO_TYPE_R8: - case MONO_TYPE_R4: -#endif return TRUE; default: return FALSE; diff --git a/mono/metadata/cominterop.c b/mono/metadata/cominterop.c index e80cca9f292..9cb93585cc9 100644 --- a/mono/metadata/cominterop.c +++ b/mono/metadata/cominterop.c @@ -3160,17 +3160,11 @@ default_ptr_to_bstr (const gunichar2* ptr, int slen) // The allocation pre-string is pointer-sized, and then only 4 bytes are used for the length regardless. Additionally, // the total length is also aligned to a 16-byte boundary. This preserves the old behavior on legacy and fixes it for // netcore moving forward. -#ifdef ENABLE_NETCORE - mono_bstr const s = (mono_bstr)mono_bstr_alloc ((slen + 1) * sizeof (gunichar2)); - if (s == NULL) - return NULL; -#else /* allocate len + 1 utf16 characters plus 4 byte integer for length*/ guint32 * const ret = (guint32 *)g_malloc ((slen + 1) * sizeof (gunichar2) + sizeof (guint32)); if (ret == NULL) return NULL; mono_bstr const s = (mono_bstr)(ret + 1); -#endif mono_bstr_set_length (s, slen); if (ptr) memcpy (s, ptr, slen * sizeof (gunichar2)); @@ -3286,11 +3280,7 @@ mono_free_bstr (/*mono_bstr_const*/gpointer bstr) #ifndef DISABLE_COM if (com_provider == MONO_COM_DEFAULT) { #endif -#ifdef ENABLE_NETCORE - g_free (((char *)bstr) - SIZEOF_VOID_P); -#else // In Mono, historically BSTR was allocated with a guaranteed size prefix of 4 bytes regardless of platform g_free (((char *)bstr) - 4); -#endif #ifndef DISABLE_COM } else if (com_provider == MONO_COM_MS && init_com_provider_ms ()) { sys_free_string_ms ((mono_bstr_const)bstr); @@ -4205,7 +4195,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_QueryInterfaceInternal (MonoIUn #endif /* HOST_WIN32 */ #endif /* DISABLE_COM */ -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (mono_bstr_const ptr, MonoError *error) { @@ -4215,7 +4204,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR (mono_bstr_cons } return mono_string_from_bstr_checked (ptr, error); } -#endif mono_bstr ves_icall_System_Runtime_InteropServices_Marshal_BufferToBSTR (const gunichar2* ptr, int len) diff --git a/mono/metadata/console-unix.c b/mono/metadata/console-unix.c index 908b2d60aa4..52c2117e8bb 100644 --- a/mono/metadata/console-unix.c +++ b/mono/metadata/console-unix.c @@ -40,7 +40,6 @@ #include <mono/metadata/exception.h> #include "icall-decl.h" -#ifndef ENABLE_NETCORE /* On solaris, curses.h must come before both termios.h and term.h */ #ifdef HAVE_CURSES_H @@ -511,16 +510,3 @@ ves_icall_System_ConsoleDriver_TtySetup (MonoStringHandle keypad, MonoStringHand return TRUE; } -#else /* ENABLE_NETCORE */ - -void -mono_console_init (void) -{ -} - -void -mono_console_handle_async_ops (void) -{ -} - -#endif diff --git a/mono/metadata/custom-attrs.c b/mono/metadata/custom-attrs.c index fe3165f1690..2b21524a76d 100644 --- a/mono/metadata/custom-attrs.c +++ b/mono/metadata/custom-attrs.c @@ -1435,16 +1435,11 @@ ves_icall_System_Reflection_CustomAttributeData_ResolveArgumentsInternal (MonoRe } MONO_HANDLE_ASSIGN_RAW (minfo_h, minfo); -#if ENABLE_NETCORE - namedarg = create_cattr_named_arg (minfo, obj, error); - MONO_HANDLE_ASSIGN_RAW (namedarg_h, namedarg); -#else MonoObject* typedarg = create_cattr_typed_arg (arginfo [i].type, obj, error); MONO_HANDLE_ASSIGN_RAW (typedarg_h, typedarg); goto_if_nok (error, leave); namedarg = create_cattr_named_arg (minfo, typedarg, error); MONO_HANDLE_ASSIGN_RAW (namedarg_h, namedarg); -#endif goto_if_nok (error, leave); mono_array_setref_internal (named_args, i, namedarg); @@ -2219,15 +2214,10 @@ mono_reflection_get_custom_attrs_info_checked (MonoObjectHandle obj, MonoError * MonoArrayHandle cattrs = MONO_HANDLE_NEW_GET (MonoArray, mb, cattrs); cinfo = mono_custom_attrs_from_builders_handle (NULL, &dynamic_image->image, cattrs); } else if (strcmp ("ConstructorBuilder", klass_name) == 0) { -#ifdef ENABLE_NETCORE - mono_error_set_not_supported (error, ""); - goto leave; -#else MonoReflectionCtorBuilderHandle cb = MONO_HANDLE_CAST (MonoReflectionCtorBuilder, obj); MonoMethod *mhandle = MONO_HANDLE_GETVAL (cb, mhandle); MonoArrayHandle cattrs = MONO_HANDLE_NEW_GET (MonoArray, cb, cattrs); cinfo = mono_custom_attrs_from_builders_handle (NULL, m_class_get_image (mhandle->klass), cattrs); -#endif } else if (strcmp ("MethodBuilder", klass_name) == 0) { MonoReflectionMethodBuilderHandle mb = MONO_HANDLE_CAST (MonoReflectionMethodBuilder, obj); MonoMethod *mhandle = MONO_HANDLE_GETVAL (mb, mhandle); diff --git a/mono/metadata/domain-internals.h b/mono/metadata/domain-internals.h index b33b88e2a46..4adffe49d89 100644 --- a/mono/metadata/domain-internals.h +++ b/mono/metadata/domain-internals.h @@ -27,20 +27,10 @@ * So we move it to Mono.MonoDomain * */ -#ifndef ENABLE_NETCORE #define MONO_APPDOMAIN_CLASS_NAME_SPACE "System" #define MONO_APPDOMAIN_CLASS_NAME "AppDomain" #define MONO_APPDOMAIN_SETUP_CLASS_NAME_SPACE "System" #define MONO_APPDOMAIN_SETUP_CLASS_NAME "AppDomainSetup" -#else -/* We don't care anymore about the managed appdomain representation - * so we just use a sentinel System.Object in the parts of the code that still care - */ -/* -#define MONO_APPDOMAIN_CLASS_NAME_SPACE "System" -#define MONO_APPDOMAIN_CLASS_NAME "Object" -*/ -#endif G_BEGIN_DECLS @@ -52,7 +42,6 @@ G_BEGIN_DECLS */ extern gboolean mono_dont_free_domains; -#ifndef ENABLE_NETCORE /* This is a copy of System.AppDomainSetup */ typedef struct { MonoObject object; @@ -79,7 +68,6 @@ typedef struct { MonoArray *configuration_bytes; MonoArray *serialized_non_primitives; } MonoAppDomainSetup; -#endif typedef struct _MonoJitInfoTable MonoJitInfoTable; typedef struct _MonoJitInfoTableChunk MonoJitInfoTableChunk; @@ -349,12 +337,8 @@ struct _MonoDomain { * keep all the managed objects close to each other for the precise GC * For the Boehm GC we additionally keep close also other GC-tracked pointers. */ -#ifndef ENABLE_NETCORE #define MONO_DOMAIN_FIRST_OBJECT setup MonoAppDomainSetup *setup; -#else -#define MONO_DOMAIN_FIRST_OBJECT domain -#endif MonoAppDomain *domain; MonoAppContext *default_context; MonoException *out_of_memory_ex; @@ -465,16 +449,9 @@ struct _MonoDomain { guint32 execution_context_field_offset; -#ifdef ENABLE_NETCORE - GSList *alcs; - MonoAssemblyLoadContext *default_alc; - MonoCoopMutex alcs_lock; /* Used when accessing 'alcs' */ -#endif -#ifndef ENABLE_NETCORE // Holds domain code memory MonoMemoryManager *memory_manager; -#endif }; typedef struct { @@ -570,8 +547,6 @@ mono_make_shadow_copy (const char *filename, MonoError *error); gboolean mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name); -// TODO: remove these on netcore, we should always be explicit about allocating from ALCs -//#ifndef ENABLE_NETCORE gpointer mono_domain_alloc (MonoDomain *domain, guint size); @@ -582,8 +557,6 @@ mono_domain_alloc0 (MonoDomain *domain, guint size); #define mono_domain_alloc0(domain, size) (g_cast (mono_domain_alloc0 ((domain), (size)))) -//#endif - gpointer mono_domain_alloc0_lock_free (MonoDomain *domain, guint size); @@ -595,10 +568,8 @@ mono_domain_unset (void); void mono_domain_set_internal_with_options (MonoDomain *domain, gboolean migrate_exception); -#ifndef ENABLE_NETCORE gboolean mono_domain_set_config_checked (MonoDomain *domain, const char *base_dir, const char *config_file_name, MonoError *error); -#endif MonoTryBlockHoleTableJitInfo* mono_jit_info_get_try_block_hole_table_info (MonoJitInfo *ji); @@ -655,9 +626,7 @@ mono_try_assembly_resolve (MonoAssemblyLoadContext *alc, const char *fname, Mono MonoAssembly * mono_domain_assembly_postload_search (MonoAssemblyLoadContext *alc, MonoAssembly *requesting, MonoAssemblyName *aname, gboolean refonly, gboolean postload, gpointer user_data, MonoError *error); -#ifndef ENABLE_NETCORE void mono_domain_set_options_from_config (MonoDomain *domain); -#endif int mono_framework_version (void); @@ -696,19 +665,6 @@ mono_domain_set_fast (MonoDomain *domain, gboolean force); MonoAssemblyLoadContext * mono_domain_default_alc (MonoDomain *domain); -#ifdef ENABLE_NETCORE -static inline void -mono_domain_alcs_lock (MonoDomain *domain) -{ - mono_coop_mutex_lock (&domain->alcs_lock); -} - -static inline void -mono_domain_alcs_unlock (MonoDomain *domain) -{ - mono_coop_mutex_unlock (&domain->alcs_lock); -} -#endif static inline MonoAssemblyLoadContext * @@ -724,11 +680,7 @@ mono_domain_ambient_alc (MonoDomain *domain) static inline MonoMemoryManager * mono_domain_memory_manager (MonoDomain *domain) { -#ifdef ENABLE_NETCORE - return (MonoMemoryManager *)mono_domain_default_alc (domain)->memory_manager; -#else return domain->memory_manager; -#endif } static inline MonoMemoryManager * diff --git a/mono/metadata/domain.c b/mono/metadata/domain.c index 4af4b21702d..6d455e4fa77 100644 --- a/mono/metadata/domain.c +++ b/mono/metadata/domain.c @@ -66,13 +66,8 @@ mono_thread_info_tls_set (info, TLS_KEY_DOMAIN, (x)); \ } while (FALSE) -#ifndef ENABLE_NETCORE #define GET_APPCONTEXT() (mono_thread_internal_current ()->current_appcontext) #define SET_APPCONTEXT(x) MONO_OBJECT_SETREF_INTERNAL (mono_thread_internal_current (), current_appcontext, (x)) -#else -#define GET_APPCONTEXT() NULL -#define SET_APPCONTEXT(x) -#endif static guint16 appdomain_list_size = 0; static guint16 appdomain_next = 0; @@ -432,17 +427,13 @@ mono_domain_create (void) domain->shadow_serial = shadow_serial; domain->domain = NULL; -#ifndef ENABLE_NETCORE domain->setup = NULL; -#endif domain->friendly_name = NULL; domain->search_path = NULL; MONO_PROFILER_RAISE (domain_loading, (domain)); -#ifndef ENABLE_NETCORE domain->memory_manager = (MonoMemoryManager *)mono_mem_manager_create_singleton (NULL, domain, TRUE); -#endif domain->lock_free_mp = lock_free_mempool_new (); domain->env = mono_g_hash_table_new_type_internal ((GHashFunc)mono_string_hash_internal, (GCompareFunc)mono_string_equal_internal, MONO_HASH_KEY_VALUE_GC, MONO_ROOT_SOURCE_DOMAIN, domain, "Domain Environment Variable Table"); @@ -464,9 +455,6 @@ mono_domain_create (void) mono_os_mutex_init_recursive (&domain->jit_code_hash_lock); mono_os_mutex_init_recursive (&domain->finalizable_objects_hash_lock); -#ifdef ENABLE_NETCORE - mono_coop_mutex_init (&domain->alcs_lock); -#endif mono_appdomains_lock (); domain_id_alloc (domain); @@ -479,9 +467,6 @@ mono_domain_create (void) mono_debug_domain_create (domain); -#ifdef ENABLE_NETCORE - mono_alc_create_default (domain); -#endif if (create_domain_hook) create_domain_hook (domain); @@ -705,10 +690,8 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_defaults.multicastdelegate_class = mono_class_load_from_name ( mono_defaults.corlib, "System", "MulticastDelegate"); -#ifndef ENABLE_NETCORE mono_defaults.manualresetevent_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Threading", "ManualResetEvent"); -#endif mono_defaults.typehandle_class = mono_class_load_from_name ( mono_defaults.corlib, "System", "RuntimeTypeHandle"); @@ -731,20 +714,13 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_defaults.thread_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Threading", "Thread"); -#ifdef ENABLE_NETCORE - /* There is only one thread class */ - mono_defaults.internal_thread_class = mono_defaults.thread_class; -#else mono_defaults.internal_thread_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Threading", "InternalThread"); mono_defaults.threadabortexception_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Threading", "ThreadAbortException"); -#endif -#ifndef ENABLE_NETCORE mono_defaults.appdomain_class = mono_class_get_appdomain_class (); -#endif #ifndef DISABLE_REMOTING mono_defaults.transparent_proxy_class = mono_class_load_from_name ( @@ -762,10 +738,8 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * #endif /* FIXME pretty sure this is wrong and netcore has messages... */ -#ifndef ENABLE_NETCORE mono_defaults.mono_method_message_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "MonoMethodMessage"); -#endif mono_defaults.field_info_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Reflection", "FieldInfo"); @@ -773,13 +747,8 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_defaults.method_info_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Reflection", "MethodInfo"); -#ifdef ENABLE_NETCORE - mono_defaults.stack_frame_class = mono_class_load_from_name ( - mono_defaults.corlib, "System.Diagnostics", "MonoStackFrame"); -#else mono_defaults.stack_frame_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Diagnostics", "StackFrame"); -#endif mono_defaults.marshal_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Runtime.InteropServices", "Marshal"); @@ -813,12 +782,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_defaults.generic_ienumerator_class = mono_class_try_load_from_name ( mono_defaults.corlib, "System.Collections.Generic", "IEnumerator`1"); -#ifdef ENABLE_NETCORE - mono_defaults.alc_class = mono_class_get_assembly_load_context_class (); - mono_defaults.appcontext_class = mono_class_try_load_from_name (mono_defaults.corlib, "System", "AppContext"); -#endif -#ifndef ENABLE_NETCORE MonoClass *threadpool_wait_callback_class = mono_class_load_from_name ( mono_defaults.corlib, "System.Threading", "_ThreadPoolWaitCallback"); @@ -826,7 +790,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * mono_defaults.threadpool_perform_wait_callback_method = mono_class_get_method_from_name_checked ( threadpool_wait_callback_class, "PerformWaitCallback", 0, 0, error); mono_error_assert_ok (error); -#endif domain->friendly_name = g_path_get_basename (filename); @@ -1036,7 +999,6 @@ mono_domain_ensure_entry_assembly (MonoDomain *domain, MonoAssembly *assembly) if (!mono_runtime_get_no_exec () && !domain->entry_assembly && assembly) { domain->entry_assembly = assembly; -#ifndef ENABLE_NETCORE gchar *str; ERROR_DECL (error); /* Domains created from another domain already have application_base and configuration_file set */ @@ -1054,7 +1016,6 @@ mono_domain_ensure_entry_assembly (MonoDomain *domain, MonoAssembly *assembly) g_free (str); mono_domain_set_options_from_config (domain); } -#endif } } @@ -1097,9 +1058,6 @@ mono_domain_assembly_open_internal (MonoDomain *domain, MonoAssemblyLoadContext // On netcore, this is necessary because we check the AppContext.BaseDirectory property as part of the assembly lookup algorithm // AppContext.BaseDirectory can sometimes fall back to checking the location of the entry_assembly, which should be non-null -#ifdef ENABLE_NETCORE - mono_domain_ensure_entry_assembly (domain, ass); -#endif return ass; } @@ -1118,7 +1076,6 @@ mono_domain_assembly_open_internal (MonoDomain *domain, MonoAssemblyLoadContext void mono_domain_free (MonoDomain *domain, gboolean force) { -#ifndef ENABLE_NETCORE int code_size, code_alloc; GSList *tmp; gpointer *p; @@ -1290,9 +1247,6 @@ mono_domain_free (MonoDomain *domain, gboolean force) if (domain == mono_root_domain) mono_root_domain = NULL; -#else - g_assert_not_reached (); -#endif } /** @@ -1961,9 +1915,5 @@ mono_domain_get_assemblies (MonoDomain *domain, gboolean refonly) MonoAssemblyLoadContext * mono_domain_default_alc (MonoDomain *domain) { -#ifndef ENABLE_NETCORE return NULL; -#else - return domain->default_alc; -#endif } diff --git a/mono/metadata/environment.c b/mono/metadata/environment.c index cabd09543fb..5bec6e3452a 100644 --- a/mono/metadata/environment.c +++ b/mono/metadata/environment.c @@ -62,7 +62,6 @@ mono_get_os_cmd_line (void) return mono_runtime_get_cmd_line (mini_argc, mini_argv); } -#ifndef ENABLE_NETCORE /* note: we better manipulate the string in managed code (easier and safer) */ MonoStringHandle ves_icall_System_Environment_GetOSVersionString (MonoError *error) @@ -108,4 +107,3 @@ ves_icall_System_Environment_GetOSVersionString (MonoError *error) #endif return mono_string_new_handle (mono_domain_get (), "0.0.0.0", error); } -#endif diff --git a/mono/metadata/exception.c b/mono/metadata/exception.c index db668d23f65..e74df53cc4a 100644 --- a/mono/metadata/exception.c +++ b/mono/metadata/exception.c @@ -680,22 +680,11 @@ mono_get_exception_argument (const char *arg, const char *msg) return mono_get_exception_argument_internal ("ArgumentException", arg, msg); } -#ifndef ENABLE_NETCORE TYPED_HANDLE_DECL (MonoArgumentException); -#endif static MonoExceptionHandle mono_exception_new_argument_internal (const char *type, const char *arg, const char *msg, MonoError *error) { -#ifdef ENABLE_NETCORE - MonoStringHandle arg_str = arg ? mono_string_new_handle (mono_domain_get (), arg, error) : NULL_HANDLE_STRING; - MonoStringHandle msg_str = msg ? mono_string_new_handle (mono_domain_get (), msg, error) : NULL_HANDLE_STRING; - - if (!strcmp (type, "ArgumentException")) - return mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", type, msg_str, arg_str, error); - else - return mono_exception_from_name_two_strings_checked (mono_get_corlib (), "System", type, arg_str, msg_str, error); -#else MonoExceptionHandle ex = mono_exception_new_by_name_msg (mono_get_corlib (), "System", type, msg, error); if (arg && !MONO_HANDLE_IS_NULL (ex)) { @@ -704,7 +693,6 @@ mono_exception_new_argument_internal (const char *type, const char *arg, const c MONO_HANDLE_SET (argex, param_name, arg_str); } return ex; -#endif } MonoExceptionHandle diff --git a/mono/metadata/filewatcher.c b/mono/metadata/filewatcher.c index cf1646114cd..c1bb7574c70 100644 --- a/mono/metadata/filewatcher.c +++ b/mono/metadata/filewatcher.c @@ -12,7 +12,6 @@ #include <config.h> #include <mono/utils/mono-compiler.h> -#if !ENABLE_NETCORE #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -187,8 +186,3 @@ ves_icall_System_IO_KqueueMonitor_kevent_notimeout (int *kq_ptr, gpointer change #endif /* #if HAVE_KQUEUE */ -#else - -MONO_EMPTY_SOURCE_FILE (filewatcher); - -#endif /* !ENABLE_NETCORE */ diff --git a/mono/metadata/filewatcher.h b/mono/metadata/filewatcher.h index 3d484b92f61..b37ff30c08d 100644 --- a/mono/metadata/filewatcher.h +++ b/mono/metadata/filewatcher.h @@ -20,7 +20,6 @@ #include <unistd.h> #endif -#if !ENABLE_NETCORE ICALL_EXPORT gint ves_icall_System_IO_FSW_SupportsFSW (void); @@ -28,7 +27,6 @@ gint ves_icall_System_IO_FSW_SupportsFSW (void); ICALL_EXPORT int ves_icall_System_IO_KqueueMonitor_kevent_notimeout (int *kq, gpointer changelist, int nchanges, gpointer eventlist, int nevents); -#endif #ifdef HOST_IOS // This will obsoleted by System.Native as soon as it's ported to iOS MONO_API char* SystemNative_RealPath(const char* path); diff --git a/mono/metadata/gc.c b/mono/metadata/gc.c index f81963be552..6914262b4a6 100644 --- a/mono/metadata/gc.c +++ b/mono/metadata/gc.c @@ -650,51 +650,6 @@ ves_icall_System_GC_get_ephemeron_tombstone (MonoError *error) return MONO_HANDLE_NEW (MonoObject, mono_domain_get ()->ephemeron_tombstone); } -#if ENABLE_NETCORE - -MonoGCHandle -ves_icall_System_GCHandle_InternalAlloc (MonoObjectHandle obj, gint32 type, MonoError *error) -{ - MonoGCHandle handle = NULL; - - switch (type) { - case HANDLE_WEAK: - handle = mono_gchandle_new_weakref_from_handle (obj); - break; - case HANDLE_WEAK_TRACK: - handle = mono_gchandle_new_weakref_from_handle_track_resurrection (obj); - break; - case HANDLE_NORMAL: - handle = mono_gchandle_from_handle (obj, FALSE); - break; - case HANDLE_PINNED: - handle = mono_gchandle_from_handle (obj, TRUE); - break; - default: - g_assert_not_reached (); - } - return handle; -} - -void -ves_icall_System_GCHandle_InternalFree (MonoGCHandle handle, MonoError *error) -{ - mono_gchandle_free_internal (handle); -} - -MonoObjectHandle -ves_icall_System_GCHandle_InternalGet (MonoGCHandle handle, MonoError *error) -{ - return mono_gchandle_get_target_handle (handle); -} - -void -ves_icall_System_GCHandle_InternalSet (MonoGCHandle handle, MonoObjectHandle obj, MonoError *error) -{ - mono_gchandle_set_target_handle (handle, obj); -} - -#else MonoObjectHandle ves_icall_System_GCHandle_GetTarget (MonoGCHandle handle, MonoError *error) @@ -774,7 +729,6 @@ ves_icall_System_GCHandle_CheckCurrentDomain (MonoGCHandle gchandle) return mono_gchandle_is_in_domain (gchandle, mono_domain_get ()); } -#endif static MonoCoopSem finalizer_sem; static volatile gboolean finished; diff --git a/mono/metadata/icall-decl.h b/mono/metadata/icall-decl.h index b00b1aa36e5..6ca080535bb 100644 --- a/mono/metadata/icall-decl.h +++ b/mono/metadata/icall-decl.h @@ -136,20 +136,9 @@ ICALL_EXPORT float ves_icall_System_MathF_Sqrt (float); ICALL_EXPORT float ves_icall_System_MathF_Tan (float); ICALL_EXPORT float ves_icall_System_MathF_Tanh (float); ICALL_EXPORT float ves_icall_System_Math_Abs_single (float); -#if ENABLE_NETCORE -ICALL_EXPORT gint32 ves_icall_System_Math_ILogB (double); -ICALL_EXPORT double ves_icall_System_Math_Log2 (double); -ICALL_EXPORT double ves_icall_System_Math_FusedMultiplyAdd (double, double, double); -ICALL_EXPORT gint32 ves_icall_System_MathF_ILogB (float); -ICALL_EXPORT float ves_icall_System_MathF_Log2 (float); -ICALL_EXPORT float ves_icall_System_MathF_FusedMultiplyAdd (float, float, float); -#endif ICALL_EXPORT gint ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void); ICALL_EXPORT gint32 ves_icall_System_Environment_get_ProcessorCount (void); ICALL_EXPORT gint32 ves_icall_System_Environment_get_TickCount (void); -#if ENABLE_NETCORE -ICALL_EXPORT gint64 ves_icall_System_Environment_get_TickCount64 (void); -#endif ICALL_EXPORT gint64 ves_icall_System_DateTime_GetSystemTimeAsFileTime (void); ICALL_EXPORT gint64 ves_icall_System_Diagnostics_Process_GetProcessData (int, gint32, MonoProcessError*); ICALL_EXPORT gint64 ves_icall_System_Diagnostics_Stopwatch_GetTimestamp (void); @@ -157,9 +146,7 @@ ICALL_EXPORT gint64 ves_icall_System_GC_GetTotalMemory (MonoBoolean forceCollect ICALL_EXPORT gint64 ves_icall_System_Threading_Timer_GetTimeMonotonic (void); ICALL_EXPORT gpointer ves_icall_System_GCHandle_GetAddrOfPinnedObject (MonoGCHandle handle); ICALL_EXPORT int ves_icall_Interop_Sys_DoubleToString (double, char*, char*, int); -#if !ENABLE_NETCORE ICALL_EXPORT int ves_icall_System_Environment_get_Platform (void); -#endif ICALL_EXPORT int ves_icall_System_GC_GetCollectionCount (int); ICALL_EXPORT int ves_icall_System_GC_GetMaxGeneration (void); ICALL_EXPORT gint64 ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void); @@ -177,25 +164,13 @@ ICALL_EXPORT void ves_icall_System_GC_RecordPressure (gint64); ICALL_EXPORT void ves_icall_System_GC_WaitForPendingFinalizers (void); ICALL_EXPORT void ves_icall_System_GC_GetGCMemoryInfo (gint64*, gint64*, gint64*, gint64*, gint64*); -#if !ENABLE_NETCORE ICALL_EXPORT void ves_icall_System_IO_LogcatTextWriter_Log (const char*, gint32, const char*); -#endif ICALL_EXPORT void ves_icall_System_NumberFormatter_GetFormatterTables (guint64 const**, gint32 const**, gunichar2 const**, gunichar2 const**, gint64 const**, gint32 const**); -#if ENABLE_NETCORE -ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_Memmove (guint8*, guint8*, size_t); -ICALL_EXPORT void ves_icall_System_Buffer_BulkMoveWithWriteBarrier (guint8 *, guint8 *, size_t, MonoType *); -#else ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_Memmove (guint8*, guint8*, guint); ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_Memmove_wbarrier (guint8*, guint8*, guint, MonoType*); -#endif -#if ENABLE_NETCORE -ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8*, size_t); -#else ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8*, guint); -#endif ICALL_EXPORT void ves_icall_System_Runtime_RuntimeImports_ecvt_s(char*, size_t, double, int, int*, int*); -#if !defined(ENABLE_NETCORE) #if defined(ENABLE_MONODROID) || defined(ENABLE_MONOTOUCH) || defined(TARGET_WASM) ICALL_EXPORT gpointer ves_icall_System_IO_Compression_DeflateStreamNative_CreateZStream (gint32 compress, MonoBoolean gzip, gpointer feeder, gpointer data); ICALL_EXPORT gint32 ves_icall_System_IO_Compression_DeflateStreamNative_CloseZStream (gpointer stream); @@ -213,7 +188,6 @@ ICALL_EXPORT gpointer ves_icall_System_Net_NetworkInformation_LinuxNetworkChange ICALL_EXPORT gint32 ves_icall_System_Net_NetworkInformation_LinuxNetworkChange_ReadEvents (gpointer sock, gpointer buffer, gint32 count, gint32 size); ICALL_EXPORT gpointer ves_icall_System_Net_NetworkInformation_LinuxNetworkChange_CloseNLSocket (gpointer sock); #endif -#endif ICALL_EXPORT MonoBoolean ves_icall_Microsoft_Win32_NativeMethods_CloseProcess (gpointer handle); ICALL_EXPORT gpointer ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void); @@ -241,18 +215,6 @@ ICALL_EXPORT MonoBoolean ves_icall_System_Diagnostics_Debugger_IsAttached_intern ICALL_EXPORT MonoBoolean ves_icall_System_Diagnostics_Debugger_IsLogging (void); ICALL_EXPORT void ves_icall_System_Diagnostics_Debugger_Log (int level, MonoString *volatile* category, MonoString *volatile* message); -#ifdef ENABLE_NETCORE -ICALL_EXPORT intptr_t ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DefineEvent (intptr_t prov_handle, uint32_t event_id, int64_t keywords, uint32_t event_version, uint32_t level, const uint8_t *metadata, uint32_t metadata_len); -ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DeleteProvider (intptr_t prov_handle); -ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Disable (uint64_t session_id); -ICALL_EXPORT uint64_t ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Enable (const_gunichar2_ptr output_file, int32_t format, uint32_t circular_buffer_size_mb, const void *providers, uint32_t num_providers); -ICALL_EXPORT int32_t ves_icall_System_Diagnostics_Tracing_EventPipeInternal_EventActivityIdControl (uint32_t control_code, uint8_t *activity_id); -ICALL_EXPORT MonoBoolean ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetNextEvent (uint64_t session_id, void *instance); -ICALL_EXPORT intptr_t ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetProvider (const_gunichar2_ptr provider_name); -ICALL_EXPORT MonoBoolean ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetSessionInfo (uint64_t session_id, void *session_info); -ICALL_EXPORT intptr_t ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetWaitHandle (uint64_t session_id); -ICALL_EXPORT void ves_icall_System_Diagnostics_Tracing_EventPipeInternal_WriteEventData (intptr_t event_handle, void *event_data, uint32_t event_data_len, const uint8_t *activity_id, const uint8_t *related_activity_id); -#endif ICALL_EXPORT void ves_icall_Mono_RuntimeGPtrArrayHandle_GPtrArrayFree (GPtrArray *ptr_array); ICALL_EXPORT void ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct); @@ -295,19 +257,7 @@ ICALL_EXPORT gpointer ves_icall_System_Threading_Semaphore_CreateSemaphore_ic ICALL_EXPORT gpointer ves_icall_System_Threading_Semaphore_OpenSemaphore_icall (const gunichar2 *name, gint32 name_length, gint32 rights, gint32 *win32error); ICALL_EXPORT MonoBoolean ves_icall_System_Threading_Semaphore_ReleaseSemaphore_internal (gpointer handle, gint32 releaseCount, gint32 *prevcount); -#ifdef ENABLE_NETCORE -ICALL_EXPORT gpointer ves_icall_System_Threading_LowLevelLifoSemaphore_InitInternal (void); -ICALL_EXPORT void ves_icall_System_Threading_LowLevelLifoSemaphore_DeleteInternal (gpointer sem_ptr); -ICALL_EXPORT gint32 ves_icall_System_Threading_LowLevelLifoSemaphore_TimedWaitInternal (gpointer sem_ptr, gint32 timeout_ms); -ICALL_EXPORT void ves_icall_System_Threading_LowLevelLifoSemaphore_ReleaseInternal (gpointer sem_ptr, gint32 count); -#endif -#if defined(ENABLE_NETCORE) && defined(TARGET_AMD64) -ICALL_EXPORT void ves_icall_System_Runtime_Intrinsics_X86_X86Base___cpuidex (int abcd[4], int function_id, int subfunction_id); -#endif -#if defined(ENABLE_NETCORE) && defined(ENABLE_METADATA_UPDATE) -ICALL_EXPORT void ves_icall_Mono_Runtime_LoadMetadataUpdate (MonoAssembly *assm, gconstpointer dmeta_bytes, int32_t dmeta_len, gconstpointer dil_bytes, int32_t dil_len); -#endif #endif // __MONO_METADATA_ICALL_DECL_H__ diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 56dd99bccb5..19995156fa3 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -107,9 +107,6 @@ // "HandleIn" is the default for managed types, and is just called "Handle". // -#if ENABLE_NETCORE -#include "icall-def-netcore.h" -#else ICALL_TYPE(CLR_INTEROP_SYS, "Interop/Sys", CLR_INTEROP_SYS_1) NOHANDLES(ICALL(CLR_INTEROP_SYS_1, "DoubleToString", ves_icall_Interop_Sys_DoubleToString)) @@ -1136,7 +1133,6 @@ HANDLES(COMOBJ_2, "GetInterfaceInternal", ves_icall_System_ComObject_GetInterfac HANDLES(COMOBJ_3, "ReleaseInterfaces", ves_icall_System_ComObject_ReleaseInterfaces, void, 1, (MonoComObject)) #endif -#endif // This is similar to HANDLES() but is for icalls passed to register_jit_icall. // There is no metadata for these. No signature matching. diff --git a/mono/metadata/icall-eventpipe.c b/mono/metadata/icall-eventpipe.c index 87098b566b3..75768d30608 100644 --- a/mono/metadata/icall-eventpipe.c +++ b/mono/metadata/icall-eventpipe.c @@ -2,1086 +2,5 @@ #include <glib.h> #include <mono/utils/mono-compiler.h> -#ifdef ENABLE_NETCORE -#include <mono/metadata/icall-decl.h> - -#if defined(ENABLE_PERFTRACING) && !defined(DISABLE_EVENTPIPE) -#include <eventpipe/ep-rt-config.h> -#include <eventpipe/ep.h> -#include <eventpipe/ep-event.h> -#include <eventpipe/ep-event-instance.h> -#include <eventpipe/ep-session.h> - -#include <mono/utils/checked-build.h> -#include <mono/utils/mono-time.h> -#include <mono/utils/mono-proclib.h> -#include <mono/utils/mono-threads.h> -#include <mono/utils/mono-rand.h> -#include <mono/metadata/appdomain.h> -#include <mono/metadata/profiler.h> -#include <mono/metadata/assembly.h> -#include <mono/metadata/class-internals.h> -#include <mono/metadata/debug-internals.h> -#include <mono/mini/mini-runtime.h> - -// Rundown flags. -#define METHOD_FLAGS_DYNAMIC_METHOD 0x1 -#define METHOD_FLAGS_GENERIC_METHOD 0x2 -#define METHOD_FLAGS_SHARED_GENERIC_METHOD 0x4 -#define METHOD_FLAGS_JITTED_METHOD 0x8 -#define METHOD_FLAGS_JITTED_HELPER_METHOD 0x10 - -#define MODULE_FLAGS_NATIVE_MODULE 0x2 -#define MODULE_FLAGS_DYNAMIC_MODULE 0x4 -#define MODULE_FLAGS_MANIFEST_MODULE 0x8 - -#define ASSEMBLY_FLAGS_DYNAMIC_ASSEMBLY 0x2 -#define ASSEMBLY_FLAGS_NATIVE_ASSEMBLY 0x4 -#define ASSEMBLY_FLAGS_COLLECTIBLE_ASSEMBLY 0x8 - -#define DOMAIN_FLAGS_DEFAULT_DOMAIN 0x1 -#define DOMAIN_FLAGS_EXECUTABLE_DOMAIN 0x2 - -typedef enum _EventPipeActivityControlCode { - EP_ACTIVITY_CONTROL_GET_ID = 1, - EP_ACTIVITY_CONTROL_SET_ID = 2, - EP_ACTIVITY_CONTROL_CREATE_ID = 3, - EP_ACTIVITY_CONTROL_GET_SET_ID = 4, - EP_ACTIVITY_CONTROL_CREATE_SET_ID = 5 -} EventPipeActivityControlCode; - -typedef struct _EventPipeProviderConfigurationNative { - gunichar2 *provider_name; - uint64_t keywords; - uint32_t logging_level; - gunichar2 *filter_data; -} EventPipeProviderConfigurationNative; - -typedef struct _EventPipeSessionInfo { - int64_t starttime_as_utc_filetime; - int64_t start_timestamp; - int64_t timestamp_frequency; -} EventPipeSessionInfo; - -typedef struct _EventPipeEventInstanceData { - intptr_t provider_id; - uint32_t event_id; - uint32_t thread_id; - int64_t timestamp; - uint8_t activity_id [EP_ACTIVITY_ID_SIZE]; - uint8_t related_activity_id [EP_ACTIVITY_ID_SIZE]; - const uint8_t *payload; - uint32_t payload_len; -} EventPipeEventInstanceData; - -typedef struct _EventPipeFireMethodEventsData{ - MonoDomain *domain; - uint8_t *buffer; - size_t buffer_size; - ep_rt_mono_fire_method_rundown_events_func method_events_func; -} EventPipeFireMethodEventsData; - -gboolean ep_rt_mono_initialized; -MonoNativeTlsKey ep_rt_mono_thread_holder_tls_id; -gpointer ep_rt_mono_rand_provider; - -static ep_rt_thread_holder_alloc_func thread_holder_alloc_callback_func; -static ep_rt_thread_holder_free_func thread_holder_free_callback_func; - -/* - * Forward declares of all static functions. - */ - -static -gboolean -rand_try_get_bytes_func ( - guchar *buffer, - gssize buffer_size, - MonoError *error); - -static -EventPipeThread * -eventpipe_thread_get (void); - -static -EventPipeThread * -eventpipe_thread_get_or_create (void); - -static -void -eventpipe_thread_exited (void); - -static -void -profiler_eventpipe_thread_exited ( - MonoProfiler *prof, - uintptr_t tid); - -static -gpointer -eventpipe_thread_attach (gboolean background_thread); - -static -void -eventpipe_thread_detach (void); - -static -void -eventpipe_fire_method_events ( - MonoJitInfo *ji, - EventPipeFireMethodEventsData *events_data); - -static -void -eventpipe_fire_method_events_func ( - MonoJitInfo *ji, - gpointer user_data); - -static -void -eventpipe_fire_assembly_events ( - MonoDomain *domain, - MonoAssembly *assembly, - ep_rt_mono_fire_assembly_rundown_events_func assembly_events_func); - -static -gboolean -eventpipe_execute_rundown ( - ep_rt_mono_fire_domain_rundown_events_func domain_events_func, - ep_rt_mono_fire_assembly_rundown_events_func assembly_events_func, - ep_rt_mono_fire_method_rundown_events_func methods_events_func); - -static -gboolean -eventpipe_walk_managed_stack_for_thread_func ( - MonoStackFrameInfo *frame, - MonoContext *ctx, - gpointer data); - -static -gboolean -eventpipe_walk_managed_stack_for_thread ( - ep_rt_thread_handle_t thread, - EventPipeStackContents *stack_contents); - -static -gboolean -eventpipe_method_get_simple_assembly_name ( - ep_rt_method_desc_t *method, - ep_char8_t *name, - size_t name_len); - -static -gboolean -evetpipe_method_get_full_name ( - ep_rt_method_desc_t *method, - ep_char8_t *name, - size_t name_len); - -static -void -delegate_callback_data_free_func ( - EventPipeCallback callback_func, - void *callback_data); - -static -void -delegate_callback_func ( - const uint8_t *source_id, - unsigned long is_enabled, - uint8_t level, - uint64_t match_any_keywords, - uint64_t match_all_keywords, - EventFilterDescriptor *filter_data, - void *callback_context); - -static -gboolean -rand_try_get_bytes_func ( - guchar *buffer, - gssize buffer_size, - MonoError *error) -{ - g_assert (ep_rt_mono_rand_provider != NULL); - return mono_rand_try_get_bytes (&ep_rt_mono_rand_provider, buffer, buffer_size, error); -} - -static -EventPipeThread * -eventpipe_thread_get (void) -{ - EventPipeThreadHolder *thread_holder = (EventPipeThreadHolder *)mono_native_tls_get_value (ep_rt_mono_thread_holder_tls_id); - return thread_holder ? ep_thread_holder_get_thread (thread_holder) : NULL; -} - -static -EventPipeThread * -eventpipe_thread_get_or_create (void) -{ - EventPipeThreadHolder *thread_holder = (EventPipeThreadHolder *)mono_native_tls_get_value (ep_rt_mono_thread_holder_tls_id); - if (!thread_holder && thread_holder_alloc_callback_func) { - thread_holder = thread_holder_alloc_callback_func (); - mono_native_tls_set_value (ep_rt_mono_thread_holder_tls_id, thread_holder); - } - return ep_thread_holder_get_thread (thread_holder); -} - -static -void -eventpipe_thread_exited (void) -{ - if (ep_rt_mono_initialized) { - EventPipeThreadHolder *thread_holder = (EventPipeThreadHolder *)mono_native_tls_get_value (ep_rt_mono_thread_holder_tls_id); - if (thread_holder && thread_holder_free_callback_func) - thread_holder_free_callback_func (thread_holder); - mono_native_tls_set_value (ep_rt_mono_thread_holder_tls_id, NULL); - } -} - -static -void -profiler_eventpipe_thread_exited ( - MonoProfiler *prof, - uintptr_t tid) -{ - eventpipe_thread_exited (); -} - -static -gpointer -eventpipe_thread_attach (gboolean background_thread) -{ - MonoThread *thread = NULL; - - // NOTE, under netcore, only root domain exists. - if (!mono_thread_current ()) { - thread = mono_thread_internal_attach (mono_get_root_domain ()); - if (background_thread && thread) { - mono_thread_set_state (thread, ThreadState_Background); - mono_thread_info_set_flags (MONO_THREAD_INFO_FLAGS_NO_SAMPLE); - } - } - - return thread; -} - -static -void -eventpipe_thread_detach (void) -{ - MonoThread *current_thread = mono_thread_current (); - if (current_thread) - mono_thread_internal_detach (current_thread); -} - -static -void -eventpipe_fire_method_events ( - MonoJitInfo *ji, - EventPipeFireMethodEventsData *events_data) -{ - g_assert_checked (ji != NULL); - g_assert_checked (events_data->domain != NULL); - g_assert_checked (events_data->method_events_func != NULL); - - uint64_t method_id = 0; - uint64_t module_id = 0; - uint64_t method_code_start = (uint64_t)ji->code_start; - uint32_t method_code_size = (uint32_t)ji->code_size; - uint32_t method_token = 0; - uint32_t method_flags = 0; - uint8_t kind = MONO_CLASS_DEF; - char *method_namespace = NULL; - const char *method_name = NULL; - char *method_signature = NULL; - - //TODO: Optimize string formatting into functions accepting GString to reduce heap alloc. - - MonoMethod *method = jinfo_get_method (ji); - if (method) { - method_id = (uint64_t)method; - method_token = method->token; - - if (mono_jit_info_get_generic_sharing_context (ji)) - method_flags |= METHOD_FLAGS_SHARED_GENERIC_METHOD; - - if (method->dynamic) - method_flags |= METHOD_FLAGS_DYNAMIC_METHOD; - - if (!ji->from_aot && !ji->from_llvm) { - method_flags |= METHOD_FLAGS_JITTED_METHOD; - if (method->wrapper_type != MONO_WRAPPER_NONE) - method_flags |= METHOD_FLAGS_JITTED_HELPER_METHOD; - } - - if (method->is_generic || method->is_inflated) - method_flags |= METHOD_FLAGS_GENERIC_METHOD; - - method_name = method->name; - method_signature = mono_signature_full_name (method->signature); - - if (method->klass) { - module_id = (uint64_t)m_class_get_image (method->klass); - kind = m_class_get_class_kind (method->klass); - if (kind == MONO_CLASS_GTD || kind == MONO_CLASS_GINST) - method_flags |= METHOD_FLAGS_GENERIC_METHOD; - method_namespace = mono_type_get_name_full (m_class_get_byval_arg (method->klass), MONO_TYPE_NAME_FORMAT_IL); - } - } - - uint16_t offset_entries = 0; - uint32_t *il_offsets = NULL; - uint32_t *native_offsets = NULL; - - MonoDebugMethodJitInfo *debug_info = method ? mono_debug_find_method (method, events_data->domain) : NULL; - if (debug_info) { - offset_entries = debug_info->num_line_numbers; - size_t needed_size = (offset_entries * sizeof (uint32_t) * 2); - if (!events_data->buffer || needed_size > events_data->buffer_size) { - g_free (events_data->buffer); - events_data->buffer_size = (size_t)(needed_size * 1.5); - events_data->buffer = g_new (uint8_t, events_data->buffer_size); - } - - if (events_data->buffer) { - il_offsets = (uint32_t*)events_data->buffer; - native_offsets = il_offsets + offset_entries; - - for (int offset_count = 0; offset_count < offset_entries; ++offset_count) { - il_offsets [offset_count] = debug_info->line_numbers [offset_count].il_offset; - native_offsets [offset_count] = debug_info->line_numbers [offset_count].native_offset; - } - } - - mono_debug_free_method_jit_info (debug_info); - } - - if (events_data->buffer && !il_offsets && !native_offsets) { - // No IL offset -> Native offset mapping available. Put all code on IL offset 0. - g_assert_checked (events_data->buffer_size >= sizeof (uint32_t) * 2); - offset_entries = 1; - il_offsets = (uint32_t*)events_data->buffer; - native_offsets = il_offsets + offset_entries; - il_offsets [0] = 0; - native_offsets [0] = (uint32_t)ji->code_size; - } - - events_data->method_events_func ( - method_id, - module_id, - method_code_start, - method_code_size, - method_token, - method_flags, - (ep_char8_t *)method_namespace, - (ep_char8_t *)method_name, - (ep_char8_t *)method_signature, - offset_entries, - il_offsets, - native_offsets, - NULL); - - g_free (method_namespace); - g_free (method_signature); -} - -static -void -eventpipe_fire_method_events_func ( - MonoJitInfo *ji, - gpointer user_data) -{ - EventPipeFireMethodEventsData *events_data = (EventPipeFireMethodEventsData *)user_data; - g_assert_checked (events_data != NULL); - - if (ji && !ji->is_trampoline && !ji->async) - eventpipe_fire_method_events (ji, events_data); -} - -static -void -eventpipe_fire_assembly_events ( - MonoDomain *domain, - MonoAssembly *assembly, - ep_rt_mono_fire_assembly_rundown_events_func assembly_events_func) -{ - g_assert_checked (domain != NULL); - g_assert_checked (assembly != NULL); - g_assert_checked (assembly_events_func != NULL); - - uint64_t domain_id = (uint64_t)domain; - uint64_t module_id = (uint64_t)assembly->image; - uint64_t assembly_id = (uint64_t)assembly; - - // TODO: Extract all module IL/Native paths and pdb metadata when available. - const char *module_il_path = ""; - const char *module_il_pdb_path = ""; - const char *module_native_path = ""; - const char *module_native_pdb_path = ""; - uint8_t signature [EP_GUID_SIZE] = { 0 }; - uint32_t module_il_pdb_age = 0; - uint32_t module_native_pdb_age = 0; - - uint32_t reserved_flags = 0; - uint64_t binding_id = 0; - - // Native methods are part of JIT table and already emitted. - // TODO: FireEtwMethodDCEndVerbose_V1_or_V2 for all native methods in module as well? - - // Netcore has a 1:1 between assemblies and modules, so its always a manifest module. - uint32_t module_flags = MODULE_FLAGS_MANIFEST_MODULE; - if (assembly->image) { - if (assembly->image->dynamic) - module_flags |= MODULE_FLAGS_DYNAMIC_MODULE; - if (assembly->image->aot_module) - module_flags |= MODULE_FLAGS_NATIVE_MODULE; - - module_il_path = assembly->image->filename ? assembly->image->filename : ""; - } - - uint32_t assembly_flags = 0; - if (assembly->dynamic) - assembly_flags |= ASSEMBLY_FLAGS_DYNAMIC_ASSEMBLY; - - if (assembly->image && assembly->image->aot_module) { - assembly_flags |= ASSEMBLY_FLAGS_NATIVE_ASSEMBLY; - } - - char *assembly_name = mono_stringify_assembly_name (&assembly->aname); - - assembly_events_func ( - domain_id, - assembly_id, - assembly_flags, - binding_id, - (const ep_char8_t*)assembly_name, - module_id, - module_flags, - reserved_flags, - (const ep_char8_t *)module_il_path, - (const ep_char8_t *)module_native_path, - signature, - module_il_pdb_age, - (const ep_char8_t *)module_il_pdb_path, - signature, - module_native_pdb_age, - (const ep_char8_t *)module_native_pdb_path, - NULL); - - g_free (assembly_name); -} - -static -gboolean -eventpipe_execute_rundown ( - ep_rt_mono_fire_domain_rundown_events_func domain_events_func, - ep_rt_mono_fire_assembly_rundown_events_func assembly_events_func, - ep_rt_mono_fire_method_rundown_events_func method_events_func) -{ - g_assert_checked (domain_events_func != NULL); - g_assert_checked (assembly_events_func != NULL); - g_assert_checked (method_events_func != NULL); - - // Under netcore we only have root domain. - MonoDomain *root_domain = mono_get_root_domain (); - if (root_domain) { - uint64_t domain_id = (uint64_t)root_domain; - - // Iterate all functions in use (both JIT and AOT). - EventPipeFireMethodEventsData events_data; - events_data.domain = root_domain; - events_data.buffer_size = 1024 * sizeof(uint32_t); - events_data.buffer = g_new (uint8_t, events_data.buffer_size); - events_data.method_events_func = method_events_func; - mono_jit_info_table_foreach_internal (root_domain, eventpipe_fire_method_events_func, &events_data); - g_free (events_data.buffer); - - // Iterate all assemblies in domain. - GPtrArray *assemblies = mono_domain_get_assemblies (root_domain, FALSE); - if (assemblies) { - for (int i = 0; i < assemblies->len; ++i) { - MonoAssembly *assembly = (MonoAssembly *)g_ptr_array_index (assemblies, i); - if (assembly) - eventpipe_fire_assembly_events (root_domain, assembly, assembly_events_func); - } - g_ptr_array_free (assemblies, TRUE); - } - - uint32_t domain_flags = DOMAIN_FLAGS_DEFAULT_DOMAIN | DOMAIN_FLAGS_EXECUTABLE_DOMAIN; - const char *domain_name = root_domain->friendly_name ? root_domain->friendly_name : ""; - uint32_t domain_index = 1; - - domain_events_func ( - domain_id, - domain_flags, - (const ep_char8_t *)domain_name, - domain_index, - NULL); - } - - return TRUE; -} - -static -gboolean -eventpipe_walk_managed_stack_for_thread_func ( - MonoStackFrameInfo *frame, - MonoContext *ctx, - gpointer data) -{ - g_assert_checked (frame != NULL); - g_assert_checked (data != NULL); - - switch (frame->type) { - case FRAME_TYPE_DEBUGGER_INVOKE: - case FRAME_TYPE_MANAGED_TO_NATIVE: - case FRAME_TYPE_TRAMPOLINE: - case FRAME_TYPE_INTERP_TO_MANAGED: - case FRAME_TYPE_INTERP_TO_MANAGED_WITH_CTX: - return FALSE; - case FRAME_TYPE_MANAGED: - case FRAME_TYPE_INTERP: - if (!frame->ji) - return FALSE; - MonoMethod *method = frame->ji->async ? NULL : frame->actual_method; - ep_stack_contents_append ((EventPipeStackContents *)data, (uintptr_t)((uint8_t*)frame->ji->code_start + frame->native_offset), method); - return ep_stack_contents_get_length ((EventPipeStackContents *)data) >= EP_MAX_STACK_DEPTH; - default: - g_assert_not_reached (); - return FALSE; - } -} - -static -gboolean -eventpipe_walk_managed_stack_for_thread ( - ep_rt_thread_handle_t thread, - EventPipeStackContents *stack_contents) -{ - g_assert (thread != NULL && stack_contents != NULL); - - if (thread == ep_rt_thread_get_handle ()) - mono_get_eh_callbacks ()->mono_walk_stack_with_ctx (eventpipe_walk_managed_stack_for_thread_func, NULL, MONO_UNWIND_SIGNAL_SAFE, stack_contents); - else - mono_get_eh_callbacks ()->mono_walk_stack_with_state (eventpipe_walk_managed_stack_for_thread_func, mono_thread_info_get_suspend_state (thread), MONO_UNWIND_SIGNAL_SAFE, stack_contents); - - return TRUE; -} - -static -gboolean -eventpipe_method_get_simple_assembly_name ( - ep_rt_method_desc_t *method, - ep_char8_t *name, - size_t name_len) -{ - g_assert_checked (method != NULL); - g_assert_checked (name != NULL); - - MonoClass *method_class = mono_method_get_class (method); - MonoImage *method_image = method_class ? mono_class_get_image (method_class) : NULL; - const ep_char8_t *assembly_name = method_image ? mono_image_get_name (method_image) : NULL; - - if (!assembly_name) - return FALSE; - - g_strlcpy (name, assembly_name, name_len); - return TRUE; -} - -static -gboolean -evetpipe_method_get_full_name ( - ep_rt_method_desc_t *method, - ep_char8_t *name, - size_t name_len) -{ - g_assert_checked (method != NULL); - g_assert_checked (name != NULL); - - char *full_method_name = mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL); - if (!full_method_name) - return FALSE; - - g_strlcpy (name, full_method_name, name_len); - - g_free (full_method_name); - return TRUE; -} - -void -mono_eventpipe_init ( - EventPipeMonoFuncTable *table, - ep_rt_thread_holder_alloc_func thread_holder_alloc_func, - ep_rt_thread_holder_free_func thread_holder_free_func) -{ - if (table != NULL) { - table->ep_rt_mono_cpu_count = mono_cpu_count; - table->ep_rt_mono_process_current_pid = mono_process_current_pid; - table->ep_rt_mono_native_thread_id_get = mono_native_thread_id_get; - table->ep_rt_mono_native_thread_id_equals = mono_native_thread_id_equals; - table->ep_rt_mono_runtime_is_shutting_down = mono_runtime_is_shutting_down; - table->ep_rt_mono_rand_try_get_bytes = rand_try_get_bytes_func; - table->ep_rt_mono_thread_get = eventpipe_thread_get; - table->ep_rt_mono_thread_get_or_create = eventpipe_thread_get_or_create; - table->ep_rt_mono_thread_exited = eventpipe_thread_exited; - table->ep_rt_mono_thread_info_sleep = mono_thread_info_sleep; - table->ep_rt_mono_thread_info_yield = mono_thread_info_yield; - table->ep_rt_mono_w32file_close = mono_w32file_close; - table->ep_rt_mono_w32file_create = mono_w32file_create; - table->ep_rt_mono_w32file_write = mono_w32file_write; - table->ep_rt_mono_w32event_create = mono_w32event_create; - table->ep_rt_mono_w32event_close = mono_w32event_close; - table->ep_rt_mono_w32event_set = mono_w32event_set; - table->ep_rt_mono_w32hadle_wait_one = mono_w32handle_wait_one; - table->ep_rt_mono_valloc = mono_valloc; - table->ep_rt_mono_vfree = mono_vfree; - table->ep_rt_mono_valloc_granule = mono_valloc_granule; - table->ep_rt_mono_thread_platform_create_thread = mono_thread_platform_create_thread; - table->ep_rt_mono_thread_attach = eventpipe_thread_attach; - table->ep_rt_mono_thread_detach = eventpipe_thread_detach; - table->ep_rt_mono_get_os_cmd_line = mono_get_os_cmd_line; - table->ep_rt_mono_get_managed_cmd_line = mono_runtime_get_managed_cmd_line; - table->ep_rt_mono_execute_rundown = eventpipe_execute_rundown; - table->ep_rt_mono_walk_managed_stack_for_thread = eventpipe_walk_managed_stack_for_thread; - table->ep_rt_mono_method_get_simple_assembly_name = eventpipe_method_get_simple_assembly_name; - table->ep_rt_mono_method_get_full_name = evetpipe_method_get_full_name; - } - - thread_holder_alloc_callback_func = thread_holder_alloc_func; - thread_holder_free_callback_func = thread_holder_free_func; - mono_native_tls_alloc (&ep_rt_mono_thread_holder_tls_id, NULL); - - mono_100ns_ticks (); - mono_rand_open (); - ep_rt_mono_rand_provider = mono_rand_init (NULL, 0); - - ep_rt_mono_initialized = TRUE; - - MonoProfilerHandle profiler = mono_profiler_create (NULL); - mono_profiler_set_thread_stopped_callback (profiler, profiler_eventpipe_thread_exited); -} - -void -mono_eventpipe_fini (void) -{ - if (ep_rt_mono_initialized) - mono_rand_close (ep_rt_mono_rand_provider); - - ep_rt_mono_rand_provider = NULL; - thread_holder_alloc_callback_func = NULL; - thread_holder_free_callback_func = NULL; - ep_rt_mono_initialized = FALSE; -} - -static -void -delegate_callback_data_free_func ( - EventPipeCallback callback_func, - void *callback_data) -{ - if (callback_data) - mono_gchandle_free_internal ((MonoGCHandle)callback_data); -} - -static -void -delegate_callback_func ( - const uint8_t *source_id, - unsigned long is_enabled, - uint8_t level, - uint64_t match_any_keywords, - uint64_t match_all_keywords, - EventFilterDescriptor *filter_data, - void *callback_context) -{ - - /*internal unsafe delegate void EtwEnableCallback( - in Guid sourceId, - int isEnabled, - byte level, - long matchAnyKeywords, - long matchAllKeywords, - EVENT_FILTER_DESCRIPTOR* filterData, - void* callbackContext);*/ - - MonoGCHandle delegate_object_handle = (MonoGCHandle)callback_context; - MonoObject *delegate_object = delegate_object_handle ? mono_gchandle_get_target_internal (delegate_object_handle) : NULL; - if (delegate_object) { - void *params [7]; - params [0] = (void *)source_id; - params [1] = (void *)&is_enabled; - params [2] = (void *)&level; - params [3] = (void *)&match_any_keywords; - params [4] = (void *)&match_all_keywords; - params [5] = (void *)filter_data; - params [6] = NULL; - - ERROR_DECL (error); - mono_runtime_delegate_invoke_checked (delegate_object, params, error); - } -} - -gconstpointer -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_CreateProvider ( - MonoStringHandle provider_name, - MonoDelegateHandle callback_func, - MonoError *error) -{ - EventPipeProvider *provider = NULL; - void *callback_data = NULL; - - if (MONO_HANDLE_IS_NULL (provider_name)) { - mono_error_set_argument_null (error, "providerName", ""); - return NULL; - } - - if (!MONO_HANDLE_IS_NULL (callback_func)) - callback_data = (void *)mono_gchandle_new_weakref_internal (MONO_HANDLE_RAW (MONO_HANDLE_CAST (MonoObject, callback_func)), FALSE); - - char *provider_name_utf8 = mono_string_handle_to_utf8 (provider_name, error); - if (is_ok (error) && provider_name_utf8) { - provider = ep_create_provider (provider_name_utf8, delegate_callback_func, delegate_callback_data_free_func, callback_data); - } - - g_free (provider_name_utf8); - return provider; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DefineEvent ( - intptr_t provider_handle, - uint32_t event_id, - int64_t keywords, - uint32_t event_version, - uint32_t level, - const uint8_t *metadata, - uint32_t metadata_len) -{ - g_assert (provider_handle != 0); - - EventPipeProvider *provider = (EventPipeProvider *)provider_handle; - EventPipeEvent *ep_event = ep_provider_add_event (provider, event_id, (uint64_t)keywords, event_version, (EventPipeEventLevel)level, /* needStack = */ true, metadata, metadata_len); - - g_assert (ep_event != NULL); - return (intptr_t)ep_event; -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DeleteProvider (intptr_t provider_handle) -{ - if (provider_handle) { - ep_delete_provider ((EventPipeProvider *)provider_handle); - } -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Disable (uint64_t session_id) -{ - ep_disable (session_id); -} - -uint64_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Enable ( - const gunichar2 *output_file, - /* EventPipeSerializationFormat */int32_t format, - uint32_t circular_buffer_size_mb, - /* EventPipeProviderConfigurationNative[] */const void *providers, - uint32_t providers_len) -{ - ERROR_DECL (error); - EventPipeSessionID session_id = 0; - char *output_file_utf8 = NULL; - - if (circular_buffer_size_mb == 0 || format > EP_SERIALIZATION_FORMAT_COUNT || providers_len == 0 || providers == NULL) - return 0; - - if (output_file) - output_file_utf8 = mono_utf16_to_utf8 (output_file, g_utf16_len (output_file), error); - - EventPipeProviderConfigurationNative *native_config_providers = (EventPipeProviderConfigurationNative *)providers; - EventPipeProviderConfiguration *config_providers = g_new0 (EventPipeProviderConfiguration, providers_len); - - if (config_providers) { - for (int i = 0; i < providers_len; ++i) { - ep_provider_config_init ( - &config_providers[i], - native_config_providers[i].provider_name ? mono_utf16_to_utf8 (native_config_providers[i].provider_name, g_utf16_len (native_config_providers[i].provider_name), error) : NULL, - native_config_providers [i].keywords, - (EventPipeEventLevel)native_config_providers [i].logging_level, - native_config_providers[i].filter_data ? mono_utf16_to_utf8 (native_config_providers[i].filter_data, g_utf16_len (native_config_providers[i].filter_data), error) : NULL); - } - } - - session_id = ep_enable ( - output_file_utf8, - circular_buffer_size_mb, - config_providers, - providers_len, - output_file != NULL ? EP_SESSION_TYPE_FILE : EP_SESSION_TYPE_LISTENER, - (EventPipeSerializationFormat)format, - true, - NULL, - NULL); - ep_start_streaming (session_id); - - if (config_providers) { - for (int i = 0; i < providers_len; ++i) { - ep_provider_config_fini (&config_providers[i]); - g_free ((ep_char8_t *)ep_provider_config_get_provider_name (&config_providers[i])); - g_free ((ep_char8_t *)ep_provider_config_get_filter_data (&config_providers[i])); - } - } - - g_free (output_file_utf8); - return session_id; -} - -int32_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_EventActivityIdControl ( - uint32_t control_code, - /* GUID * */uint8_t *activity_id) -{ - int32_t result = 0; - ep_rt_thread_activity_id_handle_t activity_id_handle = ep_thread_get_activity_id_handle (); - - if (activity_id_handle == NULL) - return 1; - - uint8_t current_activity_id [EP_ACTIVITY_ID_SIZE]; - EventPipeActivityControlCode activity_control_code = (EventPipeActivityControlCode)control_code; - switch (activity_control_code) { - case EP_ACTIVITY_CONTROL_GET_ID: - ep_thread_get_activity_id (activity_id_handle, activity_id, EP_ACTIVITY_ID_SIZE); - break; - case EP_ACTIVITY_CONTROL_SET_ID: - ep_thread_set_activity_id (activity_id_handle, activity_id, EP_ACTIVITY_ID_SIZE); - break; - case EP_ACTIVITY_CONTROL_CREATE_ID: - ep_thread_create_activity_id (activity_id, EP_ACTIVITY_ID_SIZE); - break; - case EP_ACTIVITY_CONTROL_GET_SET_ID: - ep_thread_get_activity_id (activity_id_handle, current_activity_id, EP_ACTIVITY_ID_SIZE); - ep_thread_set_activity_id (activity_id_handle, activity_id, EP_ACTIVITY_ID_SIZE); - memcpy (activity_id, current_activity_id, EP_ACTIVITY_ID_SIZE); - break; - case EP_ACTIVITY_CONTROL_CREATE_SET_ID: - ep_thread_get_activity_id (activity_id_handle, activity_id, EP_ACTIVITY_ID_SIZE); - ep_thread_create_activity_id (current_activity_id, EP_ACTIVITY_ID_SIZE); - ep_thread_set_activity_id (activity_id_handle, current_activity_id, EP_ACTIVITY_ID_SIZE); - break; - default: - result = 1; - break; - } - - return result; -} - -MonoBoolean -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetNextEvent ( - uint64_t session_id, - /* EventPipeEventInstanceData * */void *instance) -{ - g_assert (instance != NULL); - - EventPipeEventInstance *const next_instance = ep_get_next_event (session_id); - EventPipeEventInstanceData *const data = (EventPipeEventInstanceData *)instance; - if (next_instance && data) { - const EventPipeEvent *const ep_event = ep_event_instance_get_ep_event (next_instance); - if (ep_event) { - data->provider_id = (intptr_t)ep_event_get_provider (ep_event); - data->event_id = ep_event_get_event_id (ep_event); - } - data->thread_id = ep_event_instance_get_thread_id (next_instance); - data->timestamp = ep_event_instance_get_timestamp (next_instance); - memcpy (&data->activity_id, ep_event_instance_get_activity_id_cref (next_instance), EP_ACTIVITY_ID_SIZE); - memcpy (&data->related_activity_id, ep_event_instance_get_related_activity_id_cref (next_instance), EP_ACTIVITY_ID_SIZE); - data->payload = ep_event_instance_get_data (next_instance); - data->payload_len = ep_event_instance_get_data_len (next_instance); - } - - return next_instance != NULL; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetProvider (const gunichar2 *provider_name) -{ - ERROR_DECL (error); - char * provider_name_utf8 = NULL; - EventPipeProvider *provider = NULL; - - if (provider_name) { - provider_name_utf8 = mono_utf16_to_utf8 (provider_name, g_utf16_len (provider_name), error); - provider = ep_get_provider (provider_name_utf8); - } - - g_free (provider_name_utf8); - return (intptr_t)provider; -} - -MonoBoolean -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetSessionInfo ( - uint64_t session_id, - /* EventPipeSessionInfo * */void *session_info) -{ - bool result = false; - if (session_info) { - EventPipeSession *session = ep_get_session ((EventPipeSessionID)session_id); - if (session) { - EventPipeSessionInfo *instance = (EventPipeSessionInfo *)session_info; - instance->starttime_as_utc_filetime = ep_session_get_session_start_time (session); - instance->start_timestamp = ep_session_get_session_start_timestamp (session); - instance->timestamp_frequency = ep_perf_frequency_query (); - result = true; - } - } - - return result; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetWaitHandle (uint64_t session_id) -{ - return (intptr_t)ep_get_wait_handle (session_id); -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_WriteEventData ( - intptr_t event_handle, - /* EventData[] */void *event_data, - uint32_t event_data_len, - /* GUID * */const uint8_t *activity_id, - /* GUID * */const uint8_t *related_activity_id) -{ - g_assert (event_handle); - EventPipeEvent *ep_event = (EventPipeEvent *)event_handle; - ep_write_event_2 (ep_event, (EventData *)event_data, event_data_len, activity_id, related_activity_id); -} - -#else /* ENABLE_PERFTRACING */ - -gconstpointer -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_CreateProvider ( - MonoStringHandle provider_name, - MonoDelegateHandle callback_func, - MonoError *error) -{ - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.CreateProvider"); - return NULL; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DefineEvent ( - intptr_t provider_handle, - uint32_t event_id, - int64_t keywords, - uint32_t event_version, - uint32_t level, - const uint8_t *metadata, - uint32_t metadata_len) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.DefineEvent"); - mono_error_set_pending_exception (error); - return 0; -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_DeleteProvider (intptr_t provider_handle) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.DeleteProvider"); - mono_error_set_pending_exception (error); -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Disable (uint64_t session_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.Disable"); - mono_error_set_pending_exception (error); -} - -uint64_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_Enable ( - const gunichar2 *output_file, - /* EventPipeSerializationFormat */int32_t format, - uint32_t circular_buffer_size_mb, - /* EventPipeProviderConfigurationNative[] */const void *providers, - uint32_t providers_len) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.Enable"); - mono_error_set_pending_exception (error); - return 0; -} - -int32_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_EventActivityIdControl ( - uint32_t control_code, - /* GUID * */uint8_t *activity_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.EventActivityIdControl"); - mono_error_set_pending_exception (error); - return 0; -} - -MonoBoolean -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetNextEvent ( - uint64_t session_id, - /* EventPipeEventInstanceData * */void *instance) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.GetNextEvent"); - mono_error_set_pending_exception (error); - return FALSE; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetProvider (const gunichar2 *provider_name) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.GetProvider"); - mono_error_set_pending_exception (error); - return 0; -} - -MonoBoolean -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetSessionInfo ( - uint64_t session_id, - /* EventPipeSessionInfo * */void *session_info) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.GetSessionInfo"); - mono_error_set_pending_exception (error); - return FALSE; -} - -intptr_t -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_GetWaitHandle (uint64_t session_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.GetWaitHandle"); - mono_error_set_pending_exception (error); - return 0; -} - -void -ves_icall_System_Diagnostics_Tracing_EventPipeInternal_WriteEventData ( - intptr_t event_handle, - /* EventData[] */void *event_data, - uint32_t event_data_len, - /* GUID * */const uint8_t *activity_id, - /* GUID * */const uint8_t *related_activity_id) -{ - ERROR_DECL (error); - mono_error_set_not_implemented (error, "System.Diagnostics.Tracing.EventPipeInternal.WriteEventData"); - mono_error_set_pending_exception (error); -} - -#endif /* ENABLE_PERFTRACING */ -#endif /* ENABLE_NETCORE */ MONO_EMPTY_SOURCE_FILE (icall_eventpipe); diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index b265582c284..786c1099a07 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -201,12 +201,6 @@ ves_icall_System_Array_GetValueImpl (MonoArrayHandle array, guint32 pos, MonoErr MonoClass * const array_class = mono_handle_class (array); MonoClass * const element_class = m_class_get_element_class (array_class); -#ifdef ENABLE_NETCORE - if (m_class_is_native_pointer (element_class)) { - mono_error_set_not_supported (error, NULL); - return NULL_HANDLE; - } -#endif if (m_class_is_valuetype (element_class)) { gsize element_size = mono_array_element_size (array_class); @@ -278,93 +272,6 @@ set_invalid_cast (MonoError *error, MonoClass *src_class, MonoClass *dst_class) mono_error_set_invalid_cast (error); } -#if ENABLE_NETCORE -void -ves_icall_System_Array_SetValueRelaxedImpl (MonoArrayHandle arr, MonoObjectHandle value, guint32 pos, MonoError *error) -{ - array_set_value_impl (arr, value, pos, FALSE, FALSE, error); -} - -// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/d3e39bc2f81e3dbf9e4b96347f62b49d8700336c/src/vm/invokeutil.cpp#L33 -#define PT_Primitive 0x01000000 - -static const guint32 primitive_conversions [] = { - 0x00, // MONO_TYPE_END - 0x00, // MONO_TYPE_VOID - PT_Primitive | 0x0004, // MONO_TYPE_BOOLEAN - PT_Primitive | 0x3F88, // MONO_TYPE_CHAR (W = U2, CHAR, I4, U4, I8, U8, R4, R8) - PT_Primitive | 0x3550, // MONO_TYPE_I1 (W = I1, I2, I4, I8, R4, R8) - PT_Primitive | 0x3FE8, // MONO_TYPE_U1 (W = CHAR, U1, I2, U2, I4, U4, I8, U8, R4, R8) - PT_Primitive | 0x3540, // MONO_TYPE_I2 (W = I2, I4, I8, R4, R8) - PT_Primitive | 0x3F88, // MONO_TYPE_U2 (W = U2, CHAR, I4, U4, I8, U8, R4, R8) - PT_Primitive | 0x3500, // MONO_TYPE_I4 (W = I4, I8, R4, R8) - PT_Primitive | 0x3E00, // MONO_TYPE_U4 (W = U4, I8, R4, R8) - PT_Primitive | 0x3400, // MONO_TYPE_I8 (W = I8, R4, R8) - PT_Primitive | 0x3800, // MONO_TYPE_U8 (W = U8, R4, R8) - PT_Primitive | 0x3000, // MONO_TYPE_R4 (W = R4, R8) - PT_Primitive | 0x2000, // MONO_TYPE_R8 (W = R8) -}; - -// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/030a3ea9b8dbeae89c90d34441d4d9a1cf4a7de6/src/vm/invokeutil.h#L176 -static -gboolean can_primitive_widen (MonoTypeEnum src_type, MonoTypeEnum dest_type) -{ - if (dest_type > MONO_TYPE_R8 || src_type > MONO_TYPE_R8) { - return (MONO_TYPE_I == dest_type && MONO_TYPE_I == src_type) || (MONO_TYPE_U == dest_type && MONO_TYPE_U == src_type); - } - return ((1 << dest_type) & primitive_conversions [src_type]) != 0; -} - -// Copied from CoreCLR: https://github.com/dotnet/coreclr/blob/eafa8648ebee92de1380278b15cd5c2b6ef11218/src/vm/array.cpp#L1406 -static MonoTypeEnum -get_normalized_integral_array_element_type (MonoTypeEnum elementType) -{ - // Array Primitive types such as E_T_I4 and E_T_U4 are interchangeable - // Enums with interchangeable underlying types are interchangable - // BOOL is NOT interchangeable with I1/U1, neither CHAR -- with I2/U2 - - switch (elementType) { - case MONO_TYPE_U1: - case MONO_TYPE_U2: - case MONO_TYPE_U4: - case MONO_TYPE_U8: - case MONO_TYPE_U: - return (MonoTypeEnum) (elementType - 1); // normalize to signed type - } - - return elementType; -} - -MonoBoolean -ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable) -{ - MonoReflectionType* const ref_src_type = *ref_src_type_handle; - MonoReflectionType* const ref_dst_type = *ref_dst_type_handle; - - MonoType *src_type = ref_src_type->type; - MonoType *dst_type = ref_dst_type->type; - - g_assert (mono_type_is_primitive (src_type)); - g_assert (mono_type_is_primitive (dst_type)); - - MonoTypeEnum normalized_src_type = get_normalized_integral_array_element_type (src_type->type); - MonoTypeEnum normalized_dst_type = get_normalized_integral_array_element_type (dst_type->type); - - // Allow conversions like int <-> uint - if (normalized_src_type == normalized_dst_type) { - return TRUE; - } - - // Widening is not allowed if reliable is true. - if (reliable) { - return FALSE; - } - - // NOTE we don't use normalized types here so int -> ulong will be false - // see https://github.com/dotnet/coreclr/pull/25209#issuecomment-505952295 - return can_primitive_widen (src_type->type, dst_type->type); -} -#endif static void array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, guint32 pos, gboolean strict_enums, gboolean strict_signs, MonoError *error) @@ -392,13 +299,6 @@ array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, esize = mono_array_element_size (ac); if (mono_class_is_nullable (ec)) { -#ifdef ENABLE_NETCORE - if (vc && m_class_is_primitive (vc) && vc != m_class_get_nullable_elem_class (ec)) { - // T -> Nullable<T> T must be exact - set_invalid_cast (error, vc, ec); - goto leave; - } -#endif MONO_ENTER_NO_SAFEPOINTS; ea = (gpointer*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (arr_handle), esize, pos); if (!MONO_HANDLE_IS_NULL (value_handle)) @@ -416,13 +316,8 @@ array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, goto leave; } -#ifdef ENABLE_NETCORE -#define WIDENING_MSG NULL -#define WIDENING_ARG NULL -#else #define WIDENING_MSG "not a widening conversion" #define WIDENING_ARG "value" -#endif #define NO_WIDENING_CONVERSION G_STMT_START{ \ mono_error_set_argument (error, WIDENING_ARG, WIDENING_MSG); \ @@ -520,12 +415,6 @@ array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, et_isenum = et == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (ec)->data.klass); vt_isenum = vt == MONO_TYPE_VALUETYPE && m_class_is_enumtype (m_class_get_byval_arg (vc)->data.klass); -#if ENABLE_NETCORE - if (strict_enums && et_isenum && !vt_isenum) { - INVALID_CAST; - goto leave; - } -#endif if (et_isenum) et = mono_class_enum_basetype_internal (m_class_get_byval_arg (ec)->data.klass)->type; @@ -533,16 +422,6 @@ array_set_value_impl (MonoArrayHandle arr_handle, MonoObjectHandle value_handle, if (vt_isenum) vt = mono_class_enum_basetype_internal (m_class_get_byval_arg (vc)->data.klass)->type; -#if ENABLE_NETCORE - // Treat MONO_TYPE_U/I as MONO_TYPE_U8/I8/U4/I4 -#if SIZEOF_VOID_P == 8 - vt = vt == MONO_TYPE_U ? MONO_TYPE_U8 : (vt == MONO_TYPE_I ? MONO_TYPE_I8 : vt); - et = et == MONO_TYPE_U ? MONO_TYPE_U8 : (et == MONO_TYPE_I ? MONO_TYPE_I8 : et); -#else - vt = vt == MONO_TYPE_U ? MONO_TYPE_U4 : (vt == MONO_TYPE_I ? MONO_TYPE_I4 : vt); - et = et == MONO_TYPE_U ? MONO_TYPE_U4 : (et == MONO_TYPE_I ? MONO_TYPE_I4 : et); -#endif -#endif #define ASSIGN_UNSIGNED(etype) G_STMT_START{\ switch (vt) { \ @@ -765,11 +644,7 @@ ves_icall_System_Array_SetValue (MonoArrayHandle arr, MonoObjectHandle value, error_init (error); if (MONO_HANDLE_IS_NULL (idxs)) { -#ifdef ENABLE_NETCORE - mono_error_set_argument_null (error, "indices", ""); -#else mono_error_set_argument_null (error, "idxs", ""); -#endif return; } @@ -778,11 +653,7 @@ ves_icall_System_Array_SetValue (MonoArrayHandle arr, MonoObjectHandle value, g_assert (m_class_get_rank (ic) == 1); if (mono_handle_array_has_bounds (idxs) || MONO_HANDLE_GETVAL (idxs, max_length) != m_class_get_rank (ac)) { -#ifdef ENABLE_NETCORE - mono_error_set_argument (error, NULL, ""); -#else mono_error_set_argument (error, "idxs", ""); -#endif return; } @@ -820,73 +691,7 @@ ves_icall_System_Array_SetValue (MonoArrayHandle arr, MonoObjectHandle value, array_set_value_impl (arr, value, pos, TRUE, TRUE, error); } -#ifdef ENABLE_NETCORE - -void -ves_icall_System_Array_InternalCreate (MonoArray *volatile* result, MonoType* type, gint32 rank, gint32* pLengths, gint32* pLowerBounds) -{ - ERROR_DECL (error); - - MonoClass* klass = mono_class_from_mono_type_internal (type); - if (!mono_class_init_checked (klass, error)) - goto exit; - - if (m_class_get_byval_arg (m_class_get_element_class (klass))->type == MONO_TYPE_VOID) { - mono_error_set_not_supported (error, "Arrays of System.Void are not supported."); - goto exit; - } - - if (type->byref || m_class_is_byreflike (klass)) { - mono_error_set_not_supported (error, NULL); - goto exit; - } - - MonoGenericClass *gklass; - gklass = mono_class_try_get_generic_class (klass); - if (is_generic_parameter (type) || mono_class_is_gtd (klass) || (gklass && gklass->context.class_inst->is_open)) { - mono_error_set_not_supported (error, NULL); - goto exit; - } - - /* vectors are not the same as one dimensional arrays with non-zero bounds */ - gboolean bounded; - bounded = pLowerBounds != NULL && rank == 1 && pLowerBounds [0] != 0; - - MonoClass* aklass; - aklass = mono_class_create_bounded_array (klass, rank, bounded); - - uintptr_t aklass_rank; - aklass_rank = m_class_get_rank (aklass); - - uintptr_t* sizes; - sizes = g_newa (uintptr_t, aklass_rank * 2); - - intptr_t* lower_bounds; - lower_bounds = (intptr_t*)(sizes + aklass_rank); - - // Copy lengths and lower_bounds from gint32 to [u]intptr_t. - for (uintptr_t i = 0; i < aklass_rank; ++i) { - if (pLowerBounds != NULL) { - lower_bounds [i] = pLowerBounds [i]; - if ((gint64) pLowerBounds [i] + (gint64) pLengths [i] > G_MAXINT32) { - mono_error_set_argument_out_of_range (error, NULL, "Length + bound must not exceed Int32.MaxValue."); - goto exit; - } - } else { - lower_bounds [i] = 0; - } - sizes [i] = pLengths [i]; - } - - *result = mono_array_new_full_checked (mono_domain_get (), aklass, sizes, lower_bounds, error); - -exit: - mono_error_set_pending_exception (error); -} - -#endif -#ifndef ENABLE_NETCORE MonoArrayHandle ves_icall_System_Array_CreateInstanceImpl (MonoReflectionTypeHandle type, MonoArrayHandle lengths, MonoArrayHandle bounds, MonoError *error) { @@ -954,22 +759,7 @@ ves_icall_System_Array_GetRank (MonoObjectHandle arr, MonoError *error) return result; } -#endif -#ifdef ENABLE_NETCORE -gint32 -ves_icall_System_Array_GetCorElementTypeOfElementType (MonoArrayHandle arr, MonoError *error) -{ - MonoType *type = mono_type_get_underlying_type (m_class_get_byval_arg (m_class_get_element_class (mono_handle_class (arr)))); - return type->type; -} - -gint32 -ves_icall_System_Array_IsValueOfElementType (MonoArrayHandle arr, MonoObjectHandle obj, MonoError *error) -{ - return m_class_get_element_class (mono_handle_class (arr)) == mono_handle_class (obj); -} -#endif static mono_array_size_t mono_array_get_length (MonoArrayHandle arr, gint32 dimension, MonoError *error) @@ -996,7 +786,6 @@ ves_icall_System_Array_GetLength (MonoArrayHandle arr, gint32 dimension, MonoErr return (gint32)length; } -#ifndef ENABLE_NETCORE gint64 ves_icall_System_Array_GetLongLength (MonoArrayHandle arr, gint32 dimension, MonoError *error) { @@ -1004,7 +793,6 @@ ves_icall_System_Array_GetLongLength (MonoArrayHandle arr, gint32 dimension, Mon return (gint64)mono_array_get_length (arr, dimension, error); } -#endif gint32 ves_icall_System_Array_GetLowerBound (MonoArrayHandle arr, gint32 dimension, MonoError *error) @@ -1020,7 +808,6 @@ ves_icall_System_Array_GetLowerBound (MonoArrayHandle arr, gint32 dimension, Mon : 0; } -#ifndef ENABLE_NETCORE void ves_icall_System_Array_ClearInternal (MonoArrayHandle arr, int idx, int length, MonoError *error) { @@ -1029,7 +816,6 @@ ves_icall_System_Array_ClearInternal (MonoArrayHandle arr, int idx, int length, int sz = mono_array_element_size (mono_handle_class (arr)); mono_gc_bzero_atomic (mono_array_addr_with_size_fast (MONO_HANDLE_RAW (arr), sz, idx), length * sz); } -#endif MonoBoolean ves_icall_System_Array_FastCopy (MonoArrayHandle source, int source_idx, MonoArrayHandle dest, int dest_idx, int length, MonoError *error) @@ -1145,25 +931,11 @@ ves_icall_System_Array_SetGenericValue_icall (MonoArray **arr, guint32 pos, gpoi } void -#if ENABLE_NETCORE -ves_icall_System_Runtime_RuntimeImports_Memmove (guint8 *destination, guint8 *source, size_t byte_count) -#else ves_icall_System_Runtime_RuntimeImports_Memmove (guint8 *destination, guint8 *source, guint byte_count) -#endif { mono_gc_memmove_atomic (destination, source, byte_count); } -#if ENABLE_NETCORE -void -ves_icall_System_Buffer_BulkMoveWithWriteBarrier (guint8 *destination, guint8 *source, size_t len, MonoType *type) -{ - if (MONO_TYPE_IS_REFERENCE (type)) - mono_gc_wbarrier_arrayref_copy_internal (destination, source, (guint)len); - else - mono_gc_wbarrier_value_copy_internal (destination, source, (guint)len, mono_class_from_mono_type_internal (type)); -} -#else void ves_icall_System_Runtime_RuntimeImports_Memmove_wbarrier (guint8 *destination, guint8 *source, guint len, MonoType *type) { @@ -1172,14 +944,9 @@ ves_icall_System_Runtime_RuntimeImports_Memmove_wbarrier (guint8 *destination, g else mono_gc_wbarrier_value_copy_internal (destination, source, len, mono_class_from_mono_type_internal (type)); } -#endif void -#if ENABLE_NETCORE -ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8 *p, size_t byte_length) -#else ves_icall_System_Runtime_RuntimeImports_ZeroMemory (guint8 *p, guint byte_length) -#endif { memset (p, 0, byte_length); } @@ -1306,27 +1073,6 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunModuleConstructor (M mono_runtime_class_init_full (vtable, error); } -#ifdef ENABLE_NETCORE -MonoBoolean -ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void) -{ - MonoThreadInfo *thread = mono_thread_info_current (); - void *current = &thread; - - // Stack upper/lower bound should have been calculated and set as part of register_thread. - // If not, we are optimistic and assume there is enough room. - if (!thread->stack_start_limit || !thread->stack_end) - return TRUE; - - // Stack start limit is stack lower bound. Make sure there is enough room left. - void *limit = ((uint8_t *)thread->stack_start_limit) + ALIGN_TO (MONO_STACK_OVERFLOW_GUARD_SIZE + MONO_MIN_EXECUTION_STACK_SIZE, ((gssize)mono_pagesize ())); - - if (current < limit) - return FALSE; - - return TRUE; -} -#else MonoBoolean ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStack (void) { @@ -1365,81 +1111,7 @@ ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_SufficientExecutionStac #endif return TRUE; } -#endif - -#ifdef ENABLE_NETCORE -MonoObjectHandle -ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetUninitializedObjectInternal (MonoType *handle, MonoError *error) -{ - MonoClass *klass; - MonoVTable *vtable; - - g_assert (handle); - - klass = mono_class_from_mono_type_internal (handle); - if (m_class_is_string (klass)) { - mono_error_set_argument (error, NULL, NULL); - return NULL_HANDLE; - } - - if (mono_class_is_array (klass) || mono_class_is_pointer (klass) || handle->byref) { - mono_error_set_argument (error, NULL, NULL); - return NULL_HANDLE; - } - - if (MONO_TYPE_IS_VOID (handle)) { - mono_error_set_argument (error, NULL, NULL); - return NULL_HANDLE; - } - - if (m_class_is_abstract (klass) || m_class_is_interface (klass) || m_class_is_gtd (klass)) { - mono_error_set_member_access (error, NULL, NULL); - return NULL_HANDLE; - } - - if (m_class_is_byreflike (klass)) { - mono_error_set_not_supported (error, NULL, NULL); - return NULL_HANDLE; - } - - if (!mono_class_is_before_field_init (klass)) { - vtable = mono_class_vtable_checked (mono_domain_get (), klass, error); - return_val_if_nok (error, NULL_HANDLE); - - mono_runtime_class_init_full (vtable, error); - return_val_if_nok (error, NULL_HANDLE); - } - - if (m_class_is_nullable (klass)) - return mono_object_new_handle (mono_domain_get (), m_class_get_nullable_elem_class (klass), error); - else - return mono_object_new_handle (mono_domain_get (), klass, error); -} -void -ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_PrepareMethod (MonoMethod *method, gpointer inst_types, int n_inst_types, MonoError *error) -{ - if (method->flags & METHOD_ATTRIBUTE_ABSTRACT) { - mono_error_set_argument (error, NULL, NULL); - return; - } - - MonoGenericContainer *container = NULL; - if (method->is_generic) - container = mono_method_get_generic_container (method); - else if (m_class_is_gtd (method->klass)) - container = mono_class_get_generic_container (method->klass); - if (container) { - int nparams = container->type_argc + (container->parent ? container->parent->type_argc : 0); - if (nparams != n_inst_types) { - mono_error_set_argument (error, NULL, NULL); - return; - } - } - - // FIXME: Implement -} -#endif MonoObjectHandle ves_icall_System_Object_MemberwiseClone (MonoObjectHandle this_obj, MonoError *error) @@ -1686,7 +1358,6 @@ ves_icall_System_ValueType_Equals (MonoObjectHandle this_obj, MonoObjectHandle t } } -#ifndef ENABLE_NETCORE MonoReflectionTypeHandle ves_icall_System_Object_GetType (MonoObjectHandle obj, MonoError *error) { @@ -1708,7 +1379,6 @@ ves_icall_System_Object_GetType (MonoObjectHandle obj, MonoError *error) #endif return mono_type_get_object_handle (domain, m_class_get_byval_arg (klass), error); } -#endif static gboolean get_executing (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data) @@ -2017,7 +1687,6 @@ typedef enum { TYPECODE_STRING = 18 } TypeCode; -#ifndef ENABLE_NETCORE guint32 ves_icall_type_GetTypeCodeInternal (MonoReflectionTypeHandle ref_type, MonoError *error) { @@ -2103,7 +1772,6 @@ handle_enum: } return 0; } -#endif guint32 ves_icall_RuntimeTypeHandle_type_is_assignable_from (MonoReflectionTypeHandle ref_type, MonoReflectionTypeHandle ref_c, MonoError *error) @@ -2198,10 +1866,6 @@ ves_icall_RuntimeTypeHandle_GetAttributes (MonoReflectionTypeHandle ref_type, Mo { MonoType *type = MONO_HANDLE_GETVAL (ref_type, type); -#ifdef ENABLE_NETCORE - if (type->byref || type->type == MONO_TYPE_PTR || type->type == MONO_TYPE_FNPTR) - return TYPE_ATTRIBUTE_NOT_PUBLIC; -#endif MonoClass *klass = mono_class_from_mono_type_internal (type); return mono_class_get_flags (klass); @@ -3363,7 +3027,6 @@ leave: HANDLE_FUNCTION_RETURN_VAL (is_ok (error)); } -#ifndef ENABLE_NETCORE void ves_icall_RuntimeType_GetGUID (MonoReflectionTypeHandle type_handle, MonoArrayHandle guid_handle, MonoError *error) { @@ -3383,7 +3046,6 @@ ves_icall_RuntimeType_GetGUID (MonoReflectionTypeHandle type_handle, MonoArrayHa guint8 *data = (guint8*) mono_array_addr_with_size_internal (MONO_HANDLE_RAW (guid_handle), 1, 0); mono_metadata_get_class_guid (klass, data, error); } -#endif MonoArrayHandle ves_icall_RuntimeType_GetGenericArguments (MonoReflectionTypeHandle ref_type, MonoBoolean runtimeTypeArray, MonoError *error) @@ -3609,7 +3271,6 @@ leave: return ret; } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_RuntimeType_IsTypeExportedToWindowsRuntime (MonoError *error) { @@ -3625,7 +3286,6 @@ ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType (MonoError *error) mono_error_set_not_implemented (error, "%s", "System.RuntimeType.IsWindowsRuntimeObjectType"); return FALSE; } -#endif /* ENABLE_NETCORE */ void ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, int* flags, MonoStringHandleOut entry_point, MonoStringHandleOut dll_name, MonoError *error) @@ -3720,87 +3380,6 @@ ves_icall_RuntimeMethodInfo_GetGenericMethodDefinition (MonoReflectionMethodHand return mono_method_get_object_handle (MONO_HANDLE_DOMAIN (ref_method), result, NULL, error); } -#ifdef ENABLE_NETCORE -static GENERATE_TRY_GET_CLASS_WITH_CACHE (stream, "System.IO", "Stream") -static int io_stream_begin_read_slot = -1; -static int io_stream_begin_write_slot = -1; -static int io_stream_end_read_slot = -1; -static int io_stream_end_write_slot = -1; -static gboolean io_stream_slots_set = FALSE; - -static void -init_io_stream_slots (void) -{ - MonoClass* klass = mono_class_try_get_stream_class (); - mono_class_setup_vtable (klass); - MonoMethod **klass_methods = m_class_get_methods (klass); - if (!klass_methods) { - mono_class_setup_methods (klass); - klass_methods = m_class_get_methods (klass); - } - int method_count = mono_class_get_method_count (klass); - int methods_found = 0; - for (int i = 0; i < method_count; i++) { - // find slots for Begin(End)Read and Begin(End)Write - MonoMethod* m = klass_methods [i]; - if (m->slot == -1) - continue; - - if (!strcmp (m->name, "BeginRead")) { - methods_found++; - io_stream_begin_read_slot = m->slot; - } else if (!strcmp (m->name, "BeginWrite")) { - methods_found++; - io_stream_begin_write_slot = m->slot; - } else if (!strcmp (m->name, "EndRead")) { - methods_found++; - io_stream_end_read_slot = m->slot; - } else if (!strcmp (m->name, "EndWrite")) { - methods_found++; - io_stream_end_write_slot = m->slot; - } - } - g_assert (methods_found <= 4); // some of them can be linked out - io_stream_slots_set = TRUE; -} - -MonoBoolean -ves_icall_System_IO_Stream_HasOverriddenBeginEndRead (MonoObjectHandle stream, MonoError *error) -{ - MonoClass* curr_klass = MONO_HANDLE_GET_CLASS (stream); - MonoClass* base_klass = mono_class_try_get_stream_class (); - - if (!io_stream_slots_set) - init_io_stream_slots (); - - // slots can still be -1 and it means Linker removed the methods from the base class (Stream) - // in this case we can safely assume the methods are not overridden - // otherwise - check vtable - MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass); - gboolean begin_read_is_overriden = io_stream_begin_read_slot != -1 && curr_klass_vtable [io_stream_begin_read_slot]->klass != base_klass; - gboolean end_read_is_overriden = io_stream_end_read_slot != -1 && curr_klass_vtable [io_stream_end_read_slot]->klass != base_klass; - - // return true if BeginRead or EndRead were overriden - return begin_read_is_overriden || end_read_is_overriden; -} - -MonoBoolean -ves_icall_System_IO_Stream_HasOverriddenBeginEndWrite (MonoObjectHandle stream, MonoError *error) -{ - MonoClass* curr_klass = MONO_HANDLE_GETVAL (stream, vtable)->klass; - MonoClass* base_klass = mono_class_try_get_stream_class (); - - if (!io_stream_slots_set) - init_io_stream_slots (); - - MonoMethod **curr_klass_vtable = m_class_get_vtable (curr_klass); - gboolean begin_write_is_overriden = curr_klass_vtable [io_stream_begin_write_slot]->klass != base_klass; - gboolean end_write_is_overriden = curr_klass_vtable [io_stream_end_write_slot]->klass != base_klass; - - // return true if BeginWrite or EndWrite were overriden - return begin_write_is_overriden || end_write_is_overriden; -} -#endif MonoBoolean ves_icall_RuntimeMethodInfo_get_IsGenericMethod (MonoReflectionMethodHandle ref_method, MonoError *erro) @@ -3947,24 +3526,10 @@ ves_icall_InternalInvoke (MonoReflectionMethodHandle method_handle, MonoObjectHa exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "NotSupportedException", "Cannot invoke method with stack pointers via reflection"); goto return_null; } -#if ENABLE_NETCORE - if (sig->ret->byref) { - MonoType* ret_byval = m_class_get_byval_arg (mono_class_from_mono_type_internal (sig->ret)); - if (ret_byval->type == MONO_TYPE_VOID) { - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "NotSupportedException", "ByRef to void return values are not supported in reflection invocation"); - goto return_null; - } - if (m_class_is_byreflike (mono_class_from_mono_type_internal (ret_byval))) { - exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "NotSupportedException", "Cannot invoke method returning ByRef to ByRefLike type via reflection"); - goto return_null; - } - } -#else if (sig->ret->byref) { exception = mono_exception_from_name_msg (mono_defaults.corlib, "System", "NotSupportedException", "Cannot invoke method returning ByRef type via reflection"); goto return_null; } -#endif pcount = params? mono_array_length_internal (params): 0; if (pcount != sig->param_count) { @@ -4348,7 +3913,6 @@ ves_icall_System_Enum_InternalHasFlag (MonoObjectHandle a, MonoObjectHandle b, M return (a_val & b_val) == b_val; } -#ifndef ENABLE_NETCORE MonoObjectHandle ves_icall_System_Enum_get_value (MonoObjectHandle ehandle, MonoError *error) { @@ -4372,7 +3936,6 @@ ves_icall_System_Enum_get_value (MonoObjectHandle ehandle, MonoError *error) return_null: return MONO_HANDLE_NEW (MonoObject, NULL); } -#endif MonoReflectionTypeHandle ves_icall_System_Enum_get_underlying_type (MonoReflectionTypeHandle type, MonoError *error) @@ -4404,7 +3967,6 @@ ves_icall_System_Enum_InternalGetCorElementType (MonoObjectHandle this_handle, M return (int)m_class_get_byval_arg (m_class_get_element_class (klass))->type; } -#ifndef ENABLE_NETCORE int ves_icall_System_Enum_compare_value_to (MonoObjectHandle enumHandle, MonoObjectHandle otherHandle, MonoError *error) { @@ -4469,9 +4031,7 @@ ves_icall_System_Enum_compare_value_to (MonoObjectHandle enumHandle, MonoObjectH /* indicates that the enum was of an unsupported underlying type */ return 3; } -#endif -#ifndef ENABLE_NETCORE int ves_icall_System_Enum_get_hashcode (MonoObjectHandle enumHandle, MonoError *error) { @@ -4519,7 +4079,6 @@ ves_icall_System_Enum_get_hashcode (MonoObjectHandle enumHandle, MonoError *erro } return 0; } -#endif static void get_enum_field (MonoDomain *domain, MonoArrayHandle names, MonoArrayHandle values, int base_type, MonoClassField *field, guint* j, guint64 *previous_value, gboolean *sorted, MonoError *error) @@ -4573,11 +4132,7 @@ ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionTypeHandle type, Mono return_val_if_nok (error, FALSE); if (!m_class_is_enumtype (enumc)) { -#if ENABLE_NETCORE - mono_error_set_argument (error, NULL, "Type provided must be an Enum."); -#else mono_error_set_argument (error, "enumType", "Type provided must be an Enum."); -#endif return TRUE; } @@ -4951,10 +4506,6 @@ property_accessor_nonpublic (MonoMethod* accessor, gboolean start_klass) GPtrArray* ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionTypeHandle ref_type, gchar *propname, guint32 bflags, guint32 mlisttype, MonoError *error) { -#if ENABLE_NETCORE - // Fetch non-public properties as well because they can hide public properties with the same name in base classes - bflags |= BFLAGS_NonPublic; -#endif MonoType *type = MONO_HANDLE_GETVAL (ref_type, type); if (type->byref) { @@ -5029,10 +4580,6 @@ handle_parent: g_hash_table_insert (properties, prop, prop); } if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass))) { -#if ENABLE_NETCORE - // BFLAGS_NonPublic should be excluded for base classes - bflags &= ~BFLAGS_NonPublic; -#endif goto handle_parent; } @@ -5229,11 +4776,7 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssemblyHand mono_reflection_free_type_info (&info); mono_error_cleanup (parse_error); if (throwOnError) { -#if ENABLE_NETCORE - mono_error_set_argument (error, "typeName@0", "failed to parse the type"); -#else mono_error_set_argument (error, "typeName", "failed to parse the type"); -#endif goto fail; } /*g_print ("failed parse\n");*/ @@ -5415,7 +4958,6 @@ ves_icall_System_Reflection_RuntimeAssembly_get_code_base (MonoReflectionAssembl return res; } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Reflection_RuntimeAssembly_get_global_assembly_cache (MonoReflectionAssemblyHandle assembly, MonoError *error) { @@ -5444,7 +4986,6 @@ ves_icall_System_Reflection_Assembly_load_with_partial_name (MonoStringHandle mn leave: return result; } -#endif MonoStringHandle ves_icall_System_Reflection_RuntimeAssembly_get_location (MonoReflectionAssemblyHandle refassembly, MonoError *error) @@ -5455,14 +4996,12 @@ ves_icall_System_Reflection_RuntimeAssembly_get_location (MonoReflectionAssembly return mono_string_new_handle (domain, image_name != NULL ? image_name : "", error); } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Reflection_RuntimeAssembly_get_ReflectionOnly (MonoReflectionAssemblyHandle assembly_h, MonoError *error) { MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly); return mono_asmctx_get_kind (&assembly->context) == MONO_ASMCTX_REFONLY; } -#endif MonoStringHandle ves_icall_System_Reflection_RuntimeAssembly_InternalImageRuntimeVersion (MonoReflectionAssemblyHandle refassembly, MonoError *error) @@ -5532,7 +5071,6 @@ fail: return NULL_HANDLE_ARRAY; } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Reflection_RuntimeAssembly_GetAotIdInternal (MonoArrayHandle guid_h, MonoError *error) { @@ -5549,7 +5087,6 @@ ves_icall_System_Reflection_RuntimeAssembly_GetAotIdInternal (MonoArrayHandle gu return TRUE; } } -#endif static MonoAssemblyName* create_referenced_assembly_name (MonoDomain *domain, MonoImage *image, int i, MonoError *error) @@ -5620,51 +5157,6 @@ g_concat_dir_and_file (const char *dir, const char *file) return g_strconcat (dir, file, (const char*)NULL); } -#ifdef ENABLE_NETCORE -static MonoReflectionAssemblyHandle -try_resource_resolve_name (MonoReflectionAssemblyHandle assembly_handle, MonoStringHandle name_handle) -{ - MonoObjectHandle ret; - - ERROR_DECL (error); - - HANDLE_FUNCTION_ENTER (); - - if (mono_runtime_get_no_exec ()) - goto return_null; - - MONO_STATIC_POINTER_INIT (MonoMethod, resolve_method) - - static gboolean inited; - if (!inited) { - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve_method = mono_class_get_method_from_name_checked (alc_class, "OnResourceResolve", -1, 0, error); - inited = TRUE; - } - mono_error_cleanup (error); - error_init_reuse (error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve_method) - - if (!resolve_method) - goto return_null; - - gpointer args [2]; - args [0] = MONO_HANDLE_RAW (assembly_handle); - args [1] = MONO_HANDLE_RAW (name_handle); - ret = mono_runtime_try_invoke_handle (resolve_method, NULL_HANDLE, args, error); - goto_if_nok (error, return_null); - - goto exit; - -return_null: - ret = NULL_HANDLE; - -exit: - HANDLE_FUNCTION_RETURN_REF (MonoReflectionAssembly, MONO_HANDLE_CAST (MonoReflectionAssembly, ret)); -} -#endif static void * get_manifest_resource_internal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoReflectionModuleHandleOut ref_module, MonoError *error) @@ -5720,13 +5212,6 @@ ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoRef { gpointer ret = get_manifest_resource_internal (assembly_h, name, size, ref_module, error); -#ifdef ENABLE_NETCORE - if (!ret) { - MonoReflectionAssemblyHandle event_assembly_h = try_resource_resolve_name (assembly_h, name); - if (MONO_HANDLE_BOOL (event_assembly_h)) - ret = get_manifest_resource_internal (event_assembly_h, name, size, ref_module, error); - } -#endif return ret; } @@ -6061,16 +5546,6 @@ ves_icall_System_Reflection_RuntimeMethodInfo_GetMethodBodyInternal (MonoMethod return mono_method_body_get_object_handle (mono_domain_get (), method, error); } -#if ENABLE_NETCORE -MonoReflectionAssemblyHandle -ves_icall_System_Reflection_Assembly_GetExecutingAssembly (MonoStackCrawlMark *stack_mark, MonoError *error) -{ - MonoAssembly *assembly; - assembly = mono_runtime_get_caller_from_stack_mark (stack_mark); - g_assert (assembly); - return mono_assembly_get_object_handle (mono_domain_get (), assembly, error); -} -#else MonoReflectionAssemblyHandle ves_icall_System_Reflection_Assembly_GetExecutingAssembly (MonoError *error) { @@ -6079,7 +5554,6 @@ ves_icall_System_Reflection_Assembly_GetExecutingAssembly (MonoError *error) g_assert (dest); return mono_assembly_get_object_handle (mono_domain_get (), m_class_get_image (dest->klass)->assembly, error); } -#endif MonoReflectionAssemblyHandle ves_icall_System_Reflection_Assembly_GetEntryAssembly (MonoError *error) @@ -6144,7 +5618,6 @@ ves_icall_System_RuntimeType_getFullName (MonoReflectionTypeHandle object, MonoB return res; } -#ifndef ENABLE_NETCORE int ves_icall_RuntimeType_get_core_clr_security_level (MonoReflectionTypeHandle rfield, MonoError *error) { @@ -6169,7 +5642,6 @@ ves_icall_RuntimeMethodInfo_get_core_clr_security_level (MonoReflectionMethodHan MonoMethod *method = MONO_HANDLE_GETVAL (rfield, method); return mono_security_core_clr_method_level (method, TRUE); } -#endif MonoStringHandle ves_icall_System_Reflection_RuntimeAssembly_get_fullname (MonoReflectionAssemblyHandle assembly, MonoError *error) @@ -6252,7 +5724,6 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoStringHandle f g_free (filename); } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Reflection_RuntimeAssembly_LoadPermissions (MonoReflectionAssemblyHandle assembly_h, char **minimum, guint32 *minLength, char **optional, guint32 *optLength, char **refused, guint32 *refLength, MonoError *error) @@ -6282,7 +5753,6 @@ ves_icall_System_Reflection_RuntimeAssembly_LoadPermissions (MonoReflectionAssem return result; } -#endif static gboolean mono_module_type_is_visible (MonoTableInfo *tdef, MonoImage *image, int type) @@ -6488,113 +5958,12 @@ assembly_get_types (MonoReflectionAssemblyHandle assembly_handle, MonoBoolean ex return res; } -#ifndef ENABLE_NETCORE MonoArrayHandle ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssemblyHandle assembly_handle, MonoBoolean exportedOnly, MonoError *error) { return assembly_get_types (assembly_handle, exportedOnly, error); } -#endif - -#if ENABLE_NETCORE -MonoArrayHandle -ves_icall_System_Reflection_RuntimeAssembly_GetExportedTypes (MonoReflectionAssemblyHandle assembly_handle, MonoError *error) -{ - return assembly_get_types (assembly_handle, TRUE, error); -} - -static void -get_top_level_forwarded_type (MonoImage *image, MonoTableInfo *table, int i, MonoArrayHandle types, MonoArrayHandle exceptions, int *aindex, int *exception_count) -{ - ERROR_DECL (local_error); - guint32 cols [MONO_EXP_TYPE_SIZE]; - MonoClass *klass; - MonoReflectionTypeHandle rt; - - mono_metadata_decode_row (table, i, cols, MONO_EXP_TYPE_SIZE); - if (!(cols [MONO_EXP_TYPE_FLAGS] & TYPE_ATTRIBUTE_FORWARDER)) - return; - guint32 impl = cols [MONO_EXP_TYPE_IMPLEMENTATION]; - const char *name = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAME]); - const char *nspace = mono_metadata_string_heap (image, cols [MONO_EXP_TYPE_NAMESPACE]); - - g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_ASSEMBLYREF); - guint32 assembly_idx = impl >> MONO_IMPLEMENTATION_BITS; - - mono_assembly_load_reference (image, assembly_idx - 1); - g_assert (image->references [assembly_idx - 1]); - - HANDLE_FUNCTION_ENTER (); - - if (image->references [assembly_idx - 1] == REFERENCE_MISSING) { - MonoExceptionHandle ex = MONO_HANDLE_NEW (MonoException, mono_get_exception_bad_image_format ("Invalid image")); - MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE); - MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex); - (*exception_count)++; (*aindex)++; - goto exit; - } - klass = mono_class_from_name_checked (image->references [assembly_idx - 1]->image, nspace, name, local_error); - if (!is_ok (local_error)) { - MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error); - MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE); - MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex); - mono_error_cleanup (local_error); - (*exception_count)++; (*aindex)++; - goto exit; - } - rt = mono_type_get_object_handle (mono_domain_get (), m_class_get_byval_arg (klass), local_error); - if (!is_ok (local_error)) { - MonoExceptionHandle ex = mono_error_convert_to_exception_handle (local_error); - MONO_HANDLE_ARRAY_SETREF (types, *aindex, NULL_HANDLE); - MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, ex); - mono_error_cleanup (local_error); - (*exception_count)++; (*aindex)++; - goto exit; - } - MONO_HANDLE_ARRAY_SETREF (types, *aindex, rt); - MONO_HANDLE_ARRAY_SETREF (exceptions, *aindex, NULL_HANDLE); - (*aindex)++; - -exit: - HANDLE_FUNCTION_RETURN (); -} -MonoArrayHandle -ves_icall_System_Reflection_RuntimeAssembly_GetTopLevelForwardedTypes (MonoReflectionAssemblyHandle assembly_h, MonoError *error) -{ - MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly); - MonoImage *image = assembly->image; - int count = 0; - - g_assert (!assembly_is_dynamic (assembly)); - MonoTableInfo *table = &image->tables [MONO_TABLE_EXPORTEDTYPE]; - for (int i = 0; i < table->rows; ++i) { - if (mono_metadata_decode_row_col (table, i, MONO_EXP_TYPE_FLAGS) & TYPE_ATTRIBUTE_FORWARDER) - count ++; - } - - MonoArrayHandle types = mono_array_new_handle (mono_domain_get (), mono_defaults.runtimetype_class, count, error); - return_val_if_nok (error, NULL_HANDLE_ARRAY); - MonoArrayHandle exceptions = mono_array_new_handle (mono_domain_get (), mono_defaults.exception_class, count, error); - return_val_if_nok (error, NULL_HANDLE_ARRAY); - - int aindex = 0; - int exception_count = 0; - for (int i = 0; i < table->rows; ++i) { - get_top_level_forwarded_type (image, table, i, types, exceptions, &aindex, &exception_count); - } - - if (exception_count > 0) { - MonoExceptionHandle exc = MONO_HANDLE_NEW (MonoException, NULL); - MONO_HANDLE_ASSIGN (exc, mono_get_exception_reflection_type_load_checked (types, exceptions, error)); - return_val_if_nok (error, NULL_HANDLE_ARRAY); - mono_error_set_exception_handle (error, exc); - return NULL_HANDLE_ARRAY; - } - - return types; -} -#endif void ves_icall_Mono_RuntimeMarshal_FreeAssemblyName (MonoAssemblyName *aname, MonoBoolean free_struct) @@ -6846,23 +6215,6 @@ ves_icall_Mono_Runtime_DumpStateTotal (guint64 *portable_hash, guint64 *unportab return result; } -#if defined (ENABLE_NETCORE) && defined (ENABLE_METADATA_UPDATE) -void -ves_icall_Mono_Runtime_LoadMetadataUpdate (MonoAssembly *assm, - gconstpointer dmeta_bytes, int32_t dmeta_len, - gconstpointer dil_bytes, int32_t dil_len) -{ - ERROR_DECL (error); - g_assert (assm); - g_assert (dmeta_len >= 0); - MonoImage *image_base = assm->image; - g_assert (image_base); - - MonoDomain *domain = mono_domain_get (); - mono_image_load_enc_delta (domain, image_base, dmeta_bytes, dmeta_len, dil_bytes, dil_len, error); - mono_error_set_pending_exception (error); -} -#endif MonoBoolean ves_icall_System_Reflection_AssemblyName_ParseAssemblyName (const char *name, MonoAssemblyName *aname, MonoBoolean *is_version_defined_arg, MonoBoolean *is_token_defined_arg) @@ -6930,13 +6282,11 @@ mono_icall_module_get_hinstance (MonoImage *image) } #endif /* HOST_WIN32 */ -#ifndef ENABLE_NETCORE gpointer ves_icall_System_Reflection_RuntimeModule_GetHINSTANCE (MonoImage *image, MonoError *error) { return mono_icall_module_get_hinstance (image); } -#endif void ves_icall_System_Reflection_RuntimeModule_GetPEKind (MonoImage *image, gint32 *pe_kind, gint32 *machine, MonoError *error) @@ -7379,11 +6729,7 @@ check_for_invalid_array_type (MonoClass *klass, MonoError *error) static void check_for_invalid_byref_or_pointer_type (MonoClass *klass, MonoError *error) { -#ifdef ENABLE_NETCORE - return; -#else check_for_invalid_array_type (klass, error); -#endif } MonoReflectionTypeHandle @@ -7562,7 +6908,6 @@ mono_array_get_byte_length (MonoArrayHandle array) } } -#ifndef ENABLE_NETCORE gint32 ves_icall_System_Buffer_ByteLengthInternal (MonoArrayHandle array, MonoError* error) { @@ -7611,7 +6956,6 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArrayHandle src, gint32 src_offse return TRUE; } -#endif #ifndef DISABLE_REMOTING MonoObjectHandle @@ -7666,7 +7010,6 @@ ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxyHandle tp /* System.Environment */ -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Environment_get_UserName (MonoError *error) { @@ -7750,7 +7093,6 @@ ves_icall_System_Environment_get_Platform (void) { return mono_icall_get_platform (); } -#endif /* !ENABLE_NETCORE */ #ifndef HOST_WIN32 static MonoStringHandle @@ -7760,13 +7102,11 @@ mono_icall_get_new_line (MonoError *error) } #endif /* !HOST_WIN32 */ -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Environment_get_NewLine (MonoError *error) { return mono_icall_get_new_line (error); } -#endif #ifndef HOST_WIN32 static inline MonoBoolean @@ -7893,7 +7233,6 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (MonoError *error) return mono_icall_get_environment_variable_names (error); } -#ifndef ENABLE_NETCORE void ves_icall_System_Environment_InternalSetEnvironmentVariable (const gunichar2 *name, gint32 name_length, const gunichar2 *value, gint32 value_length, MonoError *error) @@ -7924,7 +7263,6 @@ exit: g_free (utf8_value); #endif } -#endif void ves_icall_System_Environment_Exit (int result) @@ -7934,10 +7272,8 @@ ves_icall_System_Environment_Exit (int result) if (!mono_runtime_try_shutdown ()) mono_thread_exit (); -#ifndef ENABLE_NETCORE /* Suspend all managed threads since the runtime is going away */ mono_thread_suspend_all_other_threads (); -#endif mono_runtime_quit_internal (); @@ -7973,13 +7309,11 @@ ves_icall_System_Environment_FailFast (MonoStringHandle message, MonoExceptionHa abort (); } -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Environment_GetGacPath (MonoError *error) { return mono_string_new_handle (mono_domain_get (), mono_assembly_getrootdir (), error); } -#endif #ifndef HOST_WIN32 static inline MonoStringHandle @@ -7991,13 +7325,11 @@ mono_icall_get_windows_folder_path (int folder, MonoError *error) } #endif /* !HOST_WIN32 */ -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Environment_GetWindowsFolderPath (int folder, MonoError *error) { return mono_icall_get_windows_folder_path (folder, error); } -#endif static MonoArrayHandle mono_icall_get_logical_drives (MonoError *error) @@ -8063,7 +7395,6 @@ leave: return result; } -#ifndef ENABLE_NETCORE MonoArrayHandle ves_icall_System_Environment_GetLogicalDrivesInternal (MonoError *error) { @@ -8171,7 +7502,6 @@ ves_icall_System_Text_EncodingHelper_InternalCodePage (gint32 *int_code_page, Mo return mono_string_new_handle (mono_domain_get (), cset, error); return NULL_HANDLE_STRING; } -#endif MonoBoolean ves_icall_System_Environment_get_HasShutdownStarted (void) @@ -8181,12 +7511,10 @@ ves_icall_System_Environment_get_HasShutdownStarted (void) #ifndef HOST_WIN32 -#ifndef ENABLE_NETCORE void ves_icall_System_Environment_BroadcastSettingChange (MonoError *error) { } -#endif #endif @@ -8197,21 +7525,12 @@ ves_icall_System_Environment_get_TickCount (void) return (gint32) (mono_msec_boottime () & 0xffffffff); } -#if ENABLE_NETCORE -gint64 -ves_icall_System_Environment_get_TickCount64 (void) -{ - return mono_msec_boottime (); -} -#endif -#ifndef ENABLE_NETCORE gint32 ves_icall_System_Runtime_Versioning_VersioningHelper_GetRuntimeId (MonoError *error) { return 9; } -#endif #ifndef DISABLE_REMOTING MonoBoolean @@ -8296,17 +7615,14 @@ ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (Mo #else /* DISABLE_REMOTING */ -#ifndef ENABLE_NETCORE void ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionTypeHandle type, MonoBoolean enable, MonoError *error) { g_assert_not_reached (); } -#endif #endif -#ifndef ENABLE_NETCORE MonoObjectHandle ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionTypeHandle type, MonoError *error) { @@ -8413,7 +7729,6 @@ ves_icall_System_TimeZoneInfo_mono_timezone_get_local_name (MonoString **result) } #endif -#endif /* ENABLE_NETCORE */ #ifndef PLATFORM_NO_DRIVEINFO MonoBoolean @@ -8447,7 +7762,6 @@ ves_icall_RuntimeMethodHandle_GetFunctionPointer (MonoMethod *method, MonoError return mono_compile_method_checked (method, error); } -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (MonoError *error) @@ -8592,7 +7906,6 @@ ves_icall_get_resources_ptr (MonoReflectionAssemblyHandle assembly, gpointer *re return TRUE; } -#endif /* ENABLE_NETCORE */ MonoBoolean ves_icall_System_Diagnostics_Debugger_IsAttached_internal (void) @@ -8622,13 +7935,11 @@ mono_icall_write_windows_debug_string (const gunichar2 *message) } #endif /* !HOST_WIN32 */ -#ifndef ENABLE_NETCORE void ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (const gunichar2 *message, MonoError *error) { mono_icall_write_windows_debug_string (message); } -#endif /* Only used for value types */ MonoObjectHandle @@ -8838,8 +8149,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionTypeH void ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionTypeHandle type, MonoError *error) { - g_assert_not_netcore (); - error_init (error); MonoClass *klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (type, type)); MonoMethod* m; @@ -8854,7 +8163,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionTypeH } } -#ifndef ENABLE_NETCORE /* * used by System.Runtime.InteropServices.RuntimeInformation.(OS|Process)Architecture; * which use them in different ways for filling in an enum @@ -8873,7 +8181,6 @@ ves_icall_System_Runtime_InteropServices_RuntimeInformation_GetOSName (MonoError { return mono_string_new_handle (mono_domain_get (), mono_config_get_os (), error); } -#endif /* ENABLE_NETCORE */ int ves_icall_Interop_Sys_DoubleToString(double value, char *format, char *buffer, int bufferLength) @@ -9157,7 +8464,6 @@ mono_icall_wait_for_input_idle (gpointer handle, gint32 milliseconds) } #endif /* !HOST_WIN32 */ -#ifndef ENABLE_NETCORE gint32 ves_icall_Microsoft_Win32_NativeMethods_WaitForInputIdle (gpointer handle, gint32 milliseconds) { @@ -9179,7 +8485,6 @@ ves_icall_Mono_TlsProviderFactory_IsBtlsSupported (void) return FALSE; #endif } -#endif /* ENABLE_NETCORE */ #ifndef DISABLE_COM @@ -9247,7 +8552,6 @@ ves_icall_System_Runtime_InteropServices_WindowsRuntime_UnsafeNativeMethods_Wind #endif -#if !ENABLE_NETCORE void ves_icall_System_IO_LogcatTextWriter_Log (const char *appname, gint32 level, const char *message) @@ -9255,7 +8559,6 @@ ves_icall_System_IO_LogcatTextWriter_Log (const char *appname, gint32 level, con g_log (appname, (GLogLevelFlags)level, "%s", message); } -#endif static const MonoIcallTableCallbacks *icall_table; static mono_mutex_t icall_mutex; @@ -9838,13 +9141,6 @@ ves_icall_System_GC_GetAllocatedBytesForCurrentThread (void) return mono_gc_get_allocated_bytes_for_current_thread (); } -#ifdef ENABLE_NETCORE -guint64 -ves_icall_System_GC_GetTotalAllocatedBytes (MonoBoolean precise, MonoError* error) -{ - return mono_gc_get_total_allocated_bytes (precise); -} -#endif void ves_icall_System_GC_RecordPressure (gint64 value) @@ -9889,7 +9185,6 @@ ves_icall_System_Environment_get_ProcessorCount (void) return mono_cpu_count (); } -#if !defined(ENABLE_NETCORE) #if defined(ENABLE_MONODROID) G_EXTERN_C gpointer CreateNLSocket (void); @@ -9915,7 +9210,6 @@ ves_icall_System_Net_NetworkInformation_LinuxNetworkChange_CloseNLSocket (gpoint } #endif -#endif // Generate wrappers. diff --git a/mono/metadata/image.c b/mono/metadata/image.c index b0733c7e14e..8b82bfa6333 100644 --- a/mono/metadata/image.c +++ b/mono/metadata/image.c @@ -260,9 +260,7 @@ mono_images_init (void) images_storage_hash = g_hash_table_new (g_str_hash, g_str_equal); -#ifndef ENABLE_NETCORE mono_loaded_images_init (mono_get_global_loaded_images (), NULL); -#endif debug_assembly_unload = g_hasenv ("MONO_DEBUG_ASSEMBLY_UNLOAD"); @@ -281,9 +279,7 @@ mono_images_cleanup (void) { mono_os_mutex_destroy (&images_mutex); -#ifndef ENABLE_NETCORE mono_loaded_images_cleanup (mono_get_global_loaded_images (), TRUE); -#endif g_hash_table_destroy (images_storage_hash); @@ -715,7 +711,6 @@ mono_image_check_for_module_cctor (MonoImage *image) image->checked_module_cctor = TRUE; } -#ifndef ENABLE_NETCORE static void load_modules (MonoImage *image) { @@ -729,7 +724,6 @@ load_modules (MonoImage *image) image->modules_loaded = g_new0 (gboolean, t->rows); image->module_count = t->rows; } -#endif /** * mono_image_load_module_checked: @@ -747,10 +741,6 @@ mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error) if (image->modules_loaded [idx - 1]) return image->modules [idx - 1]; -#ifdef ENABLE_NETCORE - /* SRE still uses image->modules, but they are not loaded from files, so the rest of this function is dead code for netcore */ - g_assert_not_reached (); -#else MonoTableInfo *t; MonoTableInfo *file_table; int i; @@ -821,7 +811,6 @@ mono_image_load_module_checked (MonoImage *image, int idx, MonoError *error) g_list_free (valid_modules); return image->modules [idx - 1]; -#endif } /** @@ -1565,9 +1554,7 @@ do_mono_image_load (MonoImage *image, MonoImageOpenStatus *status, mono_image_load_time_date_stamp (image); -#ifndef ENABLE_NETCORE load_modules (image); -#endif done: MONO_PROFILER_RAISE (image_loaded, (image)); @@ -1801,9 +1788,6 @@ do_mono_image_open (MonoAssemblyLoadContext *alc, const char *fname, MonoImageOp image->ref_count = 1; /* if MONO_SECURITY_MODE_CORE_CLR is set then determine if this image is platform code */ image->core_clr_platform_code = mono_security_core_clr_determine_platform_image (image); -#ifdef ENABLE_NETCORE - image->alc = alc; -#endif return do_mono_image_load (image, status, care_about_cli, care_about_pecoff); } @@ -1913,7 +1897,6 @@ mono_image_loaded_by_guid_full (const char *guid, gboolean refonly) static MonoImage * mono_image_loaded_by_guid_internal (const char *guid, gboolean refonly) { -#ifndef ENABLE_NETCORE GuidData data; GHashTable *loaded_images = mono_loaded_images_get_hash (mono_get_global_loaded_images (), refonly); data.res = NULL; @@ -1923,10 +1906,6 @@ mono_image_loaded_by_guid_internal (const char *guid, gboolean refonly) g_hash_table_foreach (loaded_images, find_by_guid, &data); mono_images_unlock (); return data.res; -#else - /* TODO: Maybe implement this for netcore by searching only the default ALC of the current domain */ - return NULL; -#endif } /** @@ -1973,13 +1952,6 @@ register_image (MonoLoadedImages *li, MonoImage *image, gboolean *problematic) { MonoImage *image2; char *name = image->name; -#ifdef ENABLE_NETCORE - /* Since we register cultures by file name, we need to make this culture aware for - satellite assemblies */ - char *name_with_culture = mono_image_get_name_with_culture_if_needed (image); - if (name_with_culture) - name = name_with_culture; -#endif GHashTable *loaded_images = mono_loaded_images_get_hash (li, image->ref_only); mono_images_lock (); @@ -1990,9 +1962,6 @@ register_image (MonoLoadedImages *li, MonoImage *image, gboolean *problematic) mono_image_addref (image2); mono_images_unlock (); mono_image_close (image); -#ifdef ENABLE_NETCORE - g_free (name_with_culture); -#endif return image2; } @@ -2007,9 +1976,6 @@ register_image (MonoLoadedImages *li, MonoImage *image, gboolean *problematic) if (problematic) *problematic = TRUE; } -#ifdef ENABLE_NETCORE - g_free (name_with_culture); -#endif return image; } @@ -2047,9 +2013,6 @@ mono_image_open_from_data_internal (MonoAssemblyLoadContext *alc, char *data, gu image->ref_only = refonly; image->metadata_only = metadata_only; image->ref_count = 1; -#ifdef ENABLE_NETCORE - image->alc = alc; -#endif image = do_mono_image_load (image, status, TRUE, TRUE); if (image == NULL) @@ -2063,11 +2026,7 @@ mono_image_open_from_data_alc (MonoAssemblyLoadContextGCHandle alc_gchandle, cha { MonoImage *result; MONO_ENTER_GC_UNSAFE; -#ifdef ENABLE_NETCORE - MonoAssemblyLoadContext *alc = mono_alc_from_gchandle (alc_gchandle); -#else MonoAssemblyLoadContext *alc = mono_domain_default_alc (mono_domain_get ()); -#endif result = mono_image_open_from_data_internal (alc, data, data_len, need_copy, status, FALSE, FALSE, name, name); MONO_EXIT_GC_UNSAFE; return result; @@ -2158,9 +2117,6 @@ mono_image_open_from_module_handle (MonoAssemblyLoadContext *alc, HMODULE module image->name = fname; image->filename = g_strdup (image->name); image->ref_count = has_entry_point ? 0 : 1; -#ifdef ENABLE_NETCORE - image->alc = alc; -#endif image = do_mono_image_load (image, status, TRUE, TRUE); if (image == NULL) @@ -2696,9 +2652,7 @@ mono_image_close_except_pools (MonoImage *image) if (image->mvar_gparam_cache) mono_conc_hashtable_destroy (image->mvar_gparam_cache); free_hash (image->wrapper_param_names); -#ifndef ENABLE_NETCORE free_hash (image->pinvoke_scopes); -#endif free_hash (image->native_func_wrapper_cache); mono_conc_hashtable_destroy (image->typespec_cache); free_hash (image->weak_field_indexes); diff --git a/mono/metadata/loaded-images-global.c b/mono/metadata/loaded-images-global.c index 645b0cd271c..dbcf79dc51b 100644 --- a/mono/metadata/loaded-images-global.c +++ b/mono/metadata/loaded-images-global.c @@ -3,7 +3,6 @@ #include "mono/metadata/loaded-images-internals.h" #include "mono/metadata/metadata-internals.h" -#ifndef ENABLE_NETCORE /* Global image hashes should not be in netcore Mono */ static MonoLoadedImages global_loaded_images; /* zero initalized is good enough */ @@ -62,4 +61,3 @@ mono_alc_get_loaded_images (MonoAssemblyLoadContext *alc) return mono_get_global_loaded_images (); } -#endif /* ENABLE_NETCORE */ diff --git a/mono/metadata/loaded-images-internals.h b/mono/metadata/loaded-images-internals.h index 7eb2b2833dd..e75093af295 100644 --- a/mono/metadata/loaded-images-internals.h +++ b/mono/metadata/loaded-images-internals.h @@ -50,10 +50,8 @@ mono_loaded_images_remove_image (MonoImage *image); MonoLoadedImages* mono_image_get_loaded_images_for_modules (MonoImage *image); -#ifndef ENABLE_NETCORE MonoLoadedImages* mono_get_global_loaded_images (void); -#endif MonoImage * mono_find_image_owner (void *ptr); diff --git a/mono/metadata/loaded-images-netcore.c b/mono/metadata/loaded-images-netcore.c deleted file mode 100644 index 3d15afd5b9b..00000000000 --- a/mono/metadata/loaded-images-netcore.c +++ /dev/null @@ -1,38 +0,0 @@ -#include "config.h" - -#include "mono/metadata/loaded-images-internals.h" - -#ifdef ENABLE_NETCORE -/* Should be compiling loaded-images-netcore.c only for netcore Mono */ - -// This is support for the mempool reference tracking feature in checked-build, -// but lives in loaded-images-netcore.c due to use of static variables of this -// file. - -/** - * mono_find_image_owner: - * - * Find the image, if any, which a given pointer is located in the memory of. - */ -MonoImage * -mono_find_image_owner (void *ptr) -{ - /* FIXME: this function is a bit annoying to implement without a global - * table of all the loaded images. We need to traverse all the domains - * and each ALC in each domain. */ - return NULL; -} - -MonoLoadedImages * -mono_alc_get_loaded_images (MonoAssemblyLoadContext *alc) -{ - g_assert (alc); - g_assert (alc->loaded_images); - return alc->loaded_images; -} - -#else - -MONO_EMPTY_SOURCE_FILE (loaded_images_netcore); - -#endif /* ENABLE_NETCORE */ diff --git a/mono/metadata/loaded-images.c b/mono/metadata/loaded-images.c index c0fa0d5e6aa..9cb57828234 100644 --- a/mono/metadata/loaded-images.c +++ b/mono/metadata/loaded-images.c @@ -104,11 +104,6 @@ mono_loaded_images_remove_image (MonoImage *image) loaded_images_by_name = mono_loaded_images_get_by_name_hash (li, image->ref_only); name = image->name; -#ifdef ENABLE_NETCORE - char *name_with_culture = mono_image_get_name_with_culture_if_needed (image); - if (name_with_culture) - name = name_with_culture; -#endif image2 = (MonoImage *)g_hash_table_lookup (loaded_images, name); if (image == image2) { /* This is not true if we are called from mono_image_open () */ @@ -118,9 +113,6 @@ mono_loaded_images_remove_image (MonoImage *image) g_hash_table_remove (loaded_images_by_name, (char *) image->assembly_name); proceed = TRUE; -#ifdef ENABLE_NETCORE - g_free (name_with_culture); -#endif done: mono_images_unlock (); @@ -131,9 +123,5 @@ done: MonoLoadedImages* mono_image_get_loaded_images_for_modules (MonoImage *image) { -#ifndef ENABLE_NETCORE return mono_get_global_loaded_images (); -#else - g_assert_not_reached (); -#endif } diff --git a/mono/metadata/loader-internals.h b/mono/metadata/loader-internals.h index e0d67f22763..286a1f3b164 100644 --- a/mono/metadata/loader-internals.h +++ b/mono/metadata/loader-internals.h @@ -17,15 +17,6 @@ #include <mono/utils/mono-error.h> #include <mono/utils/mono-forward.h> -#ifdef ENABLE_NETCORE -#if defined(TARGET_OSX) -#define MONO_LOADER_LIBRARY_NAME "libcoreclr.dylib" -#elif defined(TARGET_ANDROID) -#define MONO_LOADER_LIBRARY_NAME "libmonodroid.so" -#else -#define MONO_LOADER_LIBRARY_NAME "libcoreclr.so" -#endif -#endif G_BEGIN_DECLS @@ -33,9 +24,6 @@ typedef struct _MonoLoadedImages MonoLoadedImages; typedef struct _MonoAssemblyLoadContext MonoAssemblyLoadContext; typedef struct _MonoMemoryManager MonoMemoryManager; typedef struct _MonoSingletonMemoryManager MonoSingletonMemoryManager; -#ifdef ENABLE_NETCORE -typedef struct _MonoGenericMemoryManager MonoGenericMemoryManager; -#endif struct _MonoBundledSatelliteAssembly { const char *name; @@ -55,31 +43,6 @@ struct _MonoDllMap { }; #endif -#ifdef ENABLE_NETCORE -struct _MonoAssemblyLoadContext { - MonoDomain *domain; - MonoLoadedImages *loaded_images; - GSList *loaded_assemblies; - // If taking this with the domain assemblies_lock, always take this second - MonoCoopMutex assemblies_lock; - // Holds ALC-specific memory - MonoSingletonMemoryManager *memory_manager; - GPtrArray *generic_memory_managers; - // Protects generic_memory_managers; if taking this with the domain alcs_lock, always take this second - MonoCoopMutex memory_managers_lock; - // Handle of the corresponding managed object. If the ALC is - // collectible, the handle is weak, otherwise it's strong. - MonoGCHandle gchandle; - // Whether the ALC can be unloaded; should only be set at creation - gboolean collectible; - // Set to TRUE when the unloading process has begun - gboolean unloading; - // Used in native-library.c for the hash table below; do not access anywhere else - MonoCoopMutex pinvoke_lock; - // Maps malloc-ed char* pinvoke scope -> MonoDl* - GHashTable *pinvoke_scopes; -}; -#endif /* ENABLE_NETCORE */ struct _MonoMemoryManager { MonoDomain *domain; @@ -117,15 +80,6 @@ struct _MonoSingletonMemoryManager { MonoAssemblyLoadContext *alc; }; -#ifdef ENABLE_NETCORE -struct _MonoGenericMemoryManager { - MonoMemoryManager memory_manager; - - // Parent ALCs - int n_alcs; - MonoAssemblyLoadContext **alcs; -}; -#endif void mono_global_loader_data_lock (void); @@ -150,52 +104,11 @@ mono_global_loader_cache_init (void); void mono_global_loader_cache_cleanup (void); -#ifdef ENABLE_NETCORE -void -mono_set_pinvoke_search_directories (int dir_count, char **dirs); - -void -mono_alc_create_default (MonoDomain *domain); - -MonoAssemblyLoadContext * -mono_alc_create_individual (MonoDomain *domain, MonoGCHandle this_gchandle, gboolean collectible, MonoError *error); - -void -mono_alc_assemblies_lock (MonoAssemblyLoadContext *alc); - -void -mono_alc_assemblies_unlock (MonoAssemblyLoadContext *alc); - -void -mono_alc_memory_managers_lock (MonoAssemblyLoadContext *alc); - -void -mono_alc_memory_managers_unlock (MonoAssemblyLoadContext *alc); - -gboolean -mono_alc_is_default (MonoAssemblyLoadContext *alc); - -MonoAssembly* -mono_alc_invoke_resolve_using_load_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname); - -MonoAssembly* -mono_alc_invoke_resolve_using_resolving_event_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname); - -MonoAssembly* -mono_alc_invoke_resolve_using_resolve_satellite_nofail (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname); - -MonoAssemblyLoadContext * -mono_alc_from_gchandle (MonoGCHandle alc_gchandle); -#endif /* ENABLE_NETCORE */ static inline MonoDomain * mono_alc_domain (MonoAssemblyLoadContext *alc) { -#ifdef ENABLE_NETCORE - return alc->domain; -#else return mono_domain_get (); -#endif } MonoLoadedImages * diff --git a/mono/metadata/locales.h b/mono/metadata/locales.h index 8746cf98433..de806988ef2 100644 --- a/mono/metadata/locales.h +++ b/mono/metadata/locales.h @@ -16,7 +16,6 @@ #include <mono/metadata/object-internals.h> #include <mono/metadata/icalls.h> -#if !ENABLE_NETCORE /* This is a copy of System.Globalization.CompareOptions */ typedef enum { @@ -53,7 +52,6 @@ ICALL_EXPORT gint32 ves_icall_System_Globalization_CompareInfo_internal_index (const gunichar2 *source, gint32 sindex, gint32 count, const gunichar2 *value, gint32 value_length, MonoBoolean first); -#endif /* !ENABLE_NETCORE */ #define MONO_LOCALE_INVARIANT (0x007F) diff --git a/mono/metadata/marshal-ilgen.c b/mono/metadata/marshal-ilgen.c index b72a45c007c..ea8880024fa 100644 --- a/mono/metadata/marshal-ilgen.c +++ b/mono/metadata/marshal-ilgen.c @@ -1645,13 +1645,6 @@ handle_enum: if (sig->ret->byref) { /* perform indirect load and return by value */ -#ifdef ENABLE_NETCORE - int pos; - mono_mb_emit_byte (mb, CEE_DUP); - pos = mono_mb_emit_branch (mb, CEE_BRTRUE); - mono_mb_emit_exception_full (mb, "Mono", "NullByRefReturnException", NULL); - mono_mb_patch_branch (mb, pos); -#endif int ldind_op; MonoType* ret_byval = m_class_get_byval_arg (mono_class_from_mono_type_internal (sig->ret)); @@ -2061,40 +2054,6 @@ emit_native_wrapper_ilgen (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSi if (need_gc_safe) gc_safe_transition_builder_add_locals (&gc_safe_transition_builder); -#ifdef ENABLE_NETCORE - if (!func && !aot && !func_param && !MONO_CLASS_IS_IMPORT (mb->method->klass)) { - /* - * On netcore, its possible to register pinvoke resolvers at runtime, so - * a pinvoke lookup can fail, and then succeed later. So if the - * original lookup failed, do a lookup every time until it - * succeeds. - * This adds some overhead, but only when the pinvoke lookup - * was not initially successful. - * FIXME: AOT case - */ - func_addr_local = mono_mb_add_local (mb, int_type); - - int cache_local = mono_mb_add_local (mb, int_type); - mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); - mono_mb_emit_op (mb, CEE_MONO_PINVOKE_ADDR_CACHE, &piinfo->method); - mono_mb_emit_stloc (mb, cache_local); - - mono_mb_emit_ldloc (mb, cache_local); - mono_mb_emit_byte (mb, CEE_LDIND_I); - int pos = mono_mb_emit_branch (mb, CEE_BRTRUE); - - mono_mb_emit_ldloc (mb, cache_local); - mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); - mono_mb_emit_op (mb, CEE_MONO_METHODCONST, &piinfo->method); - mono_mb_emit_icall (mb, mono_marshal_lookup_pinvoke); - mono_mb_emit_byte (mb, CEE_STIND_I); - - mono_mb_patch_branch (mb, pos); - mono_mb_emit_ldloc (mb, cache_local); - mono_mb_emit_byte (mb, CEE_LDIND_I); - mono_mb_emit_stloc (mb, func_addr_local); - } -#endif /* * cookie = mono_threads_enter_gc_safe_region_unbalanced (ref dummy); @@ -6513,11 +6472,7 @@ emit_create_string_hack_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *csig, { int i; -#ifdef ENABLE_NETCORE - g_assert (!mono_method_signature_internal (res)->hasthis); -#else mono_mb_emit_byte (mb, CEE_LDARG_0); -#endif for (i = 1; i <= csig->param_count; i++) mono_mb_emit_ldarg (mb, i); mono_mb_emit_managed_call (mb, res, NULL); diff --git a/mono/metadata/marshal-windows.c b/mono/metadata/marshal-windows.c index 1220048c84b..8631a829393 100644 --- a/mono/metadata/marshal-windows.c +++ b/mono/metadata/marshal-windows.c @@ -83,8 +83,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (const guni char* ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (const gunichar2 *s, int length) { - g_assert_not_netcore (); - // FIXME pass mono_utf16_to_utf8 an allocator to avoid double alloc/copy. ERROR_DECL (error); diff --git a/mono/metadata/marshal.c b/mono/metadata/marshal.c index f75f843df03..e3ca84bc324 100644 --- a/mono/metadata/marshal.c +++ b/mono/metadata/marshal.c @@ -111,10 +111,6 @@ delegate_hash_table_remove (MonoDelegate *d); GENERATE_TRY_GET_CLASS_WITH_CACHE (stringbuilder, "System.Text", "StringBuilder"); static GENERATE_TRY_GET_CLASS_WITH_CACHE (unmanaged_function_pointer_attribute, "System.Runtime.InteropServices", "UnmanagedFunctionPointerAttribute"); -#ifdef ENABLE_NETCORE -static GENERATE_TRY_GET_CLASS_WITH_CACHE (suppress_gc_transition_attribute, "System.Runtime.InteropServices", "SuppressGCTransitionAttribute") -static GENERATE_TRY_GET_CLASS_WITH_CACHE (unmanaged_callers_only_attribute, "System.Runtime.InteropServices", "UnmanagedCallersOnlyAttribute") -#endif static gboolean type_is_blittable (MonoType *type); @@ -1230,10 +1226,6 @@ handle_enum: MonoAsyncResult * mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params) { -#ifdef ENABLE_NETCORE - mono_set_pending_exception (mono_exception_from_name (mono_defaults.corlib, "System", "PlatformNotSupportedException")); - return NULL; -#else ERROR_DECL (error); MonoMulticastDelegate *mcast_delegate; MonoClass *klass; @@ -1298,7 +1290,6 @@ mono_delegate_begin_invoke (MonoDelegate *delegate, gpointer *params) MonoAsyncResult *result = mono_threadpool_begin_invoke (mono_domain_get (), (MonoObject*) delegate, method, params, error); mono_error_set_pending_exception (error); return result; -#endif } static char* @@ -1945,10 +1936,6 @@ mono_marshal_get_delegate_begin_invoke (MonoMethod *method) MonoObject * mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params) { -#ifdef ENABLE_NETCORE - mono_set_pending_exception (mono_exception_from_name (mono_defaults.corlib, "System", "PlatformNotSupportedException")); - return NULL; -#else ERROR_DECL (error); MonoDomain *domain = mono_domain_get (); MonoAsyncResult *ares; @@ -2048,7 +2035,6 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params) mono_method_return_message_restore (method, params, out_args, error); mono_error_set_pending_exception (error); return res; -#endif } /** @@ -3357,29 +3343,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, csig->pinvoke = 0; res = NULL; -#ifdef ENABLE_NETCORE - iter = NULL; - while ((m = mono_class_get_methods (mono_defaults.string_class, &iter))) { - /* - * Find the corresponding String::Ctor () method which has the same signature but its static - * and returns a string. - */ - if (!strcmp ("Ctor", m->name)) { - int i; - - MonoMethodSignature *rsig = mono_method_signature_internal (m); - if (csig->param_count == rsig->param_count) { - for (i = 0; i < csig->param_count; ++i) - if (!mono_metadata_type_equal (csig->params [i], rsig->params [i])) - break; - if (i == csig->param_count) { - res = m; - break; - } - } - } - } -#else iter = NULL; while ((m = mono_class_get_methods (mono_defaults.string_class, &iter))) { if (!strcmp ("CreateString", m->name) && @@ -3388,7 +3351,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, break; } } -#endif g_assert (res); WrapperInfo *info; @@ -3436,12 +3398,7 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, * In AOT mode and embedding scenarios, it is possible that the icall is not * registered in the runtime doing the AOT compilation. */ -#ifdef ENABLE_NETCORE - /* Handled at runtime */ - pinvoke_not_found = !pinvoke && !piinfo->addr && !aot; -#else pinvoke_not_found = !piinfo->addr && !aot; -#endif if (pinvoke_not_found) { /* if there's no code but the error isn't set, just use a fairly generic exception. */ if (is_ok (emitted_error)) @@ -3496,29 +3453,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions, mspecs = g_new (MonoMarshalSpec*, sig->param_count + 1); mono_method_get_marshal_info (method, mspecs); -#ifdef ENABLE_NETCORE - if (mono_class_try_get_suppress_gc_transition_attribute_class ()) { - MonoCustomAttrInfo *cinfo; - ERROR_DECL (error); - - cinfo = mono_custom_attrs_from_method_checked (method, error); - mono_error_assert_ok (error); - gboolean found = FALSE; - if (cinfo) { - for (i = 0; i < cinfo->num_attrs; ++i) { - MonoClass *ctor_class = cinfo->attrs [i].ctor->klass; - if (ctor_class == mono_class_try_get_suppress_gc_transition_attribute_class ()) { - found = TRUE; - break; - } - } - } - if (found) - skip_gc_trans = TRUE; - if (cinfo && !cinfo->cached) - mono_custom_attrs_free (cinfo); - } -#endif MonoNativeWrapperFlags flags = aot ? EMIT_NATIVE_WRAPPER_AOT : (MonoNativeWrapperFlags)0; flags |= check_exceptions ? EMIT_NATIVE_WRAPPER_CHECK_EXCEPTIONS : (MonoNativeWrapperFlags)0; @@ -5042,8 +4976,6 @@ void ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged (MonoArrayHandle src, gint32 start_index, gpointer dest, gint32 length, gconstpointer managed_source_addr, MonoError *error) { - g_assert_not_netcore (); - if (length != 0) { MonoGCHandle gchandle = 0; gsize const bytes = copy_managed_common (src, dest, start_index, length, (gpointer*)&managed_source_addr, &gchandle, error); @@ -5061,8 +4993,6 @@ void ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged (gconstpointer src, gint32 start_index, MonoArrayHandle dest, gint32 length, gpointer managed_dest_addr, MonoError *error) { - g_assert_not_netcore (); - if (length != 0) { MonoGCHandle gchandle = 0; gsize const bytes = copy_managed_common (dest, src, start_index, length, &managed_dest_addr, &gchandle, error); @@ -5078,8 +5008,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi (const char *pt MonoStringHandle ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi (const char *ptr, MonoError *error) { - g_assert_not_netcore (); - if (!ptr) return NULL_HANDLE_STRING; return mono_string_new_handle (mono_domain_get (), ptr, error); @@ -5091,8 +5019,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len (const char MonoStringHandle ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len (const char *ptr, gint32 len, MonoError *error) { - g_assert_not_netcore (); - if (!ptr) { mono_error_set_argument_null (error, "ptr", ""); return NULL_HANDLE_STRING; @@ -5106,8 +5032,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni (const gunichar2 MonoStringHandle ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni (const gunichar2 *ptr, MonoError *error) { - g_assert_not_netcore (); - gsize len = 0; const gunichar2 *t = ptr; @@ -5129,8 +5053,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len (const gunic MonoStringHandle ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len (const gunichar2 *ptr, gint32 len, MonoError *error) { - g_assert_not_netcore (); - if (!ptr) { mono_error_set_argument_null (error, "ptr", ""); return NULL_HANDLE_STRING; @@ -5190,17 +5112,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr (MonoObjectHandl MONO_CHECK_ARG_NULL_HANDLE_NAMED (obj, "structure",); MONO_CHECK_ARG_NULL_NAMED (dst, "ptr",); -#ifdef ENABLE_NETCORE - MonoClass *klass = mono_handle_class (obj); - if (m_class_is_auto_layout (klass)) { - mono_error_set_argument (error, "structure", "The specified structure must be blittable or have layout information."); - return; - } - if (m_class_is_ginst (klass)) { - mono_error_set_argument (error, "structure", "The specified object must not be an instance of a generic type."); - return; - } -#endif MonoMethod *method = mono_marshal_get_struct_to_ptr (mono_handle_class (obj)); @@ -5220,30 +5131,6 @@ ptr_to_structure (gconstpointer src, MonoObjectHandle dst, MonoError *error) mono_runtime_invoke_checked (method, NULL, pa, error); } -#ifdef ENABLE_NETCORE - -void -ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructureInternal (gconstpointer src, MonoObjectHandle dst, MonoBoolean allow_vtypes, MonoError *error) -{ - MonoType *t; - MonoClass *klass; - - t = m_class_get_byval_arg (mono_handle_class (dst)); - if (!allow_vtypes && MONO_TYPE_ISSTRUCT (t)) { - mono_error_set_argument (error, "structure", "The structure must not be a value class."); - return; - } - - klass = mono_class_from_mono_type_internal (t); - if (m_class_is_auto_layout (klass)) { - mono_error_set_argument (error, "structure", "The specified structure must be blittable or have layout information."); - return; - } - - ptr_to_structure (src, dst, error); -} - -#else void ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure (gconstpointer src, MonoObjectHandle dst, MonoError *error) @@ -5283,7 +5170,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type (gconstpoin return res; } -#endif // !NETCORE int ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionTypeHandle ref_type, MonoStringHandle field_name, MonoError *error) @@ -5294,20 +5180,12 @@ ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionTypeHan return 0; } if (MONO_HANDLE_IS_NULL (field_name)) { -#ifdef ENABLE_NETCORE - mono_error_set_argument_null (error, NULL, ""); -#else mono_error_set_argument_null (error, "fieldName", ""); -#endif return 0; } if (!m_class_is_runtime_type (MONO_HANDLE_GET_CLASS (ref_type))) { -#ifdef ENABLE_NETCORE - mono_error_set_argument (error, "fieldName", ""); -#else mono_error_set_argument (error, "type", ""); -#endif return 0; } @@ -5318,12 +5196,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf (MonoReflectionTypeHan MonoClass *klass = mono_class_from_mono_type_internal (type); if (!mono_class_init_checked (klass, error)) return 0; -#ifdef ENABLE_NETCORE - if (m_class_is_auto_layout (klass)) { - mono_error_set_argument (error, NULL, ""); - return 0; - } -#endif int match_index = -1; while (klass && match_index == -1) { MonoClassField* field; @@ -5365,8 +5237,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (const guni char* ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi (const gunichar2 *utf16, int length) { - g_assert_not_netcore (); - ERROR_DECL (error); char * const utf8 = mono_utf16_to_utf8 (utf16, length, error); @@ -5390,8 +5260,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni (const gunic gunichar2* ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni (const gunichar2 *s, int length) { - g_assert_not_netcore (); - if (!s) return NULL; @@ -5475,13 +5343,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure (gpointer src, MonoClass *klass = mono_class_from_mono_type_handle (type); if (!mono_class_init_checked (klass, error)) return; -#ifdef ENABLE_NETCORE - if (m_class_is_auto_layout (klass)) { - mono_error_set_argument (error, "structureType", "The specified structure must be blittable or have layout information."); - return; - } - -#endif mono_struct_delete_old (klass, (char *)src); } @@ -5568,8 +5429,6 @@ ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMemSize (gsize size) void* ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMemSize (gsize size) { - g_assert_not_netcore (); - void *res = mono_marshal_alloc_co_task_mem (size); if (!res) { @@ -5610,14 +5469,12 @@ ves_icall_System_Runtime_InteropServices_Marshal_ReAllocCoTaskMem (gpointer ptr, return res; } -#ifndef ENABLE_NETCORE gpointer ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement (MonoArrayHandle arrayobj, int index, MonoError *error) { int esize = mono_array_element_size (mono_handle_class (arrayobj)); return mono_array_addr_with_size_fast (MONO_HANDLE_RAW (arrayobj), esize, index); } -#endif MonoDelegateHandle ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal (void *ftn, MonoReflectionTypeHandle type, MonoError *error) @@ -6006,16 +5863,6 @@ mono_marshal_type_size (MonoType *type, MonoMarshalSpec *mspec, guint32 *align, *align = 16; return 16; } -#ifdef ENABLE_NETCORE - else if (strcmp (m_class_get_name_space (klass), "System") == 0 && - strcmp (m_class_get_name (klass), "Decimal") == 0) { - - // Special case: Managed Decimal consists of 4 int32 fields, the alignment should be 8 on x64 to follow - // https://github.com/dotnet/coreclr/blob/4450e5ca663b9e66c20e6f9751c941efa3716fde/src/vm/methodtablebuilder.cpp#L9753 - *align = MONO_ABI_ALIGNOF (gpointer); - return mono_class_native_size (klass, NULL); - } -#endif padded_size = mono_class_native_size (klass, align); if (padded_size == 0) padded_size = 1; @@ -6505,24 +6352,5 @@ get_marshal_cb (void) gboolean mono_method_has_unmanaged_callers_only_attribute (MonoMethod *method) { -#ifndef ENABLE_NETCORE return FALSE; -#else - ERROR_DECL (attr_error); - MonoClass *attr_klass = NULL; - attr_klass = mono_class_try_get_unmanaged_callers_only_attribute_class (); - if (!attr_klass) - return FALSE; - MonoCustomAttrInfo *cinfo; - cinfo = mono_custom_attrs_from_method_checked (method, attr_error); - if (!is_ok (attr_error) || !cinfo) { - mono_error_cleanup (attr_error); - return FALSE; - } - gboolean result; - result = mono_custom_attrs_has_attr (cinfo, attr_klass); - if (!cinfo->cached) - mono_custom_attrs_free (cinfo); - return result; -#endif } diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h index 0e6bf2429ec..fe89dde8f5c 100644 --- a/mono/metadata/metadata-internals.h +++ b/mono/metadata/metadata-internals.h @@ -169,11 +169,7 @@ struct _MonoAssemblyName { uint32_t hash_alg; uint32_t hash_len; uint32_t flags; -#ifdef ENABLE_NETCORE - int32_t major, minor, build, revision, arch; -#else uint16_t major, minor, build, revision, arch; -#endif //Add members for correct work with mono_stringify_assembly_name MonoBoolean without_version; MonoBoolean without_culture; @@ -466,12 +462,6 @@ struct _MonoImage { */ MonoAssembly *assembly; -#ifdef ENABLE_NETCORE - /* - * The AssemblyLoadContext that this image was loaded into. - */ - MonoAssemblyLoadContext *alc; -#endif /* * Indexed by method tokens and typedef tokens. @@ -574,10 +564,8 @@ struct _MonoImage { MonoConcurrentHashTable *var_gparam_cache; MonoConcurrentHashTable *mvar_gparam_cache; -#ifndef ENABLE_NETCORE /* Maps malloc-ed char* pinvoke scope -> MonoDl* */ GHashTable *pinvoke_scopes; -#endif /* The loader used to load this image */ MonoImageLoader *loader; @@ -1320,11 +1308,7 @@ static inline MonoAssemblyLoadContext * mono_image_get_alc (MonoImage *image) { -#ifndef ENABLE_NETCORE return NULL; -#else - return image->alc; -#endif } static inline diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c index 2f19eabe3ea..6969182f0b9 100644 --- a/mono/metadata/metadata.c +++ b/mono/metadata/metadata.c @@ -8026,7 +8026,7 @@ mono_loader_set_strict_assembly_name_check (gboolean enabled) gboolean mono_loader_get_strict_assembly_name_check (void) { -#if !defined(DISABLE_DESKTOP_LOADER) || defined(ENABLE_NETCORE) +#if !defined(DISABLE_DESKTOP_LOADER) return check_assembly_names_strictly; #else return FALSE; diff --git a/mono/metadata/monitor.c b/mono/metadata/monitor.c index 86a25e9d0cd..694e29d59b0 100644 --- a/mono/metadata/monitor.c +++ b/mono/metadata/monitor.c @@ -795,9 +795,6 @@ signal_monitor (gpointer mon_untyped) mono_coop_mutex_unlock (mon->entry_mutex); } -#ifdef ENABLE_NETCORE -static gint64 thread_contentions; /* for Monitor.LockContentionCount, otherwise mono_perfcounters struct is used */ -#endif /* If allow_interruption==TRUE, the method will be interrupted if abort or suspend * is requested. In this case it returns -1. @@ -856,9 +853,6 @@ retry: #ifndef DISABLE_PERFCOUNTERS mono_atomic_inc_i32 (&mono_perfcounters->thread_contentions); #else -#ifdef ENABLE_NETCORE - mono_atomic_inc_i64 (&thread_contentions); -#endif #endif /* If ms is 0 we don't block, but just fail straight away */ @@ -1223,19 +1217,11 @@ mono_monitor_try_enter_loop_if_interrupted (MonoObject *obj, guint32 ms, return res; } -#ifdef ENABLE_NETCORE -void -ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (MonoObjectHandle obj, guint32 ms, MonoBoolean allow_interruption, MonoBoolean* lockTaken, MonoError* error) -{ - mono_monitor_try_enter_loop_if_interrupted (MONO_HANDLE_RAW (obj), ms, allow_interruption, lockTaken, error); -} -#else void ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (MonoObjectHandle obj, guint32 ms, MonoBoolean* lockTaken, MonoError* error) { mono_monitor_try_enter_loop_if_interrupted (MONO_HANDLE_RAW (obj), ms, TRUE, lockTaken, error); } -#endif /** * mono_monitor_enter_v4: @@ -1493,33 +1479,14 @@ mono_monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoBoolean allow_in return success; } -#ifdef ENABLE_NETCORE -MonoBoolean -ves_icall_System_Threading_Monitor_Monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoBoolean allow_interruption, MonoError* error) -{ - return mono_monitor_wait (obj_handle, ms, allow_interruption, error); -} -#else MonoBoolean ves_icall_System_Threading_Monitor_Monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoError* error) { return mono_monitor_wait (obj_handle, ms, TRUE, error); } -#endif void ves_icall_System_Threading_Monitor_Monitor_Enter (MonoObjectHandle obj, MonoError* error) { mono_monitor_enter_internal (MONO_HANDLE_RAW (obj)); } -#ifdef ENABLE_NETCORE -gint64 -ves_icall_System_Threading_Monitor_Monitor_LockContentionCount (void) -{ -#ifndef DISABLE_PERFCOUNTERS - return mono_perfcounters->thread_contentions; -#else - return thread_contentions; -#endif -} -#endif diff --git a/mono/metadata/monitor.h b/mono/metadata/monitor.h index 6b95a3ed69e..7ab5c6f5ff7 100644 --- a/mono/metadata/monitor.h +++ b/mono/metadata/monitor.h @@ -130,10 +130,5 @@ mono_monitor_threads_sync_members_offset (int *status_offset, int *nest_offset); #define MONO_THREADS_SYNC_MEMBER_OFFSET(o) ((o)>>8) #define MONO_THREADS_SYNC_MEMBER_SIZE(o) ((o)&0xff) -#if ENABLE_NETCORE -ICALL_EXPORT -gint64 -ves_icall_System_Threading_Monitor_Monitor_LockContentionCount (void); -#endif #endif /* _MONO_METADATA_MONITOR_H_ */ diff --git a/mono/metadata/mono-mlist.c b/mono/metadata/mono-mlist.c index f4389fdbfca..80bd991b92f 100644 --- a/mono/metadata/mono-mlist.c +++ b/mono/metadata/mono-mlist.c @@ -68,11 +68,7 @@ mono_mlist_alloc_checked (MonoObject *data, MonoError *error) error_init (error); MonoMList* res; if (!monolist_item_vtable) { -#ifdef ENABLE_NETCORE - MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "Mono", "MonoListItem"); -#else MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System", "MonoListItem"); -#endif monolist_item_vtable = mono_class_vtable_checked (mono_get_root_domain (), klass, error); mono_error_assert_ok (error); } diff --git a/mono/metadata/mono-perfcounters.c b/mono/metadata/mono-perfcounters.c index 411ffe6f2f0..dec8563da7b 100644 --- a/mono/metadata/mono-perfcounters.c +++ b/mono/metadata/mono-perfcounters.c @@ -1822,7 +1822,6 @@ mono_perfcounter_foreach (PerfCounterEnumCallback cb, gpointer data) #else -#ifndef ENABLE_NETCORE void* mono_perfcounter_get_impl (const gunichar2 *category, gint32 category_length, @@ -1903,7 +1902,6 @@ mono_perfcounter_instance_names (const gunichar2 *category, gint32 category_leng g_assert_not_reached (); } -#endif /* ENABLE_NETCORE */ void mono_perfcounter_foreach (PerfCounterEnumCallback cb, gpointer data) diff --git a/mono/metadata/mono-route.c b/mono/metadata/mono-route.c index 2e0bf023097..ba7e38ebf07 100644 --- a/mono/metadata/mono-route.c +++ b/mono/metadata/mono-route.c @@ -9,7 +9,6 @@ #include "config.h" -#ifndef ENABLE_NETCORE #if HOST_DARWIN || HOST_BSD #include <sys/types.h> @@ -168,7 +167,6 @@ ves_icall_System_Net_NetworkInformation_MacOsIPInterfaceProperties_ParseRouteInf #endif -#endif extern const char mono_route_empty_file_no_warning; const char mono_route_empty_file_no_warning = 0; diff --git a/mono/metadata/mono-security.c b/mono/metadata/mono-security.c index b360d820e27..dc743ec6bf2 100644 --- a/mono/metadata/mono-security.c +++ b/mono/metadata/mono-security.c @@ -24,7 +24,6 @@ #include "reflection-internals.h" #include "icall-decl.h" -#ifndef ENABLE_NETCORE #ifndef HOST_WIN32 #ifdef HAVE_GRP_H @@ -668,8 +667,3 @@ ves_icall_System_Security_SecureString_EncryptInternal (MonoArrayHandle data, Mo mono_invoke_protected_memory_method (data, scope, "Protect", &mono_method_securestring_encrypt, error); } -#else - -MONO_EMPTY_SOURCE_FILE (mono_security); - -#endif /* ENABLE_NETCORE */ diff --git a/mono/metadata/native-library.c b/mono/metadata/native-library.c index f1c7c291bb8..3d3b4c43e36 100644 --- a/mono/metadata/native-library.c +++ b/mono/metadata/native-library.c @@ -13,46 +13,6 @@ #include "mono/metadata/native-library.h" #include "mono/metadata/custom-attrs-internals.h" -#ifdef ENABLE_NETCORE -static int pinvoke_search_directories_count; -static char **pinvoke_search_directories; - -// sync with src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/DllImportSearchPath.cs -typedef enum -{ - DLLIMPORTSEARCHPATH_LEGACY_BEHAVIOR = 0x0, // when no other flags are present, search the application directory and then call LoadLibraryEx with LOAD_WITH_ALTERED_SEARCH_PATH - DLLIMPORTSEARCHPATH_USE_DLL_DIRECTORY_FOR_DEPENDENCIES = 0x100, - DLLIMPORTSEARCHPATH_APPLICATION_DIRECTORY = 0x200, - DLLIMPORTSEARCHPATH_USER_DIRECTORIES = 0x400, - DLLIMPORTSEARCHPATH_SYSTEM32 = 0x800, - DLLIMPORTSEARCHPATH_SAFE_DIRECTORIES = 0x1000, - DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY = 0x2, // search the assembly directory first regardless of platform, not passed on to LoadLibraryEx -} DllImportSearchPath; -#ifdef HOST_WIN32 -static const int DLLIMPORTSEARCHPATH_LOADLIBRARY_FLAG_MASK = DLLIMPORTSEARCHPATH_USE_DLL_DIRECTORY_FOR_DEPENDENCIES | DLLIMPORTSEARCHPATH_APPLICATION_DIRECTORY | - DLLIMPORTSEARCHPATH_USER_DIRECTORIES | DLLIMPORTSEARCHPATH_SYSTEM32 | DLLIMPORTSEARCHPATH_SAFE_DIRECTORIES; -#endif - -// This lock may be taken within an ALC lock, and should never be the other way around. -static MonoCoopMutex native_library_module_lock; -static GHashTable *native_library_module_map; -/* - * This blocklist is used as a set for cache invalidation purposes with netcore pinvokes. - * When pinvokes are resolved with anything other than the last-chance managed event, - * the results of that lookup are added to an ALC-level cache. However, if a library is then - * unloaded with NativeLibrary.Free(), this cache should be invalidated so that a newly called - * pinvoke will not attempt to use it, hence the blocklist. This design means that if another - * library is loaded at the same address, it will function with a perf hit, as the entry will - * repeatedly be added and removed from the cache due to its presence in the blocklist. - * This is a rare scenario and considered a worthwhile tradeoff. - */ -static GHashTable *native_library_module_blocklist; - -#ifndef NO_GLOBALIZATION_SHIM -extern const void *GlobalizationResolveDllImport (const char *name); -#endif -#endif // ENABLE_NETCORE - #ifndef DISABLE_DLLMAP static MonoDllMap *global_dll_map; #endif @@ -76,10 +36,6 @@ static char *bundled_dylibrary_directory; /* Class lazy loading functions */ GENERATE_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, "System", "AppDomainUnloadedException") GENERATE_TRY_GET_CLASS_WITH_CACHE (appdomain_unloaded_exception, "System", "AppDomainUnloadedException") -#ifdef ENABLE_NETCORE -GENERATE_GET_CLASS_WITH_CACHE (native_library, "System.Runtime.InteropServices", "NativeLibrary"); -static GENERATE_TRY_GET_CLASS_WITH_CACHE (dllimportsearchpath_attribute, "System.Runtime.InteropServices", "DefaultDllImportSearchPathsAttribute"); -#endif #ifndef DISABLE_DLLMAP /* @@ -298,34 +254,6 @@ mono_loader_register_module (const char *name, MonoDl *module) mono_global_loader_data_unlock (); } -#ifdef ENABLE_NETCORE -static MonoDl * -mono_loader_register_module_locking (const char *name, MonoDl *module) -{ - MonoDl *result = NULL; - - MONO_ENTER_GC_SAFE; - mono_global_loader_data_lock (); - MONO_EXIT_GC_SAFE; - - result = (MonoDl *)g_hash_table_lookup (global_module_map, name); - if (result) { - g_free (module->full_name); - g_free (module); - goto exit; - } - - g_hash_table_insert (global_module_map, g_strdup (name), module); - result = module; - -exit: - MONO_ENTER_GC_SAFE; - mono_global_loader_data_unlock (); - MONO_EXIT_GC_SAFE; - - return result; -} -#endif static void remove_cached_module (gpointer key, gpointer value, gpointer user_data) @@ -339,13 +267,6 @@ mono_global_loader_cache_init (void) if (!global_module_map) global_module_map = g_hash_table_new (g_str_hash, g_str_equal); -#ifdef ENABLE_NETCORE - if (!native_library_module_map) - native_library_module_map = g_hash_table_new (g_direct_hash, g_direct_equal); - if (!native_library_module_blocklist) - native_library_module_blocklist = g_hash_table_new (g_direct_hash, g_direct_equal); - mono_coop_mutex_init (&native_library_module_lock); -#endif } void @@ -453,517 +374,6 @@ mono_lookup_pinvoke_call_internal (MonoMethod *method, MonoError *error) return result; } -#ifdef ENABLE_NETCORE -void -mono_set_pinvoke_search_directories (int dir_count, char **dirs) -{ - pinvoke_search_directories_count = dir_count; - g_strfreev (pinvoke_search_directories); - pinvoke_search_directories = dirs; -} - -static void -native_library_lock (void) -{ - mono_coop_mutex_lock (&native_library_module_lock); -} - -static void -native_library_unlock (void) -{ - mono_coop_mutex_unlock (&native_library_module_lock); -} - -static void -alc_pinvoke_lock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_lock (&alc->pinvoke_lock); -} - -static void -alc_pinvoke_unlock (MonoAssemblyLoadContext *alc) -{ - mono_coop_mutex_unlock (&alc->pinvoke_lock); -} - -// LOCKING: expects you to hold native_library_module_lock -static MonoDl * -netcore_handle_lookup (gpointer handle) -{ - return (MonoDl *)g_hash_table_lookup (native_library_module_map, handle); -} - -// LOCKING: expects you to hold native_library_module_lock -static gboolean -netcore_check_blocklist (MonoDl *module) -{ - return g_hash_table_contains (native_library_module_blocklist, module); -} - -static int -convert_dllimport_flags (int flags) -{ -#ifdef HOST_WIN32 - return flags & DLLIMPORTSEARCHPATH_LOADLIBRARY_FLAG_MASK; -#else - // DllImportSearchPath is Windows-only, other than DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY - return 0; -#endif -} - -static MonoDl * -netcore_probe_for_module_variations (const char *mdirname, const char *file_name, int raw_flags) -{ - void *iter = NULL; - char *full_name; - MonoDl *module = NULL; - - // FIXME: this appears to search *.dylib twice for some reason - while ((full_name = mono_dl_build_path (mdirname, file_name, &iter)) && module == NULL) { - char *error_msg; - module = mono_dl_open_full (full_name, MONO_DL_LAZY, raw_flags, &error_msg); - if (!module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "DllImport error loading library '%s': '%s'.", full_name, error_msg); - g_free (error_msg); - } - g_free (full_name); - } - g_free (full_name); - - return module; -} - -static MonoDl * -netcore_probe_for_module (MonoImage *image, const char *file_name, int flags) -{ - MonoDl *module = NULL; - int lflags = convert_dllimport_flags (flags); - - // TODO: this algorithm doesn't quite match CoreCLR, so respecting DLLIMPORTSEARCHPATH_LEGACY_BEHAVIOR makes little sense - // If the difference becomes a problem, overhaul this algorithm to match theirs exactly - - // Try without any path additions - module = netcore_probe_for_module_variations (NULL, file_name, lflags); - - // Check the NATIVE_DLL_SEARCH_DIRECTORIES - for (int i = 0; i < pinvoke_search_directories_count && module == NULL; ++i) - module = netcore_probe_for_module_variations (pinvoke_search_directories[i], file_name, lflags); - - // Check the assembly directory if the search flag is set and the image exists - if (flags & DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY && image != NULL && module == NULL) { - char *mdirname = g_path_get_dirname (image->filename); - if (mdirname) - module = netcore_probe_for_module_variations (mdirname, file_name, lflags); - g_free (mdirname); - } - - // TODO: Pass remaining flags on to LoadLibraryEx on Windows where appropriate, see https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportsearchpath?view=netcore-3.1 - - return module; -} - -static MonoDl * -netcore_resolve_with_dll_import_resolver (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, const char *scope, guint32 flags, MonoError *error) -{ - MonoDl *result = NULL; - gpointer lib = NULL; - MonoDomain *domain = mono_alc_domain (alc); - - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - static gboolean inited; - if (!inited) { - MonoClass *native_lib_class = mono_class_get_native_library_class (); - g_assert (native_lib_class); - resolve = mono_class_get_method_from_name_checked (native_lib_class, "MonoLoadLibraryCallbackStub", -1, 0, local_error); - inited = TRUE; - } - mono_error_cleanup (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - - if (!resolve) - return NULL; - - if (mono_runtime_get_no_exec ()) - return NULL; - - HANDLE_FUNCTION_ENTER (); - - MonoStringHandle scope_handle; - scope_handle = mono_string_new_handle (domain, scope, error); - goto_if_nok (error, leave); - - MonoReflectionAssemblyHandle assembly_handle; - assembly_handle = mono_assembly_get_object_handle (domain, assembly, error); - goto_if_nok (error, leave); - - gboolean has_search_flags; - has_search_flags = flags != 0 ? TRUE : FALSE; - gpointer args [5]; - args [0] = MONO_HANDLE_RAW (scope_handle); - args [1] = MONO_HANDLE_RAW (assembly_handle); - args [2] = &has_search_flags; - args [3] = &flags; - args [4] = &lib; - mono_runtime_invoke_checked (resolve, NULL, args, error); - goto_if_nok (error, leave); - - native_library_lock (); - result = netcore_handle_lookup (lib); - native_library_unlock (); - -leave: - HANDLE_FUNCTION_RETURN_VAL (result); -} - -static MonoDl * -netcore_resolve_with_dll_import_resolver_nofail (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, const char *scope, guint32 flags) -{ - MonoDl *result = NULL; - ERROR_DECL (error); - - result = netcore_resolve_with_dll_import_resolver (alc, assembly, scope, flags, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Error while invoking ALC DllImportResolver(\"%s\") delegate: '%s'", scope, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -static MonoDl * -netcore_resolve_with_load (MonoAssemblyLoadContext *alc, const char *scope, MonoError *error) -{ - MonoDl *result = NULL; - gpointer lib = NULL; - - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve = mono_class_get_method_from_name_checked (alc_class, "MonoResolveUnmanagedDll", -1, 0, local_error); - mono_error_assert_ok (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - g_assert (resolve); - - if (mono_runtime_get_no_exec ()) - return NULL; - - HANDLE_FUNCTION_ENTER (); - - MonoStringHandle scope_handle; - scope_handle = mono_string_new_handle (mono_alc_domain (alc), scope, error); - goto_if_nok (error, leave); - - gpointer gchandle; - gchandle = GUINT_TO_POINTER (alc->gchandle); - gpointer args [3]; - args [0] = MONO_HANDLE_RAW (scope_handle); - args [1] = &gchandle; - args [2] = &lib; - mono_runtime_invoke_checked (resolve, NULL, args, error); - goto_if_nok (error, leave); - - native_library_lock (); - result = netcore_handle_lookup (lib); - native_library_unlock (); - -leave: - HANDLE_FUNCTION_RETURN_VAL (result); -} - -static MonoDl * -netcore_resolve_with_load_nofail (MonoAssemblyLoadContext *alc, const char *scope) -{ - MonoDl *result = NULL; - ERROR_DECL (error); - - result = netcore_resolve_with_load (alc, scope, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Error while invoking ALC LoadUnmanagedDll(\"%s\") method: '%s'", scope, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -static MonoDl * -netcore_resolve_with_resolving_event (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, const char *scope, MonoError *error) -{ - MonoDl *result = NULL; - gpointer lib = NULL; - MonoDomain *domain = mono_alc_domain (alc); - - MONO_STATIC_POINTER_INIT (MonoMethod, resolve) - - ERROR_DECL (local_error); - static gboolean inited; - if (!inited) { - MonoClass *alc_class = mono_class_get_assembly_load_context_class (); - g_assert (alc_class); - resolve = mono_class_get_method_from_name_checked (alc_class, "MonoResolveUnmanagedDllUsingEvent", -1, 0, local_error); - inited = TRUE; - } - mono_error_cleanup (local_error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, resolve) - if (!resolve) - return NULL; - - if (mono_runtime_get_no_exec ()) - return NULL; - - HANDLE_FUNCTION_ENTER (); - - MonoStringHandle scope_handle; - scope_handle = mono_string_new_handle (domain, scope, error); - goto_if_nok (error, leave); - - MonoReflectionAssemblyHandle assembly_handle; - assembly_handle = mono_assembly_get_object_handle (domain, assembly, error); - goto_if_nok (error, leave); - - gpointer gchandle; - gchandle = GUINT_TO_POINTER (alc->gchandle); - gpointer args [4]; - args [0] = MONO_HANDLE_RAW (scope_handle); - args [1] = MONO_HANDLE_RAW (assembly_handle); - args [2] = &gchandle; - args [3] = &lib; - mono_runtime_invoke_checked (resolve, NULL, args, error); - goto_if_nok (error, leave); - - native_library_lock (); - result = netcore_handle_lookup (lib); - native_library_unlock (); - -leave: - HANDLE_FUNCTION_RETURN_VAL (result); -} - -static MonoDl * -netcore_resolve_with_resolving_event_nofail (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, const char *scope) -{ - MonoDl *result = NULL; - ERROR_DECL (error); - - result = netcore_resolve_with_resolving_event (alc, assembly, scope, error); - if (!is_ok (error)) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Error while invoking ALC ResolvingUnmangedDll(\"%s\") event: '%s'", scope, mono_error_get_message (error)); - - mono_error_cleanup (error); - - return result; -} - -// LOCKING: expects you to hold the ALC's pinvoke lock -static MonoDl * -netcore_check_alc_cache (MonoAssemblyLoadContext *alc, const char *scope) -{ - MonoDl *result = NULL; - - result = (MonoDl *)g_hash_table_lookup (alc->pinvoke_scopes, scope); - - if (result) { - gboolean blocklisted; - - native_library_lock (); - blocklisted = netcore_check_blocklist (result); - native_library_unlock (); - - if (blocklisted) { - g_hash_table_remove (alc->pinvoke_scopes, scope); - result = NULL; - } - } - - return result; -} - -static MonoDl * -netcore_lookup_native_library (MonoAssemblyLoadContext *alc, MonoImage *image, const char *scope, guint32 flags) -{ - MonoDl *module = NULL; - MonoDl *cached; - MonoAssembly *assembly = mono_image_get_assembly (image); - char *error_msg = NULL; - - MONO_REQ_GC_UNSAFE_MODE; - - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "DllImport attempting to load: '%s'.", scope); - - // We allow a special name to dlopen from the running process namespace, which is not present in CoreCLR - if (strcmp (scope, "__Internal") == 0) { - if (!internal_module) - internal_module = mono_dl_open_self (&error_msg); - module = internal_module; - - if (!module) { - mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, "DllImport error loading library '__Internal': '%s'.", error_msg); - g_free (error_msg); - } - - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found via __Internal: '%s'.", scope); - - return module; - } - - /* - * Try these until one of them succeeds: - * - * 1. Check the cache in the active ALC. - * - * 2. Call the DllImportResolver on the active assembly. - * - * 3. Call LoadUnmanagedDll on the active ALC. - * - * 4. Check the global cache. - * - * 5. Run the unmanaged probing logic. - * - * 6. Raise the ResolvingUnmanagedDll event on the active ALC. - * - * 7. Return NULL. - */ - - alc_pinvoke_lock (alc); - module = netcore_check_alc_cache (alc, scope); - alc_pinvoke_unlock (alc); - if (module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found in the active ALC cache: '%s'.", scope); - goto leave; - } - - module = (MonoDl *)netcore_resolve_with_dll_import_resolver_nofail (alc, assembly, scope, flags); - if (module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found via DllImportResolver: '%s'.", scope); - goto add_to_alc_cache; - } - - module = (MonoDl *)netcore_resolve_with_load_nofail (alc, scope); - if (module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found via LoadUnmanagedDll: '%s'.", scope); - goto add_to_alc_cache; - } - - MONO_ENTER_GC_SAFE; - mono_global_loader_data_lock (); - MONO_EXIT_GC_SAFE; - module = (MonoDl *)g_hash_table_lookup (global_module_map, scope); - MONO_ENTER_GC_SAFE; - mono_global_loader_data_unlock (); - MONO_EXIT_GC_SAFE; - if (module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found in the global cache: '%s'.", scope); - goto add_to_alc_cache; - } - - module = netcore_probe_for_module (image, scope, flags); - if (module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found via filesystem probing: '%s'.", scope); - goto add_to_global_cache; - } - - /* As this is last chance, I've opted not to put it in a cache, but that is not necessarily the correct decision. - * It is rather convenient here, however, because it means the global cache will only be populated by libraries - * resolved via netcore_probe_for_module and not NativeLibrary, eliminating potential races/conflicts. - */ - module = netcore_resolve_with_resolving_event_nofail (alc, assembly, scope); - if (module) - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Native library found via the Resolving event: '%s'.", scope); - goto leave; - -add_to_global_cache: - module = mono_loader_register_module_locking (scope, module); - -add_to_alc_cache: - /* Nothing is closed here because the only two places this can come from are: - * 1. A managed callback that made use of NativeLibrary.Load, in which case closing is dependent on NativeLibrary.Free - * 2. The global cache, which is only populated by results of netcore_probe_for_module. When adding to the global cache, - * we free the new MonoDl if another thread beat us, so we don't have to repeat that here. - */ - alc_pinvoke_lock (alc); - cached = netcore_check_alc_cache (alc, scope); - if (cached) - module = cached; - else - g_hash_table_insert (alc->pinvoke_scopes, g_strdup (scope), module); - alc_pinvoke_unlock (alc); - -leave: - return module; -} - -static int -get_dllimportsearchpath_flags (MonoCustomAttrInfo *cinfo) -{ - ERROR_DECL (error); - MonoCustomAttrEntry *attr = NULL; - MonoClass *dllimportsearchpath = mono_class_try_get_dllimportsearchpath_attribute_class (); - int idx; - int flags; - - if (!dllimportsearchpath) - return -1; - if (!cinfo) - return -2; - - for (idx = 0; idx < cinfo->num_attrs; ++idx) { - MonoClass *ctor_class = cinfo->attrs [idx].ctor->klass; - if (ctor_class == dllimportsearchpath) { - attr = &cinfo->attrs [idx]; - break; - } - } - if (!attr) - return -3; - - gpointer *typed_args, *named_args; - CattrNamedArg *arginfo; - int num_named_args; - - mono_reflection_create_custom_attr_data_args_noalloc (m_class_get_image (attr->ctor->klass), attr->ctor, attr->data, attr->data_size, - &typed_args, &named_args, &num_named_args, &arginfo, error); - if (!is_ok (error)) { - mono_error_cleanup (error); - return -4; - } - - flags = *(gint32*)typed_args [0]; - g_free (typed_args [0]); - g_free (typed_args); - g_free (named_args); - g_free (arginfo); - - return flags; -} - -#ifndef NO_GLOBALIZATION_SHIM -#ifdef HOST_WIN32 -#define GLOBALIZATION_DLL_NAME "System.Globalization.Native" -#else -#define GLOBALIZATION_DLL_NAME "libSystem.Globalization.Native" -#endif - -static gpointer -default_resolve_dllimport (const char *dll, const char *func) -{ - if (strcmp (dll, GLOBALIZATION_DLL_NAME) == 0) { - const void *method_impl = GlobalizationResolveDllImport (func); - if (method_impl) - return (gpointer)method_impl; - } - - return NULL; -} -#endif // NO_GLOBALIZATION_SHIM - -#else // ENABLE_NETCORE - static MonoDl * cached_module_load (const char *name, int flags, char **err) { @@ -1292,17 +702,11 @@ legacy_lookup_native_library (MonoImage *image, const char *scope) return module; } -#endif // ENABLE_NETCORE gpointer lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_out) { MonoImage *image = m_class_get_image (method->klass); -#ifdef ENABLE_NETCORE - MonoAssemblyLoadContext *alc = mono_image_get_alc (image); - MonoCustomAttrInfo *cinfo; - int flags; -#endif MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method; MonoTableInfo *tables = image->tables; MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP]; @@ -1374,45 +778,7 @@ lookup_pinvoke_call_impl (MonoMethod *method, MonoLookupPInvokeStatus *status_ou } #endif -#ifdef ENABLE_NETCORE -#ifndef NO_GLOBALIZATION_SHIM - addr = default_resolve_dllimport (new_scope, new_import); - if (addr) - goto exit; -#endif - - if (pinvoke_override) { - addr = pinvoke_override (new_scope, new_import); - if (addr) - goto exit; - } - -#ifndef HOST_WIN32 -retry_with_libcoreclr: -#endif - { - ERROR_DECL (local_error); - cinfo = mono_custom_attrs_from_method_checked (method, local_error); - mono_error_cleanup (local_error); - } - flags = get_dllimportsearchpath_flags (cinfo); - if (cinfo && !cinfo->cached) - mono_custom_attrs_free (cinfo); - - if (flags < 0) { - ERROR_DECL (local_error); - cinfo = mono_custom_attrs_from_assembly_checked (m_class_get_image (method->klass)->assembly, TRUE, local_error); - mono_error_cleanup (local_error); - flags = get_dllimportsearchpath_flags (cinfo); - if (cinfo && !cinfo->cached) - mono_custom_attrs_free (cinfo); - } - if (flags < 0) - flags = 0; - module = netcore_lookup_native_library (alc, image, new_scope, flags); -#else module = legacy_lookup_native_library (image, new_scope); -#endif // ENABLE_NETCORE if (!module) { mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT, @@ -1430,13 +796,6 @@ retry_with_libcoreclr: addr = pinvoke_probe_for_symbol (module, piinfo, new_import, &error_msg); if (!addr) { -#if defined(ENABLE_NETCORE) && !defined(HOST_WIN32) - if (strcmp (new_scope, "__Internal") == 0) { - g_free ((char *)new_scope); - new_scope = g_strdup (MONO_LOADER_LIBRARY_NAME); - goto retry_with_libcoreclr; - } -#endif status_out->err_code = LOOKUP_PINVOKE_ERR_NO_SYM; status_out->err_arg = g_strdup (new_import); goto exit; @@ -1461,7 +820,6 @@ pinvoke_probe_for_symbol (MonoDl *module, MonoMethodPInvoke *piinfo, const char mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "Searching for '%s'.", import); -#if !defined(ENABLE_NETCORE) || defined(HOST_WIN32) // For netcore, name mangling is Windows-exclusive if (piinfo->piflags & PINVOKE_ATTRIBUTE_NO_MANGLE) error_msg = mono_dl_symbol (module, import, &addr); else { @@ -1546,166 +904,11 @@ pinvoke_probe_for_symbol (MonoDl *module, MonoMethodPInvoke *piinfo, const char } } } -#else - error_msg = mono_dl_symbol (module, import, &addr); -#endif *error_msg_out = error_msg; return addr; } -#ifdef ENABLE_NETCORE -void -ves_icall_System_Runtime_InteropServices_NativeLibrary_FreeLib (gpointer lib, MonoError *error) -{ - MonoDl *module; - guint32 ref_count; - - g_assert (lib); - - // Don't free __Internal - if (internal_module && lib == internal_module->handle) - return; - - native_library_lock (); - - module = netcore_handle_lookup (lib); - if (!module) - goto leave; - - ref_count = mono_refcount_dec (module); - if (ref_count > 0) - goto leave; - - g_hash_table_remove (native_library_module_map, module->handle); - g_hash_table_add (native_library_module_blocklist, module); - mono_dl_close (module); - -leave: - native_library_unlock (); -} - -gpointer -ves_icall_System_Runtime_InteropServices_NativeLibrary_GetSymbol (gpointer lib, MonoStringHandle symbol_name_handle, MonoBoolean throw_on_error, MonoError *error) -{ - MonoDl *module; - gpointer symbol = NULL; - char *symbol_name; - - g_assert (lib); - - ERROR_LOCAL_BEGIN (local_error, error, throw_on_error) - - symbol_name = mono_string_handle_to_utf8 (symbol_name_handle, error); - goto_if_nok (error, leave_nolock); - - native_library_lock (); - - module = netcore_handle_lookup (lib); - if (!module) - mono_error_set_generic_error (error, "System", "DllNotFoundException", "%p: %s", lib, symbol_name); - goto_if_nok (error, leave); - - mono_dl_symbol (module, symbol_name, &symbol); - if (!symbol) - mono_error_set_generic_error (error, "System", "EntryPointNotFoundException", "%s: %s", module->full_name, symbol_name); - goto_if_nok (error, leave); - -leave: - native_library_unlock (); - -leave_nolock: - ERROR_LOCAL_END (local_error); - g_free (symbol_name); - - return symbol; -} - -// LOCKING: expects you to hold native_library_module_lock -static MonoDl * -check_native_library_cache (MonoDl *module) -{ - gpointer handle = module->handle; - - MonoDl *cached_module = netcore_handle_lookup (handle); - if (cached_module) { - g_free (module->full_name); - g_free (module); - mono_refcount_inc (cached_module); - return cached_module; - } - g_hash_table_insert (native_library_module_map, handle, (gpointer)module); - - return module; -} - -gpointer -ves_icall_System_Runtime_InteropServices_NativeLibrary_LoadByName (MonoStringHandle lib_name_handle, MonoReflectionAssemblyHandle assembly_handle, MonoBoolean has_search_flag, guint32 search_flag, MonoBoolean throw_on_error, MonoError *error) -{ - MonoDl *module; - gpointer handle = NULL; - MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_handle, assembly); - MonoImage *image = mono_assembly_get_image_internal (assembly); - char *lib_name; - - ERROR_LOCAL_BEGIN (local_error, error, throw_on_error) - - lib_name = mono_string_handle_to_utf8 (lib_name_handle, error); - goto_if_nok (error, leave); - - // FIXME: implement search flag defaults properly - module = netcore_probe_for_module (image, lib_name, has_search_flag ? search_flag : DLLIMPORTSEARCHPATH_ASSEMBLY_DIRECTORY); - if (!module) - mono_error_set_generic_error (error, "System", "DllNotFoundException", "%s", lib_name); - goto_if_nok (error, leave); - - native_library_lock (); - module = check_native_library_cache (module); - native_library_unlock (); - - handle = module->handle; - -leave: - ERROR_LOCAL_END (local_error); - g_free (lib_name); - - return handle; -} - -gpointer -ves_icall_System_Runtime_InteropServices_NativeLibrary_LoadFromPath (MonoStringHandle lib_path_handle, MonoBoolean throw_on_error, MonoError *error) -{ - MonoDl *module; - gpointer handle = NULL; - char *error_msg = NULL; - char *lib_path; - - ERROR_LOCAL_BEGIN (local_error, error, throw_on_error) - - lib_path = mono_string_handle_to_utf8 (lib_path_handle, error); - goto_if_nok (error, leave); - - module = mono_dl_open (lib_path, MONO_DL_LAZY, &error_msg); - if (!module) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_DLLIMPORT, "DllImport error loading library '%s': '%s'.", lib_path, error_msg); - mono_error_set_generic_error (error, "System", "DllNotFoundException", "'%s': '%s'", lib_path, error_msg); - g_free (error_msg); - } - goto_if_nok (error, leave); - - native_library_lock (); - module = check_native_library_cache (module); - native_library_unlock (); - - handle = module->handle; - -leave: - ERROR_LOCAL_END (local_error); - g_free (lib_path); - - return handle; -} -#endif #ifdef HAVE_ATEXIT static void diff --git a/mono/metadata/object-internals.h b/mono/metadata/object-internals.h index af9514d2ccb..b2b95479e7b 100644 --- a/mono/metadata/object-internals.h +++ b/mono/metadata/object-internals.h @@ -278,9 +278,7 @@ mono_handle_array_get_bounds_dim (MonoArrayHandle arr, gint32 dim, MonoArrayBoun typedef struct { MonoObject obj; -#ifndef ENABLE_NETCORE MonoObject *identity; -#endif } MonoMarshalByRefObject; TYPED_HANDLE_DECL (MonoMarshalByRefObject); @@ -288,18 +286,14 @@ TYPED_HANDLE_DECL (MonoMarshalByRefObject); /* This is a copy of System.AppDomain */ struct _MonoAppDomain { MonoMarshalByRefObject mbr; -#ifndef ENABLE_NETCORE MonoDomain *data; -#endif }; /* Safely access System.AppDomain from native code */ TYPED_HANDLE_DECL (MonoAppDomain); -#ifndef ENABLE_NETCORE /* Safely access System.AppDomainSetup from native code. (struct is in domain-internals.h) */ TYPED_HANDLE_DECL (MonoAppDomainSetup); -#endif typedef struct _MonoStringBuilder MonoStringBuilder; TYPED_HANDLE_DECL (MonoStringBuilder); @@ -373,12 +367,10 @@ typedef struct { TYPED_HANDLE_DECL (MonoSystemException); -#ifndef ENABLE_NETCORE typedef struct { MonoSystemException base; MonoString *param_name; } MonoArgumentException; -#endif typedef struct { MonoObject object; @@ -594,9 +586,7 @@ struct _MonoInternalThread { gsize debugger_thread; // FIXME switch to bool as soon as CI testing with corlib version bump works gpointer *static_data; struct _MonoThreadInfo *thread_info; -#ifndef ENABLE_NETCORE MonoAppContext *current_appcontext; -#endif MonoThread *root_domain_thread; MonoObject *_serialized_principal; int _serialized_principal_version; @@ -624,13 +614,7 @@ struct _MonoInternalThread { gint32 self_suspended; // TRUE | FALSE gsize thread_state; -#ifdef ENABLE_NETCORE - struct _MonoInternalThread *internal_thread; - MonoObject *start_obj; - MonoException *pending_exception; -#else void* unused [3]; // same size as netcore -#endif /* This is used only to check that we are in sync between the representation * of MonoInternalThread in native and InternalThread in managed * @@ -638,21 +622,18 @@ struct _MonoInternalThread { gpointer last; }; -#ifndef ENABLE_NETCORE struct _MonoThread { MonoObject obj; MonoInternalThread *internal_thread; MonoObject *start_obj; MonoException *pending_exception; }; -#endif typedef struct { guint32 state; MonoObject *additional; } MonoStreamingContext; -#if !ENABLE_NETCORE typedef struct { MonoObject obj; MonoBoolean readOnly; @@ -800,7 +781,6 @@ typedef struct { TYPED_HANDLE_DECL (MonoRegionInfo); -#endif /* !ENABLE_NETCORE */ typedef struct { MonoObject object; @@ -1054,9 +1034,7 @@ TYPED_HANDLE_DECL (MonoReflectionProperty); /*This is System.EventInfo*/ struct _MonoReflectionEvent { MonoObject object; -#ifndef ENABLE_NETCORE MonoObject *cached_add_event; -#endif }; /* Safely access System.Reflection.EventInfo from native code */ @@ -1523,21 +1501,6 @@ typedef struct { TYPED_HANDLE_DECL (MonoReflectionCustomAttr); -#if ENABLE_NETCORE -typedef struct { - MonoObject object; - guint32 utype; - gint32 safe_array_subtype; - MonoReflectionType *marshal_safe_array_user_defined_subtype; - gint32 IidParameterIndex; - guint32 array_subtype; - gint16 size_param_index; - gint32 size_const; - MonoString *marshal_type; - MonoReflectionType *marshal_type_ref; - MonoString *marshal_cookie; -} MonoReflectionMarshalAsAttribute; -#else typedef struct { MonoObject object; MonoString *marshal_cookie; @@ -1551,7 +1514,6 @@ typedef struct { gint32 IidParameterIndex; gint16 size_param_index; } MonoReflectionMarshalAsAttribute; -#endif /* Safely access System.Runtime.InteropServices.MarshalAsAttribute */ TYPED_HANDLE_DECL (MonoReflectionMarshalAsAttribute); @@ -1658,21 +1620,6 @@ typedef struct { MonoProperty *prop; } CattrNamedArg; -#ifdef ENABLE_NETCORE -// Keep in sync with System.Runtime.Loader.AssemblyLoadContext.InternalState -typedef enum { - ALIVE = 0, - UNLOADING = 1 -} MonoManagedAssemblyLoadContextInternalState; - -// Keep in sync with System.Runtime.Loader.AssemblyLoadContext -typedef struct { - MonoObject object; - MonoAssemblyLoadContext *native_assembly_load_context; -} MonoManagedAssemblyLoadContext; - -TYPED_HANDLE_DECL (MonoManagedAssemblyLoadContext); -#endif /* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr. However * for uniformity, icall wrapping will make handles anyway. So this is the method for getting the payload. @@ -1927,13 +1874,6 @@ mono_runtime_unhandled_exception_policy_set (MonoRuntimeUnhandledExceptionPolicy void mono_unhandled_exception_checked (MonoObjectHandle exc, MonoError *error); -#ifdef ENABLE_NETCORE -void -mono_first_chance_exception_checked (MonoObjectHandle exc, MonoError *error); - -void -mono_first_chance_exception_internal (MonoObject *exc_raw); -#endif MonoVTable * mono_class_try_get_vtable (MonoDomain *domain, MonoClass *klass); diff --git a/mono/metadata/object-offsets.h b/mono/metadata/object-offsets.h index ab8fb9e86b2..62358a23450 100644 --- a/mono/metadata/object-offsets.h +++ b/mono/metadata/object-offsets.h @@ -167,13 +167,11 @@ DECL_OFFSET(MonoJitTlsData, stack_restore_ctx) DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, locals_size) DECL_OFFSET(MonoGSharedVtMethodRuntimeInfo, entries) //XXX more to fix here -#if !defined(ENABLE_NETCORE) DECL_OFFSET(MonoContinuation, stack_used_size) DECL_OFFSET(MonoContinuation, saved_stack) DECL_OFFSET(MonoContinuation, return_sp) DECL_OFFSET(MonoContinuation, lmf) DECL_OFFSET(MonoContinuation, return_ip) -#endif DECL_OFFSET(MonoDelegateTrampInfo, method) DECL_OFFSET(MonoDelegateTrampInfo, invoke_impl) diff --git a/mono/metadata/object.c b/mono/metadata/object.c index d14e5434946..4052ce7fa03 100644 --- a/mono/metadata/object.c +++ b/mono/metadata/object.c @@ -1255,12 +1255,10 @@ field_is_special_static (MonoClass *fklass, MonoClassField *field) mono_custom_attrs_free (ainfo); return SPECIAL_STATIC_THREAD; } -#ifndef ENABLE_NETCORE else if (strcmp (klass_name, "ContextStaticAttribute") == 0) { mono_custom_attrs_free (ainfo); return SPECIAL_STATIC_CONTEXT; } -#endif } } mono_custom_attrs_free (ainfo); @@ -5005,102 +5003,6 @@ mono_unhandled_exception (MonoObject *exc) MONO_EXTERNAL_ONLY_VOID (mono_unhandled_exception_internal (exc)); } -#ifdef ENABLE_NETCORE -static MonoObjectHandle -create_first_chance_exception_eventargs (MonoObjectHandle exc, MonoError *error) -{ - MONO_REQ_GC_UNSAFE_MODE; - - HANDLE_FUNCTION_ENTER (); - - MonoObjectHandle obj; - MonoClass *klass = mono_class_get_first_chance_exception_event_args_class (); - - MONO_STATIC_POINTER_INIT (MonoMethod, ctor) - - ctor = mono_class_get_method_from_name_checked (klass, ".ctor", 1, METHOD_ATTRIBUTE_PUBLIC, error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, ctor) - - goto_if_nok (error, return_null); - g_assert (ctor); - - gpointer args [1]; - args [0] = MONO_HANDLE_RAW (exc); - - obj = mono_object_new_handle (mono_domain_get (), klass, error); - goto_if_nok (error, return_null); - - mono_runtime_invoke_handle_void (ctor, obj, args, error); - goto_if_nok (error, return_null); - - goto leave; - -return_null: - obj = MONO_HANDLE_NEW (MonoObject, NULL); - -leave: - HANDLE_FUNCTION_RETURN_REF (MonoObject, obj); -} - -void -mono_first_chance_exception_internal (MonoObject *exc_raw) -{ - ERROR_DECL (error); - - HANDLE_FUNCTION_ENTER (); - - MONO_HANDLE_DCL (MonoObject, exc); - - mono_first_chance_exception_checked (exc, error); - - if (!is_ok (error)) - g_warning ("Invoking the FirstChanceException event failed: %s", mono_error_get_message (error)); - - HANDLE_FUNCTION_RETURN (); -} - -void -mono_first_chance_exception_checked (MonoObjectHandle exc, MonoError *error) -{ - MonoClass *klass = mono_handle_class (exc); - MonoDomain *domain = mono_domain_get (); - MonoObject *delegate = NULL; - MonoObjectHandle delegate_handle; - - if (klass == mono_defaults.threadabortexception_class) - return; - - MONO_STATIC_POINTER_INIT (MonoClassField, field) - - static gboolean inited; - if (!inited) { - field = mono_class_get_field_from_name_full (mono_defaults.appcontext_class, "FirstChanceException", NULL); - inited = TRUE; - } - - MONO_STATIC_POINTER_INIT_END (MonoClassField, field) - - if (!field) - return; - - MonoVTable *vt = mono_class_vtable_checked (domain, mono_defaults.appcontext_class, error); - return_if_nok (error); - - // TODO: use handles directly - mono_field_static_get_value_checked (vt, field, &delegate, MONO_HANDLE_NEW (MonoString, NULL), error); - return_if_nok (error); - delegate_handle = MONO_HANDLE_NEW (MonoObject, delegate); - - if (MONO_HANDLE_BOOL (delegate_handle)) { - gpointer args [2]; - args [0] = domain->domain; - args [1] = MONO_HANDLE_RAW (create_first_chance_exception_eventargs (exc, error)); - mono_error_assert_ok (error); - mono_runtime_delegate_try_invoke_handle (delegate_handle, args, error); - } -} -#endif /** * mono_unhandled_exception_checked: @@ -5127,29 +5029,18 @@ mono_unhandled_exception_checked (MonoObjectHandle exc, MonoError *error) * https://msdn.microsoft.com/en-us/library/system.appdomainunloadedexception(v=vs.110).aspx#Anchor_6 */ gboolean no_event = (klass == mono_defaults.threadabortexception_class); -#ifndef ENABLE_NETCORE no_event = no_event || (klass == mono_class_get_appdomain_unloaded_exception_class () && mono_thread_info_current ()->runtime_thread); -#endif if (no_event) return; MONO_STATIC_POINTER_INIT (MonoClassField, field) -#ifndef ENABLE_NETCORE field = mono_class_get_field_from_name_full (mono_defaults.appdomain_class, "UnhandledException", NULL); -#else - static gboolean inited; - if (!inited) { - field = mono_class_get_field_from_name_full (mono_defaults.appcontext_class, "UnhandledException", NULL); - inited = TRUE; - } -#endif MONO_STATIC_POINTER_INIT_END (MonoClassField, field) -#ifndef ENABLE_NETCORE g_assert (field); MonoDomain *root_domain; @@ -5175,32 +5066,6 @@ mono_unhandled_exception_checked (MonoObjectHandle exc, MonoError *error) call_unhandled_exception_delegate (current_domain, current_appdomain_delegate, exc); mono_threads_end_abort_protected_block (); } -#else - if (!field) - goto leave; - - MonoObject *delegate = NULL; - MonoObjectHandle delegate_handle; - MonoVTable *vt = mono_class_vtable_checked (current_domain, mono_defaults.appcontext_class, error); - goto_if_nok (error, leave); - - // TODO: use handles directly - mono_field_static_get_value_checked (vt, field, &delegate, MONO_HANDLE_NEW (MonoString, NULL), error); - goto_if_nok (error, leave); - delegate_handle = MONO_HANDLE_NEW (MonoObject, delegate); - - if (MONO_HANDLE_IS_NULL (delegate_handle)) { - mono_print_unhandled_exception_internal (MONO_HANDLE_RAW (exc)); // TODO: use handles - } else { - gpointer args [2]; - args [0] = current_domain->domain; - args [1] = MONO_HANDLE_RAW (create_unhandled_exception_eventargs (exc, error)); - mono_error_assert_ok (error); - mono_runtime_delegate_try_invoke_handle (delegate_handle, args, error); - } - -leave: -#endif /* set exitcode only if we will abort the process */ if ((main_thread && mono_thread_internal_current () == main_thread->internal_thread) @@ -6703,25 +6568,6 @@ mono_array_new_specific_checked (MonoVTable *vtable, uintptr_t n, MonoError *err return mono_array_new_specific_internal (vtable, n, FALSE, error); } -#ifdef ENABLE_NETCORE -MonoArrayHandle -ves_icall_System_GC_AllocPinnedArray (MonoReflectionTypeHandle array_type, gint32 length, MonoError *error) -{ - MONO_REQ_GC_UNSAFE_MODE; - - MonoClass *klass = mono_class_from_mono_type_internal (MONO_HANDLE_GETVAL (array_type, type)); - MonoVTable *vtable = mono_class_vtable_checked (mono_domain_get (), klass, error); - goto_if_nok (error, fail); - - MonoArray *arr; - arr = mono_array_new_specific_internal (vtable, length, TRUE, error); - goto_if_nok (error, fail); - - return MONO_HANDLE_NEW (MonoArray, arr); -fail: - return MONO_HANDLE_NEW (MonoArray, NULL); -} -#endif MonoArrayHandle @@ -8311,7 +8157,6 @@ mono_raise_exception_with_context (MonoException *ex, MonoContext *ctx) eh_callbacks.mono_raise_exception_with_ctx (ex, ctx); } -#ifndef ENABLE_NETCORE /** * mono_wait_handle_new: @@ -8362,7 +8207,6 @@ mono_wait_handle_get_handle (MonoWaitHandle *handle) return sh->handle; } -#endif /* ENABLE_NETCORE */ /* * Returns the MonoMethod to call to Capture the ExecutionContext. @@ -8417,7 +8261,6 @@ mono_runtime_capture_context (MonoDomain *domain, MonoError *error) #endif } -#ifndef ENABLE_NETCORE /** * mono_async_result_new: @@ -8537,7 +8380,6 @@ ves_icall_System_Runtime_Remoting_Messaging_AsyncResult_Invoke (MonoAsyncResultH } return res; } -#endif /* ENABLE_NETCORE */ gboolean mono_message_init (MonoDomain *domain, diff --git a/mono/metadata/object.h b/mono/metadata/object.h index f421c6c1a33..ca835aa7899 100644 --- a/mono/metadata/object.h +++ b/mono/metadata/object.h @@ -22,11 +22,7 @@ typedef struct _MonoReflectionEvent MONO_RT_MANAGED_ATTR MonoReflectionEvent; typedef struct _MonoReflectionType MONO_RT_MANAGED_ATTR MonoReflectionType; typedef struct _MonoDelegate MONO_RT_MANAGED_ATTR MonoDelegate; typedef struct _MonoThreadsSync MonoThreadsSync; -#ifdef ENABLE_NETCORE -typedef struct _MonoInternalThread MONO_RT_MANAGED_ATTR MonoThread; -#else typedef struct _MonoThread MONO_RT_MANAGED_ATTR MonoThread; -#endif typedef struct _MonoDynamicAssembly MonoDynamicAssembly; typedef struct _MonoDynamicImage MonoDynamicImage; typedef struct _MonoReflectionMethodBody MONO_RT_MANAGED_ATTR MonoReflectionMethodBody; diff --git a/mono/metadata/rand.c b/mono/metadata/rand.c index 8ce627ea4d9..faf4abfb82b 100644 --- a/mono/metadata/rand.c +++ b/mono/metadata/rand.c @@ -21,7 +21,6 @@ #include "utils/mono-rand.h" #include "icall-decl.h" -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngOpen (MonoError *error) @@ -49,8 +48,3 @@ ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose (gpoint mono_rand_close (handle); } -#else - -MONO_EMPTY_SOURCE_FILE (rand); - -#endif /* ENABLE_NETCORE */ diff --git a/mono/metadata/reflection-internals.h b/mono/metadata/reflection-internals.h index 797d1ca383e..3563866139e 100644 --- a/mono/metadata/reflection-internals.h +++ b/mono/metadata/reflection-internals.h @@ -22,10 +22,8 @@ TYPED_HANDLE_DECL (MonoReflectionTypeBuilder) MonoReflectionAssemblyHandle mono_domain_try_type_resolve_name (MonoDomain *domain, MonoAssembly *assembly, MonoStringHandle name, MonoError *error); -#ifndef ENABLE_NETCORE MonoReflectionAssemblyHandle mono_domain_try_type_resolve_typebuilder (MonoDomain *domain, MonoReflectionTypeBuilderHandle typebuilder, MonoError *error); -#endif MonoReflectionTypeBuilderHandle mono_class_get_ref_info (MonoClass *klass); diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 55a21a1094b..cd7a529eabc 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -66,15 +66,9 @@ static GENERATE_GET_CLASS_WITH_CACHE (mono_event, "System.Reflection", "RuntimeE static GENERATE_GET_CLASS_WITH_CACHE (mono_property, "System.Reflection", "RuntimePropertyInfo"); static GENERATE_GET_CLASS_WITH_CACHE (mono_parameter_info, "System.Reflection", "RuntimeParameterInfo"); static GENERATE_GET_CLASS_WITH_CACHE (missing, "System.Reflection", "Missing"); -#ifdef ENABLE_NETCORE -static GENERATE_GET_CLASS_WITH_CACHE (method_body, "System.Reflection", "RuntimeMethodBody"); -static GENERATE_GET_CLASS_WITH_CACHE (local_variable_info, "System.Reflection", "RuntimeLocalVariableInfo"); -static GENERATE_GET_CLASS_WITH_CACHE (exception_handling_clause, "System.Reflection", "RuntimeExceptionHandlingClause"); -#else static GENERATE_GET_CLASS_WITH_CACHE (method_body, "System.Reflection", "MethodBody"); static GENERATE_GET_CLASS_WITH_CACHE (local_variable_info, "System.Reflection", "LocalVariableInfo"); static GENERATE_GET_CLASS_WITH_CACHE (exception_handling_clause, "System.Reflection", "ExceptionHandlingClause"); -#endif static GENERATE_GET_CLASS_WITH_CACHE (type_builder, "System.Reflection.Emit", "TypeBuilder"); static GENERATE_GET_CLASS_WITH_CACHE (dbnull, "System", "DBNull"); @@ -465,13 +459,8 @@ mono_type_get_object_checked (MonoDomain *domain, MonoType *type, MonoError *err g_assert (!type->has_cmods); /* void is very common */ -#ifdef ENABLE_NETCORE - if (!type->byref && type->type == MONO_TYPE_VOID && domain->typeof_void) - return (MonoReflectionType*)domain->typeof_void; -#else if (type->type == MONO_TYPE_VOID && domain->typeof_void) return (MonoReflectionType*)domain->typeof_void; -#endif /* * If the vtable of the given class was already created, we can use @@ -1930,11 +1919,7 @@ mono_reflection_parse_type_checked (char *name, MonoTypeNameParse *info, MonoErr if (ok) { mono_identifier_unescape_info (info); } else { -#if ENABLE_NETCORE - mono_error_set_argument_format (error, "typeName@0", "failed parse: %s", name); -#else mono_error_set_argument_format (error, "typeName", "failed parse: %s", name); -#endif } return (ok != 0); } @@ -2655,11 +2640,7 @@ reflection_bind_generic_method_parameters (MonoMethod *method, MonoArrayHandle t mono_error_assert_ok (error); if (!mono_verifier_is_method_valid_generic_instantiation (inflated)) { -#if ENABLE_NETCORE - mono_error_set_argument (error, NULL, "Invalid generic arguments"); -#else mono_error_set_argument (error, "typeArguments", "Invalid generic arguments"); -#endif return NULL; } @@ -3134,11 +3115,7 @@ mono_reflection_call_is_assignable_to (MonoClass *klass, MonoClass *oklass, Mono error_init (error); if (method == NULL) { -#ifdef ENABLE_NETCORE - method = mono_class_get_method_from_name_checked (mono_class_get_type_builder_class (), "IsAssignableToInternal", 1, 0, error); -#else method = mono_class_get_method_from_name_checked (mono_class_get_type_builder_class (), "IsAssignableTo", 1, 0, error); -#endif mono_error_assert_ok (error); g_assert (method); } diff --git a/mono/metadata/runtime.c b/mono/metadata/runtime.c index ecd0eb30d2f..8fc0a388212 100644 --- a/mono/metadata/runtime.c +++ b/mono/metadata/runtime.c @@ -57,18 +57,6 @@ fire_process_exit_event (MonoDomain *domain, gpointer user_data) ERROR_DECL (error); MonoObject *exc; -#if ENABLE_NETCORE - MONO_STATIC_POINTER_INIT (MonoMethod, procexit_method) - - procexit_method = mono_class_get_method_from_name_checked (mono_defaults.appcontext_class, "OnProcessExit", 0, 0, error); - mono_error_assert_ok (error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, procexit_method) - - g_assert (procexit_method); - - mono_runtime_try_invoke (procexit_method, NULL, NULL, &exc, error); -#else MonoClassField *field; gpointer pa [2]; MonoObject *delegate; @@ -84,7 +72,6 @@ fire_process_exit_event (MonoDomain *domain, gpointer user_data) pa [1] = NULL; mono_runtime_delegate_try_invoke (delegate, pa, &exc, error); mono_error_cleanup (error); -#endif } static void diff --git a/mono/metadata/sre.c b/mono/metadata/sre.c index ad482f98330..c3662370973 100644 --- a/mono/metadata/sre.c +++ b/mono/metadata/sre.c @@ -1405,12 +1405,6 @@ mono_reflection_dynimage_basic_init (MonoReflectionAssemblyBuilder *assemblyb, M mono_domain_assemblies_lock (domain); domain->domain_assemblies = g_slist_append (domain->domain_assemblies, assembly); -#ifdef ENABLE_NETCORE - // TODO: potentially relax the locking here? - mono_alc_assemblies_lock (alc); - alc->loaded_assemblies = g_slist_append (alc->loaded_assemblies, assembly); - mono_alc_assemblies_unlock (alc); -#endif mono_domain_assemblies_unlock (domain); register_assembly (mono_object_domain (assemblyb), &assemblyb->assembly, &assembly->assembly); @@ -4332,7 +4326,6 @@ ensure_complete_type (MonoClass *klass, MonoError *error) error_init (error); if (image_is_dynamic (klass->image) && !klass->wastypebuilder && mono_class_has_ref_info (klass)) { -#ifndef ENABLE_NETCORE MonoReflectionTypeBuilderHandle tb = mono_class_get_ref_info (klass); mono_domain_try_type_resolve_typebuilder (mono_domain_get (), tb, error); @@ -4340,10 +4333,6 @@ ensure_complete_type (MonoClass *klass, MonoError *error) // Asserting here could break a lot of code //g_assert (klass->wastypebuilder); -#else - // TODO: make this work on netcore when working on SRE.TypeBuilder - g_assert_not_reached (); -#endif } if (mono_class_is_ginst (klass)) { @@ -4441,15 +4430,10 @@ mono_reflection_resolve_object (MonoImage *image, MonoObject *obj, MonoClass **h /* Already created */ result = klass; } else { -#ifndef ENABLE_NETCORE mono_domain_try_type_resolve_typebuilder (mono_domain_get (), tb, error); goto_if_nok (error, return_null); result = type->data.klass; g_assert (result); -#else - // TODO: make this work on netcore when working on SRE.TypeBuilder - g_assert_not_reached(); -#endif } *handle_class = mono_defaults.typehandle_class; @@ -4685,7 +4669,6 @@ ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilderHandle mb, return mono_image_create_method_token (MONO_HANDLE_GETVAL (mb, dynamic_image), MONO_HANDLE_CAST (MonoObject, method), opt_param_types, error); } -#ifndef ENABLE_NETCORE void ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilderHandle mb, HANDLE file, MonoError* error) { @@ -4697,7 +4680,6 @@ ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilderHandle mb, Mo { mono_image_build_metadata (MONO_HANDLE_RAW (mb), error); } -#endif void ves_icall_ModuleBuilder_RegisterToken (MonoReflectionModuleBuilderHandle mb, MonoObjectHandle obj, guint32 token, MonoError *error) diff --git a/mono/metadata/support.c b/mono/metadata/support.c index 104ef642a97..e0e86aad6c1 100644 --- a/mono/metadata/support.c +++ b/mono/metadata/support.c @@ -1,9 +1,9 @@ #include "utils/mono-compiler.h" -#if defined(ENABLE_MONOTOUCH) && !defined(ENABLE_NETCORE) +#if defined(ENABLE_MONOTOUCH) #include "../../support/zlib-helper.c" -#elif defined(ENABLE_MONODROID) && !defined(ENABLE_NETCORE) +#elif defined(ENABLE_MONODROID) #include "../../support/nl.c" #include "../../support/zlib-helper.c" #else diff --git a/mono/metadata/sysmath.c b/mono/metadata/sysmath.c index b8457115d36..859da539564 100644 --- a/mono/metadata/sysmath.c +++ b/mono/metadata/sysmath.c @@ -188,30 +188,6 @@ ves_icall_System_Math_Ceiling (gdouble v) return ceil (v); } -#if ENABLE_NETCORE -gint32 -ves_icall_System_Math_ILogB (gdouble x) -{ - if (FP_ILOGB0 != INT_MIN && x == 0.0) - return INT_MIN; - if (FP_ILOGBNAN != INT_MAX && isnan(x)) - return INT_MAX; - - return ilogb(x); -} - -gdouble -ves_icall_System_Math_Log2 (gdouble x) -{ - return log2 (x); -} - -gdouble -ves_icall_System_Math_FusedMultiplyAdd (gdouble x, gdouble y, gdouble z) -{ - return fma (x, y, z); -} -#endif float ves_icall_System_MathF_Acos (float x) @@ -351,27 +327,3 @@ ves_icall_System_MathF_ModF (float x, float *d) return modff (x, d); } -#if ENABLE_NETCORE -gint32 -ves_icall_System_MathF_ILogB (float x) -{ - if (FP_ILOGB0 != INT_MIN && x == 0.0) - return INT_MIN; - if (FP_ILOGBNAN != INT_MAX && isnan(x)) - return INT_MAX; - - return ilogbf(x); -} - -float -ves_icall_System_MathF_Log2 (float x) -{ - return log2f (x); -} - -float -ves_icall_System_MathF_FusedMultiplyAdd (float x, float y, float z) -{ - return fmaf (x, y, z); -} -#endif diff --git a/mono/metadata/threadpool-io.c b/mono/metadata/threadpool-io.c index 45ac0d84b24..dfb0ecc68fa 100644 --- a/mono/metadata/threadpool-io.c +++ b/mono/metadata/threadpool-io.c @@ -12,7 +12,6 @@ #include <config.h> #include <mono/utils/mono-compiler.h> -#ifndef ENABLE_NETCORE #include <glib.h> #include <mono/metadata/threadpool-io.h> @@ -616,7 +615,6 @@ mono_threadpool_io_cleanup (void) mono_lazy_cleanup (&io_status, cleanup); } -#ifndef ENABLE_NETCORE void ves_icall_System_IOSelector_Add (gpointer handle, MonoIOSelectorJobHandle job_handle, MonoError* error) { @@ -661,7 +659,6 @@ ves_icall_System_IOSelector_Add (gpointer handle, MonoIOSelectorJobHandle job_ha mono_coop_mutex_unlock (&threadpool_io->updates_lock); } -#endif void ves_icall_System_IOSelector_Remove (gpointer handle) @@ -757,6 +754,5 @@ mono_threadpool_io_remove_domain_jobs (MonoDomain *domain) #endif -#endif /* !ENABLE_NETCORE */ MONO_EMPTY_SOURCE_FILE (threadpool_io); diff --git a/mono/metadata/threadpool-io.h b/mono/metadata/threadpool-io.h index 7a51863c69f..5e97ef266e6 100644 --- a/mono/metadata/threadpool-io.h +++ b/mono/metadata/threadpool-io.h @@ -8,7 +8,6 @@ #include <config.h> #include <glib.h> -#ifndef ENABLE_NETCORE #include <mono/metadata/object-internals.h> #include <mono/metadata/icalls.h> @@ -28,6 +27,5 @@ mono_threadpool_io_remove_domain_jobs (MonoDomain *domain); void mono_threadpool_io_cleanup (void); -#endif /* ENABLE_NETCORE */ #endif /* _MONO_METADATA_THREADPOOL_IO_H_ */ diff --git a/mono/metadata/threadpool-worker-default.c b/mono/metadata/threadpool-worker-default.c index 27844ab2751..044b0cb7d8f 100644 --- a/mono/metadata/threadpool-worker-default.c +++ b/mono/metadata/threadpool-worker-default.c @@ -14,7 +14,6 @@ #include <config.h> #include <glib.h> -#ifndef ENABLE_NETCORE #include <mono/metadata/class-internals.h> #include <mono/metadata/exception.h> @@ -1233,4 +1232,3 @@ mono_threadpool_worker_set_suspended (gboolean suspended) mono_refcount_dec (&worker); } -#endif /* ENABLE_NETCORE */ diff --git a/mono/metadata/threadpool-worker-wasm.c b/mono/metadata/threadpool-worker-wasm.c index 3cd3485c56f..d2b8fc68fb1 100644 --- a/mono/metadata/threadpool-worker-wasm.c +++ b/mono/metadata/threadpool-worker-wasm.c @@ -14,7 +14,6 @@ #include <config.h> #include <glib.h> -#ifndef ENABLE_NETCORE #include <mono/metadata/threadpool.h> #include <mono/metadata/threadpool-worker.h> @@ -78,4 +77,3 @@ mono_threadpool_worker_notify_completed (void) return FALSE; } -#endif diff --git a/mono/metadata/threadpool-worker.h b/mono/metadata/threadpool-worker.h index 0b37d248290..35894230d53 100644 --- a/mono/metadata/threadpool-worker.h +++ b/mono/metadata/threadpool-worker.h @@ -8,7 +8,6 @@ #include <config.h> #include <glib.h> -#ifndef ENABLE_NETCORE typedef void (*MonoThreadPoolWorkerCallback)(void); @@ -37,6 +36,5 @@ mono_threadpool_worker_set_max (gint32 value); void mono_threadpool_worker_set_suspended (gboolean suspended); -#endif /* ENABLE_NETCORE */ #endif /* _MONO_METADATA_THREADPOOL_WORKER_H */ diff --git a/mono/metadata/threadpool.c b/mono/metadata/threadpool.c index ecbe81abbda..cc669e9e132 100644 --- a/mono/metadata/threadpool.c +++ b/mono/metadata/threadpool.c @@ -24,7 +24,6 @@ #include <config.h> #include <mono/utils/mono-compiler.h> -#ifndef ENABLE_NETCORE #include <stdlib.h> #define _USE_MATH_DEFINES // needed by MSVC to define math constants @@ -823,6 +822,5 @@ ves_icall_System_Threading_ThreadPool_RequestWorkerThread (MonoError *error) return TRUE; } -#endif /* !ENABLE_NETCORE */ MONO_EMPTY_SOURCE_FILE (threadpool); diff --git a/mono/metadata/threads-types.h b/mono/metadata/threads-types.h index 8ad7e27599f..de2ecf92270 100644 --- a/mono/metadata/threads-types.h +++ b/mono/metadata/threads-types.h @@ -161,10 +161,8 @@ gint64 ves_icall_System_Threading_Interlocked_Exchange_Long(gint64 *location, gi ICALL_EXPORT void ves_icall_System_Threading_Interlocked_Exchange_Object (MonoObject *volatile*location, MonoObject *volatile*value, MonoObject *volatile*res); -#ifndef ENABLE_NETCORE ICALL_EXPORT gpointer ves_icall_System_Threading_Interlocked_Exchange_IntPtr(gpointer *location, gpointer value); -#endif ICALL_EXPORT gfloat ves_icall_System_Threading_Interlocked_Exchange_Single(gfloat *location, gfloat value); @@ -184,10 +182,8 @@ gint64 ves_icall_System_Threading_Interlocked_CompareExchange_Long(gint64 *locat ICALL_EXPORT void ves_icall_System_Threading_Interlocked_CompareExchange_Object (MonoObject *volatile*location, MonoObject *volatile*value, MonoObject *volatile*comparand, MonoObject *volatile*res); -#ifndef ENABLE_NETCORE ICALL_EXPORT gpointer ves_icall_System_Threading_Interlocked_CompareExchange_IntPtr(gpointer *location, gpointer value, gpointer comparand); -#endif ICALL_EXPORT gfloat ves_icall_System_Threading_Interlocked_CompareExchange_Single(gfloat *location, gfloat value, gfloat comparand); @@ -363,9 +359,7 @@ mono_thread_set_name (MonoInternalThread *thread, MONO_THREAD_NAME_WINDOWS_CONSTANT (name), \ (flags) | MonoSetThreadNameFlag_Constant, NULL) -#ifndef ENABLE_NETCORE void mono_thread_suspend_all_other_threads (void); -#endif gboolean mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout); void mono_thread_push_appdomain_ref (MonoDomain *domain); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index f861bbf5022..9bfb9ed4d1e 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -545,11 +545,7 @@ unlock_thread_handle (MonoInternalThreadHandle thread) static gboolean is_appdomainunloaded_exception (MonoClass *klass) { -#ifdef ENABLE_NETCORE - return FALSE; -#else return klass == mono_class_get_appdomain_unloaded_exception_class (); -#endif } static gboolean @@ -646,23 +642,17 @@ get_current_thread_ptr_for_domain (MonoDomain *domain, MonoInternalThread *threa static void set_current_thread_for_domain (MonoDomain *domain, MonoInternalThread *thread, MonoThread *current) { -#ifndef ENABLE_NETCORE MonoThread **current_thread_ptr = get_current_thread_ptr_for_domain (domain, thread); g_assert (current->obj.vtable->domain == domain); g_assert (!*current_thread_ptr); *current_thread_ptr = current; -#endif } static MonoThread* create_thread_object (MonoDomain *domain, MonoInternalThread *internal) { -#ifdef ENABLE_NETCORE - MONO_OBJECT_SETREF_INTERNAL (internal, internal_thread, internal); - return internal; -#else MonoThread *thread; MonoVTable *vtable; ERROR_DECL (error); @@ -677,7 +667,6 @@ create_thread_object (MonoDomain *domain, MonoInternalThread *internal) MONO_OBJECT_SETREF_INTERNAL (thread, internal_thread, internal); return thread; -#endif } static void @@ -1005,9 +994,7 @@ mono_thread_detach_internal (MonoInternalThread *thread) thread->abort_state_handle = 0; thread->abort_exc = NULL; -#ifndef ENABLE_NETCORE thread->current_appcontext = NULL; -#endif LOCK_THREAD (thread); @@ -1250,20 +1237,6 @@ start_wrapper_internal (StartInfo *start_info, gsize *stack_ptr) if (start_func) { start_func (start_func_arg); } else { -#ifdef ENABLE_NETCORE - /* Call a callback in the RuntimeThread class */ - g_assert (start_delegate == NULL); - - MONO_STATIC_POINTER_INIT (MonoMethod, cb) - - cb = mono_class_get_method_from_name_checked (internal->obj.vtable->klass, "StartCallback", 0, 0, error); - g_assert (cb); - mono_error_assert_ok (error); - - MONO_STATIC_POINTER_INIT_END (MonoMethod, cb) - - mono_runtime_invoke_checked (cb, internal, NULL, error); -#else void *args [1]; g_assert (start_delegate != NULL); @@ -1271,7 +1244,6 @@ start_wrapper_internal (StartInfo *start_info, gsize *stack_ptr) /* we may want to handle the exception here. See comment below on unhandled exceptions */ args [0] = (gpointer) start_delegate_arg; mono_runtime_delegate_invoke_checked (start_delegate, args, error); -#endif if (!is_ok (error)) { MonoException *ex = mono_error_convert_to_exception (error); @@ -1406,11 +1378,9 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta mono_g_hash_table_insert_internal (threads_starting_up, thread, thread); mono_threads_unlock (); -#ifndef ENABLE_NETCORE internal->threadpool_thread = flags & MONO_THREAD_CREATE_FLAGS_THREADPOOL; if (internal->threadpool_thread) mono_thread_set_state (internal, ThreadState_Background); -#endif internal->debugger_thread = flags & MONO_THREAD_CREATE_FLAGS_DEBUGGER; @@ -1436,11 +1406,7 @@ create_thread (MonoThread *thread, MonoInternalThread *internal, MonoObject *sta mono_g_hash_table_remove (threads_starting_up, thread); mono_threads_unlock (); -#ifdef ENABLE_NETCORE - throw_thread_start_exception (mono_w32error_get_last(), error); -#else mono_error_set_execution_engine (error, "Couldn't create thread. Error 0x%x", mono_w32error_get_last()); -#endif /* ref is not going to be decremented in start_wrapper_internal */ mono_atomic_dec_i32 (&start_info->ref); ret = FALSE; @@ -1824,13 +1790,11 @@ mono_thread_construct_internal (MonoThreadObjectHandle this_obj_handle) mono_gchandle_free_internal (thread_gchandle); } -#ifndef ENABLE_NETCORE void ves_icall_System_Threading_Thread_ConstructInternalThread (MonoThreadObjectHandle this_obj_handle, MonoError *error) { mono_thread_construct_internal (this_obj_handle); } -#endif void ves_icall_System_Threading_Thread_GetCurrentThread (MonoThread *volatile* thread) @@ -1856,7 +1820,6 @@ mono_error_set_exception_thread_not_started_or_dead (MonoError *error) mono_error_set_exception_thread_state (error, "Thread has not been started, or is dead."); } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Threading_Thread_Thread_internal (MonoThreadObjectHandle thread_handle, MonoObjectHandle start_handle, MonoError *error) { @@ -1906,7 +1869,6 @@ ves_icall_System_Threading_Thread_Thread_internal (MonoThreadObjectHandle thread UNLOCK_THREAD (internal); return TRUE; } -#endif static void @@ -1996,13 +1958,6 @@ mono_sleep_internal (gint32 ms, MonoBoolean allow_interruption, MonoError *error } } -#ifdef ENABLE_NETCORE -void -ves_icall_System_Threading_Thread_Sleep_internal (gint32 ms, MonoBoolean allow_interruption, MonoError *error) -{ - mono_sleep_internal (ms, allow_interruption, error); -} -#else void ves_icall_System_Threading_Thread_Sleep_internal (gint32 ms, MonoError *error) { @@ -2013,15 +1968,12 @@ void ves_icall_System_Threading_Thread_SpinWait_nop (MonoError *error) { } -#endif -#ifndef ENABLE_NETCORE gint32 ves_icall_System_Threading_Thread_GetDomainID (MonoError *error) { return mono_domain_get()->domain_id; } -#endif /** * mono_thread_get_name_utf8: @@ -2071,7 +2023,6 @@ mono_thread_get_managed_id (MonoThread *thread) return id; } -#ifndef ENABLE_NETCORE MonoStringHandle ves_icall_System_Threading_Thread_GetName_internal (MonoInternalThreadHandle thread_handle, MonoError *error) { @@ -2093,7 +2044,6 @@ ves_icall_System_Threading_Thread_GetName_internal (MonoInternalThreadHandle thr return str; } -#endif // Unusal function: // - MonoError is optional -- failure is usually not interesting, except the documented failure mode for managed callers. @@ -2172,22 +2122,12 @@ ves_icall_System_Threading_Thread_SetName_icall (MonoInternalThreadHandle thread char* name8 = name16 ? g_utf16_to_utf8 (name16, name16_length, NULL, &name8_length, NULL) : NULL; -#ifdef ENABLE_NETCORE - // The managed thread implementation prevents the Name property from being set multiple times on normal threads. On thread - // pool threads, for compatibility the thread's name should be changeable and this function may be called to force-reset the - // thread's name if user code had changed it. So for the flags, MonoSetThreadNameFlag_Reset is passed instead of - // MonoSetThreadNameFlag_Permanent for all threads, relying on the managed side to prevent multiple changes where - // appropriate. - MonoSetThreadNameFlags flags = MonoSetThreadNameFlag_Reset; -#else MonoSetThreadNameFlags flags = MonoSetThreadNameFlag_Permanent; -#endif mono_thread_set_name (mono_internal_thread_handle_ptr (thread_handle), name8, (gint32)name8_length, name16, flags, error); } -#ifndef ENABLE_NETCORE /* * ves_icall_System_Threading_Thread_GetPriority_internal: * @param this_obj: The MonoInternalThread on which to operate. @@ -2208,7 +2148,6 @@ ves_icall_System_Threading_Thread_GetPriority (MonoThreadObjectHandle this_obj, return priority; } -#endif /* * ves_icall_System_Threading_Thread_SetPriority_internal: @@ -2269,7 +2208,6 @@ exit: HANDLE_FUNCTION_RETURN_REF (MonoArray, dest.handle) } -#ifndef ENABLE_NETCORE MonoArrayHandle ves_icall_System_Threading_Thread_ByteArrayToRootDomain (MonoArrayHandle arr, MonoError *error) { @@ -2281,7 +2219,6 @@ ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArrayHandle arr, { return byte_array_to_domain (arr, mono_domain_get (), error); } -#endif /** * mono_thread_current: @@ -2289,9 +2226,6 @@ ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArrayHandle arr, MonoThread * mono_thread_current (void) { -#ifdef ENABLE_NETCORE - return mono_thread_internal_current (); -#else MonoDomain *domain = mono_domain_get (); MonoInternalThread *internal = mono_thread_internal_current (); MonoThread **current_thread_ptr; @@ -2304,7 +2238,6 @@ mono_thread_current (void) *current_thread_ptr = create_thread_object (domain, internal); } return *current_thread_ptr; -#endif } static MonoThreadObjectHandle @@ -2317,9 +2250,6 @@ mono_thread_current_handle (void) static MonoThread * mono_thread_current_for_thread (MonoInternalThread *internal) { -#ifdef ENABLE_NETCORE - return mono_thread_internal_current (); -#else MonoDomain *domain = mono_domain_get (); MonoThread **current_thread_ptr; @@ -2331,7 +2261,6 @@ mono_thread_current_for_thread (MonoInternalThread *internal) *current_thread_ptr = create_thread_object (domain, internal); } return *current_thread_ptr; -#endif } MonoInternalThread* @@ -2618,12 +2547,10 @@ ves_icall_System_Threading_Interlocked_Exchange_Object (MonoObject *volatile*loc mono_gc_wbarrier_generic_nostore_internal ((gpointer)location); // FIXME volatile } -#ifndef ENABLE_NETCORE gpointer ves_icall_System_Threading_Interlocked_Exchange_IntPtr (gpointer *location, gpointer value) { return mono_atomic_xchg_ptr(location, value); } -#endif gfloat ves_icall_System_Threading_Interlocked_Exchange_Single (gfloat *location, gfloat value) { @@ -2689,12 +2616,10 @@ ves_icall_System_Threading_Interlocked_CompareExchange_Object (MonoObject *volat mono_gc_wbarrier_generic_nostore_internal ((gpointer)location); // FIXME volatile } -#ifndef ENABLE_NETCORE gpointer ves_icall_System_Threading_Interlocked_CompareExchange_IntPtr(gpointer *location, gpointer value, gpointer comparand) { return mono_atomic_cas_ptr(location, value, comparand); } -#endif gfloat ves_icall_System_Threading_Interlocked_CompareExchange_Single (gfloat *location, gfloat value, gfloat comparand) { @@ -2927,7 +2852,6 @@ request_thread_abort (MonoInternalThread *thread, MonoObjectHandle *state, gbool return TRUE; } -#ifndef ENABLE_NETCORE void ves_icall_System_Threading_Thread_Abort (MonoInternalThreadHandle thread_handle, MonoObjectHandle state, MonoError *error) { @@ -2945,7 +2869,6 @@ ves_icall_System_Threading_Thread_Abort (MonoInternalThreadHandle thread_handle, async_abort_internal (thread, TRUE); } } -#endif /** * mono_thread_internal_abort: @@ -2963,7 +2886,6 @@ mono_thread_internal_abort (MonoInternalThread *thread, gboolean appdomain_unloa return async_abort_internal (thread, TRUE); } -#ifndef ENABLE_NETCORE void ves_icall_System_Threading_Thread_ResetAbort (MonoThreadObjectHandle this_obj, MonoError *error) { @@ -2993,7 +2915,6 @@ ves_icall_System_Threading_Thread_ResetAbort (MonoThreadObjectHandle this_obj, M only counts if the exception is set */ thread->abort_state_handle = 0; } -#endif void mono_thread_internal_reset_abort (MonoInternalThread *thread) @@ -3014,7 +2935,6 @@ mono_thread_internal_reset_abort (MonoInternalThread *thread) UNLOCK_THREAD (thread); } -#ifndef ENABLE_NETCORE MonoObjectHandle ves_icall_System_Threading_Thread_GetAbortExceptionState (MonoThreadObjectHandle this_obj, MonoError *error) { @@ -3054,7 +2974,6 @@ ves_icall_System_Threading_Thread_GetAbortExceptionState (MonoThreadObjectHandle // There is state, but we failed to return it. return NULL_HANDLE; } -#endif static gboolean mono_thread_suspend (MonoInternalThread *thread) @@ -3089,7 +3008,6 @@ mono_thread_suspend (MonoInternalThread *thread) return TRUE; } -#ifndef ENABLE_NETCORE void ves_icall_System_Threading_Thread_Suspend (MonoThreadObjectHandle this_obj, MonoError *error) { @@ -3097,7 +3015,6 @@ ves_icall_System_Threading_Thread_Suspend (MonoThreadObjectHandle this_obj, Mono mono_error_set_exception_thread_not_started_or_dead (error); } -#endif /* LOCKING: LOCK_THREAD(thread) must be held */ static gboolean @@ -3142,7 +3059,6 @@ mono_thread_resume (MonoInternalThread *thread) return TRUE; } -#ifndef ENABLE_NETCORE void ves_icall_System_Threading_Thread_Resume (MonoThreadObjectHandle thread_handle, MonoError *error) { @@ -3162,7 +3078,6 @@ ves_icall_System_Threading_Thread_Resume (MonoThreadObjectHandle thread_handle, if (exception) mono_error_set_exception_thread_not_started_or_dead (error); } -#endif gboolean mono_threads_is_critical_method (MonoMethod *method) @@ -3499,13 +3414,11 @@ mono_threads_register_app_context (MonoAppContextHandle ctx, MonoError *error) MONO_PROFILER_RAISE (context_loaded, (MONO_HANDLE_RAW (ctx))); } -#ifndef ENABLE_NETCORE void ves_icall_System_Runtime_Remoting_Contexts_Context_RegisterContext (MonoAppContextHandle ctx, MonoError *error) { mono_threads_register_app_context (ctx, error); } -#endif void mono_threads_release_app_context (MonoAppContext* ctx, MonoError *error) @@ -3521,13 +3434,11 @@ mono_threads_release_app_context (MonoAppContext* ctx, MonoError *error) MONO_PROFILER_RAISE (context_unloaded, (ctx)); } -#ifndef ENABLE_NETCORE void ves_icall_System_Runtime_Remoting_Contexts_Context_ReleaseContext (MonoAppContextHandle ctx, MonoError *error) { mono_threads_release_app_context (MONO_HANDLE_RAW (ctx), error); /* FIXME use handles in mono_threads_release_app_context */ } -#endif void mono_thread_init (MonoThreadStartCB start_cb, MonoThreadAttachCB attach_cb) @@ -3948,7 +3859,6 @@ mono_thread_manage_internal (void) mono_thread_execute_interruption_void (); } -#ifndef ENABLE_NETCORE /* * Under netcore, we don't abort any threads, just exit. * This is not a problem since we don't do runtime cleanup either. @@ -3975,7 +3885,6 @@ mono_thread_manage_internal (void) wait_for_tids (wait, MONO_INFINITE_WAIT, FALSE); } } while (wait->num > 0); -#endif /* * give the subthreads a chance to really quit (this is mainly needed @@ -3985,7 +3894,6 @@ mono_thread_manage_internal (void) mono_thread_info_yield (); } -#ifndef ENABLE_NETCORE static void collect_threads_for_suspend (gpointer key, gpointer value, gpointer user_data) { @@ -4117,7 +4025,6 @@ void mono_thread_suspend_all_other_threads (void) } } } -#endif typedef struct { MonoInternalThread *thread; @@ -4343,7 +4250,6 @@ mono_threads_perform_thread_dump (void) thread_dump_requested = FALSE; } -#ifndef ENABLE_NETCORE /* Obtain the thread dump of all threads */ void ves_icall_System_Threading_Thread_GetStackTraces (MonoArrayHandleOut out_threads_handle, MonoArrayHandleOut out_stack_frames_handle, MonoError *error) @@ -4458,7 +4364,6 @@ leave: mono_gchandle_free_internal (handle); g_free (ud.frames); } -#endif /** * mono_threads_request_thread_dump: @@ -5052,11 +4957,7 @@ mono_get_special_static_data_for_thread (MonoInternalThread *thread, guint32 off if (static_type == SPECIAL_STATIC_OFFSET_TYPE_THREAD) { return get_thread_static_data (thread, offset); } else { -#ifndef ENABLE_NETCORE return get_context_static_data (thread->current_appcontext, offset); -#else - g_assert_not_reached (); -#endif } } @@ -7383,93 +7284,3 @@ mono_threads_summarize (MonoContext *ctx, gchar **out, MonoStackHash *hashes, gb #endif -#ifdef ENABLE_NETCORE -void -ves_icall_System_Threading_Thread_StartInternal (MonoThreadObjectHandle thread_handle, MonoError *error) -{ - MonoThread *internal = MONO_HANDLE_RAW (thread_handle); - gboolean res; - -#ifdef DISABLE_THREADS - mono_error_set_platform_not_supported (error, "Cannot start threads on this runtime."); - return; -#endif - - THREAD_DEBUG (g_message("%s: Trying to start a new thread: this (%p)", __func__, internal)); - - LOCK_THREAD (internal); - - if ((internal->state & ThreadState_Unstarted) == 0) { - UNLOCK_THREAD (internal); - mono_error_set_exception_thread_state (error, "Thread has already been started."); - return; - } - - if ((internal->state & ThreadState_Aborted) != 0) { - UNLOCK_THREAD (internal); - return; - } - - res = create_thread (internal, internal, NULL, NULL, NULL, MONO_THREAD_CREATE_FLAGS_NONE, error); - if (!res) { - UNLOCK_THREAD (internal); - return; - } - - internal->state &= ~ThreadState_Unstarted; - - THREAD_DEBUG (g_message ("%s: Started thread ID %" G_GSIZE_FORMAT " (handle %p)", __func__, (gsize)internal->tid, internal->handle)); - - UNLOCK_THREAD (internal); -} - -void -ves_icall_System_Threading_Thread_InitInternal (MonoThreadObjectHandle thread_handle, MonoError *error) -{ - MonoThread *internal = MONO_HANDLE_RAW (thread_handle); - - // Need to initialize thread objects created from managed code - init_internal_thread_object (internal); - internal->state = ThreadState_Unstarted; - MONO_OBJECT_SETREF_INTERNAL (internal, internal_thread, internal); -} - -guint64 -ves_icall_System_Threading_Thread_GetCurrentOSThreadId (MonoError *error) -{ - return mono_native_thread_os_id_get (); -} - -gint32 -ves_icall_System_Threading_Thread_GetCurrentProcessorNumber (MonoError *error) -{ - return mono_native_thread_processor_id_get (); -} - -gpointer -ves_icall_System_Threading_LowLevelLifoSemaphore_InitInternal (void) -{ - return (gpointer)mono_lifo_semaphore_init (); -} - -void -ves_icall_System_Threading_LowLevelLifoSemaphore_DeleteInternal (gpointer sem_ptr) -{ - LifoSemaphore *sem = (LifoSemaphore *)sem_ptr; - mono_lifo_semaphore_delete (sem); -} - -gint32 -ves_icall_System_Threading_LowLevelLifoSemaphore_TimedWaitInternal (gpointer sem_ptr, gint32 timeout_ms) -{ - LifoSemaphore *sem = (LifoSemaphore *)sem_ptr; - return mono_lifo_semaphore_timed_wait (sem, timeout_ms); -} - -void -ves_icall_System_Threading_LowLevelLifoSemaphore_ReleaseInternal (gpointer sem_ptr, gint32 count) -{ - LifoSemaphore *sem = (LifoSemaphore *)sem_ptr; - mono_lifo_semaphore_release (sem, count); -} -#endif diff --git a/mono/metadata/w32event-unix.c b/mono/metadata/w32event-unix.c index abc9bf98b26..4d38307ac22 100644 --- a/mono/metadata/w32event-unix.c +++ b/mono/metadata/w32event-unix.c @@ -378,7 +378,6 @@ ves_icall_System_Threading_Events_CloseEvent_internal (gpointer handle) mono_w32handle_close (handle); } -#ifndef ENABLE_NETCORE gpointer ves_icall_System_Threading_Events_OpenEvent_icall (const gunichar2 *name, gint32 name_length, gint32 rights, gint32 *win32error, MonoError *error) @@ -390,7 +389,6 @@ ves_icall_System_Threading_Events_OpenEvent_icall (const gunichar2 *name, gint32 g_free (utf8_name); return handle; } -#endif gpointer mono_w32event_open (const gchar *utf8_name, gint32 rights G_GNUC_UNUSED, gint32 *win32error) diff --git a/mono/metadata/w32file-unix.c b/mono/metadata/w32file-unix.c index 98a0d8ad767..3224ec416f5 100644 --- a/mono/metadata/w32file-unix.c +++ b/mono/metadata/w32file-unix.c @@ -4734,7 +4734,6 @@ GetDriveTypeFromPath (const gchar *utf8_root_path_name) } #endif -#ifndef ENABLE_NETCORE guint32 mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_name_length, MonoError *error) { @@ -4766,7 +4765,6 @@ mono_w32file_get_drive_type (const gunichar2 *root_path_name, gint32 root_path_n return (drive_type); } -#endif #if defined (HOST_DARWIN) || defined (__linux__) || defined(HOST_BSD) || defined(__FreeBSD_kernel__) || defined(__HAIKU__) || defined(_AIX) static gchar* diff --git a/mono/metadata/w32file.c b/mono/metadata/w32file.c index bee7f717400..76bef3be8f8 100644 --- a/mono/metadata/w32file.c +++ b/mono/metadata/w32file.c @@ -187,7 +187,6 @@ static guint32 convert_attrs(MonoFileAttributes attrs) /* System.IO.MonoIO internal calls */ -#if !ENABLE_NETCORE MonoBoolean ves_icall_System_IO_MonoIO_CreateDirectory (const gunichar2 *path, gint32 *error) @@ -868,7 +867,6 @@ void ves_icall_System_IO_MonoIO_DumpHandles (void) } #endif /* !HOST_WIN32 */ -#endif /* !ENABLE_NETCORE */ //Support for io-layer free mmap'd files. diff --git a/mono/metadata/w32file.h b/mono/metadata/w32file.h index e40eac1a0ff..3a6b93cac3e 100644 --- a/mono/metadata/w32file.h +++ b/mono/metadata/w32file.h @@ -113,7 +113,6 @@ typedef struct _MonoFSAsyncResult { */ /* System.IO.MonoIO */ -#if !ENABLE_NETCORE ICALL_EXPORT MonoBoolean @@ -248,7 +247,6 @@ ICALL_EXPORT void ves_icall_System_IO_MonoIO_DumpHandles (void); -#endif /* !ENABLE_NETCORE */ #if defined (TARGET_IOS) || defined (TARGET_ANDROID) diff --git a/mono/metadata/w32process-unix.c b/mono/metadata/w32process-unix.c index 31d2d2319a8..892e9c07447 100644 --- a/mono/metadata/w32process-unix.c +++ b/mono/metadata/w32process-unix.c @@ -91,7 +91,7 @@ #include "object-internals.h" #include "icall-decl.h" -#if !defined(ENABLE_NETCORE) && !defined(DISABLE_PROCESSES) +#if !defined(DISABLE_PROCESSES) #ifndef MAXPATHLEN #define MAXPATHLEN 242 @@ -3500,50 +3500,4 @@ mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subbl return(ret); } -#else /* ENABLE_NETCORE && DISABLE_PROCESSES */ - -void -mono_w32process_init (void) -{ -} - -void -mono_w32process_cleanup (void) -{ -} - -void -mono_w32process_set_cli_launcher (gchar *path) -{ -} - -void -mono_w32process_signal_finished (void) -{ -} - -guint32 -mono_w32process_ver_language_name (guint32 lang, gunichar2 *lang_out, guint32 lang_len) -{ - return 0; -} - -gboolean -mono_w32process_get_fileversion_info (const gunichar2 *filename, gpointer *data) -{ - return FALSE; -} - -gboolean -mono_w32process_module_get_information (gpointer handle, gpointer module, gpointer modinfo, guint32 size) -{ - return FALSE; -} - -gboolean -mono_w32process_ver_query_value (gconstpointer datablock, const gunichar2 *subblock, gpointer *buffer, guint32 *len) -{ - return FALSE; -} - -#endif /* ENABLE_NETCORE && DISABLE_PROCESSES */ +#endif /* !defined(DISABLE_PROCESSES) */ diff --git a/mono/metadata/w32process.c b/mono/metadata/w32process.c index 08f9386f1ff..7c459a7b332 100644 --- a/mono/metadata/w32process.c +++ b/mono/metadata/w32process.c @@ -312,7 +312,6 @@ mono_w32process_get_fileversion (MonoObjectHandle filever, MonoStringHandle str, } #endif -#ifndef ENABLE_NETCORE void ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal (MonoObjectHandle this_obj, const gunichar2 *filename, int filename_length, MonoError *error) @@ -324,7 +323,6 @@ ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal (MonoObject process_set_field_utf16 (this_obj, str, "filename", filename, filename_length, error); } -#endif static GPtrArray* get_domain_assemblies (MonoDomain *domain) @@ -451,7 +449,6 @@ exit: HANDLE_FUNCTION_RETURN (); } -#ifndef ENABLE_NETCORE /* Returns an array of System.Diagnostics.ProcessModule */ MonoArrayHandle ves_icall_System_Diagnostics_Process_GetModules_internal (MonoObjectHandle this_obj, HANDLE process, MonoError *error) @@ -548,7 +545,6 @@ ves_icall_System_Diagnostics_Process_ProcessName_internal (HANDLE process, MonoE g_free (name); return res; } -#endif /* ENABLE_NETCORE */ gint64 ves_icall_System_Diagnostics_Process_GetProcessData (int pid, gint32 data_type, MonoProcessError *error) diff --git a/mono/metadata/w32socket-unix.c b/mono/metadata/w32socket-unix.c index 3c0e13a214c..58645ed4ef8 100644 --- a/mono/metadata/w32socket-unix.c +++ b/mono/metadata/w32socket-unix.c @@ -1557,7 +1557,6 @@ mono_w32socket_convert_error (gint error) } } -#ifndef ENABLE_NETCORE MonoBoolean ves_icall_System_Net_Sockets_Socket_SupportPortReuse_icall (MonoProtocolType proto) { @@ -1572,7 +1571,6 @@ ves_icall_System_Net_Sockets_Socket_SupportPortReuse_icall (MonoProtocolType pro return FALSE; #endif } -#endif gboolean mono_w32socket_duplicate (gpointer handle, gint32 targetProcessId, gpointer *duplicate_handle) diff --git a/mono/metadata/w32socket.c b/mono/metadata/w32socket.c index e7102f43f3d..1ad49360e59 100644 --- a/mono/metadata/w32socket.c +++ b/mono/metadata/w32socket.c @@ -18,7 +18,7 @@ #include <mono/metadata/w32socket.h> -#if !defined(DISABLE_SOCKETS) && !defined(ENABLE_NETCORE) +#if !defined(DISABLE_SOCKETS) #if defined(__APPLE__) || defined(__FreeBSD__) #define __APPLE_USE_RFC_3542 @@ -2644,4 +2644,4 @@ mono_network_cleanup (void) { } -#endif // !defined(DISABLE_SOCKETS) && !defined(ENABLE_NETCORE) +#endif // !defined(DISABLE_SOCKETS) diff --git a/mono/mini/Makefile.am.in b/mono/mini/Makefile.am.in index 132c3561b02..20765e4228d 100755 --- a/mono/mini/Makefile.am.in +++ b/mono/mini/Makefile.am.in @@ -447,11 +447,6 @@ llvm_runtime_sources = \ endif endif -if ENABLE_NETCORE -netcore_sources = \ - main-core.c -endif - common_sources = \ mini.c \ mini-runtime.c \ @@ -496,11 +491,9 @@ common_sources = \ branch-opts.c \ mini-generic-sharing.c \ simd-methods.h \ - simd-methods-netcore.h \ tasklets.c \ tasklets.h \ simd-intrinsics.c \ - simd-intrinsics-netcore.c \ mini-native-types.c \ mini-unwind.h \ unwind.c \ @@ -750,7 +743,7 @@ endif # This library is shared between mono and mono-sgen, since the code in mini/ doesn't contain # compile time dependencies on boehm/sgen. # -libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(arch_sources) $(os_sources) $(netcore_sources) +libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(arch_sources) $(os_sources) libmini_la_CFLAGS = $(AM_CFLAGS) @CXX_ADD_CFLAGS@ libmonoboehm_2_0_la_SOURCES = @@ -1091,10 +1084,6 @@ EXTRA_DIST = TestDriver.cs \ interp/whitebox-snippets.il \ Makefile.am.in -if ENABLE_NETCORE -version.h: Makefile - echo "#define FULL_VERSION \"netcore\"" > version.h -else version.h: Makefile if test -e $(top_srcdir)/.git; then \ (cd $(top_srcdir); \ @@ -1114,7 +1103,6 @@ version.h: Makefile echo "#define FULL_VERSION \"$$MONO_BRANCH/$$MONO_BUILD_REVISION\""; \ fi \ fi > version.h -endif # Utility target for patching libtool to speed up linking patch-libtool: diff --git a/mono/mini/alias-analysis.c b/mono/mini/alias-analysis.c index ea596ffb006..cf51350186f 100644 --- a/mono/mini/alias-analysis.c +++ b/mono/mini/alias-analysis.c @@ -311,11 +311,6 @@ handle_instruction: } g_hash_table_destroy (addr_loads); -#ifdef ENABLE_NETCORE - /* There could be ldaddr instructions which already got eliminated */ - if (COMPILE_LLVM (cfg)) - return TRUE; -#endif return needs_dce; } diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index 6247628384d..1a9b616fc50 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -5090,49 +5090,6 @@ MONO_RESTORE_WARNING g_hash_table_insert (acfg->export_names, wrapper, export_name); } -#ifdef ENABLE_NETCORE - for (j = 0; j < cattr->num_attrs; ++j) - if (cattr->attrs [j].ctor && mono_is_corlib_image (m_class_get_image (cattr->attrs [j].ctor->klass)) && !strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "UnmanagedCallersOnlyAttribute")) - break; - if (j < cattr->num_attrs) { - MonoCustomAttrEntry *e = &cattr->attrs [j]; - const char *named; - int slen; - char *export_name = NULL; - MonoMethod *wrapper; - - if (!(method->flags & METHOD_ATTRIBUTE_STATIC)) { - g_warning ("AOT restriction: Method '%s' must be static since it is decorated with [UnmanagedCallers].", - mono_method_full_name (method, TRUE)); - exit (1); - } - - gpointer *typed_args = NULL; - gpointer *named_args = NULL; - CattrNamedArg *named_arg_info = NULL; - int num_named_args = 0; - mono_reflection_create_custom_attr_data_args_noalloc (acfg->image, e->ctor, e->data, e->data_size, &typed_args, &named_args, &num_named_args, &named_arg_info, error); - mono_error_assert_ok (error); - for (j = 0; j < num_named_args; ++j) { - if (named_arg_info [j].field && !strcmp (named_arg_info [j].field->name, "EntryPoint")) { - named = named_args [j]; - slen = mono_metadata_decode_value (named, &named); - export_name = (char *)g_malloc (slen + 1); - memcpy (export_name, named, slen); - export_name [slen] = 0; - } - } - g_free (named_args); - g_free (named_arg_info); - - wrapper = mono_marshal_get_managed_wrapper (method, NULL, 0, error); - mono_error_assert_ok (error); - - add_method (acfg, wrapper); - if (export_name) - g_hash_table_insert (acfg->export_names, wrapper, export_name); - } -#endif g_free (cattr); } @@ -5424,7 +5381,6 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, else name_prefix = g_strdup_printf ("%s.%s", klass_name_space, klass_name); -#ifndef ENABLE_NETCORE /* Add the T[]/InternalEnumerator class */ if (!strcmp (klass_name, "IEnumerable`1") || !strcmp (klass_name, "IEnumerator`1")) { ERROR_DECL (error); @@ -5440,7 +5396,6 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, mono_error_assert_ok (error); /* FIXME don't swallow the error */ add_generic_class (acfg, nclass, FALSE, "ICollection<T>"); } -#endif iter = NULL; while ((method = mono_class_get_methods (array_class, &iter))) { @@ -5802,7 +5757,6 @@ add_generic_instances (MonoAotCompile *acfg) enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumEqualityComparer`1"); add_instances_of (acfg, enum_comparer, insts, ninsts, FALSE); -#ifndef ENABLE_NETCORE ninsts = 0; insts [ninsts ++] = int16_type; enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "ShortEnumEqualityComparer`1"); @@ -5818,7 +5772,6 @@ add_generic_instances (MonoAotCompile *acfg) insts [ninsts ++] = int64_type; insts [ninsts ++] = uint64_type; add_instances_of (acfg, enum_comparer, insts, ninsts, FALSE); -#endif } /* Add instances of the array generic interfaces for primitive types */ diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index ac6fc504871..ae697d64fa0 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -2870,10 +2870,8 @@ suspend_vm (void) tp_suspend = TRUE; mono_loader_unlock (); -#ifndef ENABLE_NETCORE if (tp_suspend) mono_threadpool_suspend (); -#endif } /* @@ -2913,10 +2911,8 @@ resume_vm (void) tp_resume = TRUE; mono_loader_unlock (); -#ifndef ENABLE_NETCORE if (tp_resume) mono_threadpool_resume (); -#endif } /* @@ -7107,10 +7103,8 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) mono_environment_exitcode_set (exit_code); /* Suspend all managed threads since the runtime is going away */ -#ifndef ENABLE_NETCORE PRINT_DEBUG_MSG (1, "Suspending all threads...\n"); mono_thread_suspend_all_other_threads (); -#endif PRINT_DEBUG_MSG (1, "Shutting down the runtime...\n"); mono_runtime_quit_internal (); transport_close2 (); diff --git a/mono/mini/driver.c b/mono/mini/driver.c index 472df6f48d3..6a48f075dcf 100644 --- a/mono/mini/driver.c +++ b/mono/mini/driver.c @@ -202,9 +202,6 @@ static gboolean parse_debug_options (const char* p) { MonoDebugOptions *opt = mini_get_debug_options (); -#ifdef ENABLE_NETCORE - opt->enabled = TRUE; -#endif do { if (!*p) { @@ -221,11 +218,6 @@ parse_debug_options (const char* p) } else if (!strncmp (p, "gdb", 3)) { opt->gdb = TRUE; p += 3; -#ifdef ENABLE_NETCORE - } else if (!strncmp (p, "ignore", 6)) { - opt->enabled = FALSE; - p += 6; -#endif } else { fprintf (stderr, "Invalid debug option `%s', use --help-debug for details\n", p); return FALSE; @@ -1620,12 +1612,7 @@ mini_usage (void) "\n" "Development:\n" " --aot[=<options>] Compiles the assembly to native code\n" -#ifdef ENABLE_NETCORE - " --debug=ignore Disable debugging support (on by default)\n" - " --debug=[<options>] Disable debugging support or enable debugging extras, use --help-debug for details\n" -#else " --debug[=<options>] Enable debugging support, use --help-debug for details\n" -#endif " --debugger-agent=options Enable the debugger agent\n" " --profile[=profiler] Runs in profiling mode with the specified profiler module\n" " --trace[=EXPR] Enable tracing, use --help-trace for details\n" @@ -1692,17 +1679,10 @@ mini_debug_usage (void) { fprintf (stdout, "Debugging options:\n" -#ifdef ENABLE_NETCORE - " --debug[=OPTIONS] Disable debugging support or enable debugging extras, optional OPTIONS is a comma\n" -#else " --debug[=OPTIONS] Enable debugging support, optional OPTIONS is a comma\n" -#endif " separated list of options\n" "\n" "OPTIONS is composed of:\n" -#ifdef ENABLE_NETCORE - " ignore Disable debugging support (on by default).\n" -#endif " casts Enable more detailed InvalidCastException messages.\n" " mdb-optimizations Disable some JIT optimizations which are normally\n" " disabled when running inside the debugger.\n" @@ -2010,14 +1990,10 @@ switch_arch (char* argv[], const char* target_arch) static void apply_root_domain_configuration_file_bindings (MonoDomain *domain, char *root_domain_configuration_file) { -#ifndef ENABLE_NETCORE g_assert (domain->setup == NULL || domain->setup->configuration_file == NULL); g_assert (!domain->assembly_bindings_parsed); mono_domain_parse_assembly_bindings (domain, 0, 0, root_domain_configuration_file); -#else - g_assert_not_reached (); -#endif } static void @@ -2164,9 +2140,6 @@ mono_main (int argc, char* argv[]) opt = mono_parse_default_optimizations (NULL); -#ifdef ENABLE_NETCORE - enable_debugging = TRUE; -#endif mono_options_parse_options ((const char**)argv + 1, argc - 1, &argc, error); argc ++; @@ -2415,13 +2388,6 @@ mono_main (int argc, char* argv[]) enable_debugging = TRUE; if (!parse_debug_options (argv [i] + 8)) return 1; -#ifdef ENABLE_NETCORE - MonoDebugOptions *opt = mini_get_debug_options (); - - if (!opt->enabled) { - enable_debugging = FALSE; - } -#endif } else if (strncmp (argv [i], "--debugger-agent=", 17) == 0) { MonoDebugOptions *opt = mini_get_debug_options (); diff --git a/mono/mini/exceptions-amd64.c b/mono/mini/exceptions-amd64.c index 82f25f81d03..9c23789491f 100644 --- a/mono/mini/exceptions-amd64.c +++ b/mono/mini/exceptions-amd64.c @@ -1906,7 +1906,7 @@ void mono_arch_code_chunk_destroy (void *chunk) } #endif /* MONO_ARCH_HAVE_UNWIND_TABLE */ -#if MONO_SUPPORT_TASKLETS && !defined(DISABLE_JIT) && !defined(ENABLE_NETCORE) +#if MONO_SUPPORT_TASKLETS && !defined(DISABLE_JIT) MonoContinuationRestore mono_tasklets_arch_restore (void) { @@ -1957,7 +1957,7 @@ mono_tasklets_arch_restore (void) saved = start; return (MonoContinuationRestore)saved; } -#endif /* MONO_SUPPORT_TASKLETS && !defined(DISABLE_JIT) && !defined(ENABLE_NETCORE) */ +#endif /* MONO_SUPPORT_TASKLETS && !defined(DISABLE_JIT) */ /* * mono_arch_setup_resume_sighandler_ctx: @@ -1976,14 +1976,14 @@ mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func) MONO_CONTEXT_SET_IP (ctx, func); } -#if (!MONO_SUPPORT_TASKLETS || defined(DISABLE_JIT)) && !defined(ENABLE_NETCORE) +#if (!MONO_SUPPORT_TASKLETS || defined(DISABLE_JIT)) MonoContinuationRestore mono_tasklets_arch_restore (void) { g_assert_not_reached (); return NULL; } -#endif /* (!MONO_SUPPORT_TASKLETS || defined(DISABLE_JIT)) && !defined(ENABLE_NETCORE) */ +#endif /* (!MONO_SUPPORT_TASKLETS || defined(DISABLE_JIT)) */ void mono_arch_undo_ip_adjustment (MonoContext *ctx) diff --git a/mono/mini/exceptions-x86.c b/mono/mini/exceptions-x86.c index d2b3201c343..d8f6f769a1c 100644 --- a/mono/mini/exceptions-x86.c +++ b/mono/mini/exceptions-x86.c @@ -1175,7 +1175,7 @@ mono_arch_handle_altstack_exception (void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *s #endif } -#if MONO_SUPPORT_TASKLETS && !defined(ENABLE_NETCORE) +#if MONO_SUPPORT_TASKLETS MonoContinuationRestore mono_tasklets_arch_restore (void) { diff --git a/mono/mini/interp/interp.c b/mono/mini/interp/interp.c index d80d5201afc..46b0da7a4ef 100644 --- a/mono/mini/interp/interp.c +++ b/mono/mini/interp/interp.c @@ -1570,11 +1570,6 @@ ves_pinvoke_method ( } #endif -#ifdef ENABLE_NETCORE - if (save_last_error) { - mono_marshal_clear_last_error (); - } -#endif #ifdef MONO_ARCH_HAVE_INTERP_PINVOKE_TRAMP CallContext ccontext; @@ -1705,7 +1700,6 @@ interp_delegate_ctor (MonoObjectHandle this_obj, MonoObjectHandle target, gpoint * runtime specifies that the implementation of the method is automatically * provided by the runtime and is primarily used for the methods of delegates. */ -#ifndef ENABLE_NETCORE static MONO_NEVER_INLINE MonoException* ves_imethod (InterpFrame *frame, MonoMethod *method, MonoMethodSignature *sig, stackval *sp) { @@ -1726,7 +1720,6 @@ ves_imethod (InterpFrame *frame, MonoMethod *method, MonoMethodSignature *sig, s m_class_get_name_space (method->klass), m_class_get_name (method->klass), method->name); } -#endif #if DEBUG_INTERP static void @@ -2033,10 +2026,6 @@ interp_entry (InterpEntryData *data) static void do_icall (MonoMethodSignature *sig, int op, stackval *sp, gpointer ptr, gboolean save_last_error) { -#ifdef ENABLE_NETCORE - if (save_last_error) - mono_marshal_clear_last_error (); -#endif switch (op) { case MINT_ICALL_V_V: { @@ -2903,15 +2892,6 @@ interp_create_method_pointer (MonoMethod *method, gboolean compile, MonoError *e return addr; } -#ifdef ENABLE_NETCORE - /* - * The runtime expects a function pointer unique to method and - * the native caller expects a function pointer with the - * right signature, so fail right away. - */ - mono_error_set_platform_not_supported (error, "No native to managed transitions on this platform."); - return NULL; -#endif } #endif return (gpointer)interp_no_native_to_managed; @@ -3749,7 +3729,6 @@ call: MINT_IN_BREAK; } MINT_IN_CASE(MINT_CALLRUN) { -#ifndef ENABLE_NETCORE MonoMethod *target_method = (MonoMethod*) frame->imethod->data_items [ip [2]]; MonoMethodSignature *sig = (MonoMethodSignature*) frame->imethod->data_items [ip [3]]; @@ -3758,9 +3737,6 @@ call: THROW_EX (ex, ip); ip += 4; -#else - g_assert_not_reached (); -#endif MINT_IN_BREAK; } MINT_IN_CASE(MINT_RET) diff --git a/mono/mini/interp/transform.c b/mono/mini/interp/transform.c index aa98dcaa85e..64e2d96d0d2 100644 --- a/mono/mini/interp/transform.c +++ b/mono/mini/interp/transform.c @@ -1987,10 +1987,8 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas interp_emit_ldelema (td, target_method->klass, check_class); td->ip += 5; return TRUE; -#ifndef ENABLE_NETCORE } else if (!strcmp (tm, "UnsafeMov") || !strcmp (tm, "UnsafeLoad")) { *op = MINT_CALLRUN; -#endif } else if (!strcmp (tm, "Get")) { interp_emit_ldelema (td, target_method->klass, NULL); interp_emit_ldobj (td, m_class_get_element_class (target_method->klass)); @@ -2191,112 +2189,7 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas } else if (((in_corlib && !strcmp (klass_name_space, "Internal.Runtime.CompilerServices")) || !strcmp (klass_name_space, "System.Runtime.CompilerServices")) && !strcmp (klass_name, "Unsafe")) { -#ifdef ENABLE_NETCORE - if (!strcmp (tm, "AddByteOffset")) - *op = MINT_INTRINS_UNSAFE_ADD_BYTE_OFFSET; - else if (!strcmp (tm, "ByteOffset")) - *op = MINT_INTRINS_UNSAFE_BYTE_OFFSET; - else if (!strcmp (tm, "As") || !strcmp (tm, "AsRef")) - *op = MINT_MOV_P; - else if (!strcmp (tm, "AsPointer")) { - /* NOP */ - SET_SIMPLE_TYPE (td->sp - 1, STACK_TYPE_MP); - td->ip += 5; - return TRUE; - } else if (!strcmp (tm, "IsAddressLessThan")) { - MonoGenericContext *ctx = mono_method_get_context (target_method); - g_assert (ctx); - g_assert (ctx->method_inst); - g_assert (ctx->method_inst->type_argc == 1); - - MonoClass *k = mono_defaults.boolean_class; - interp_add_ins (td, MINT_CLT_UN_P); - td->sp -= 2; - interp_ins_set_sregs2 (td->last_ins, td->sp [0].local, td->sp [1].local); - push_type (td, stack_type [mint_type (m_class_get_byval_arg (k))], k); - interp_ins_set_dreg (td->last_ins, td->sp [-1].local); - td->ip += 5; - return TRUE; - } else if (!strcmp (tm, "SizeOf")) { - MonoGenericContext *ctx = mono_method_get_context (target_method); - g_assert (ctx); - g_assert (ctx->method_inst); - g_assert (ctx->method_inst->type_argc == 1); - MonoType *t = ctx->method_inst->type_argv [0]; - int align; - int esize = mono_type_size (t, &align); - interp_add_ins (td, MINT_LDC_I4); - WRITE32_INS (td->last_ins, 0, &esize); - push_simple_type (td, STACK_TYPE_I4); - interp_ins_set_dreg (td->last_ins, td->sp [-1].local); - td->ip += 5; - return TRUE; - } else if (!strcmp (tm, "AreSame")) { - *op = MINT_CEQ_P; - } else if (!strcmp (tm, "SkipInit")) { - *op = MINT_NOP; - } else if (!strcmp (tm, "InitBlockUnaligned")) { - *op = MINT_INITBLK; - } -#endif } else if (in_corlib && !strcmp (klass_name_space, "System.Runtime.CompilerServices") && !strcmp (klass_name, "RuntimeHelpers")) { -#ifdef ENABLE_NETCORE - if (!strcmp (tm, "get_OffsetToStringData")) { - g_assert (csignature->param_count == 0); - int offset = MONO_STRUCT_OFFSET (MonoString, chars); - interp_add_ins (td, MINT_LDC_I4); - WRITE32_INS (td->last_ins, 0, &offset); - push_simple_type (td, STACK_TYPE_I4); - interp_ins_set_dreg (td->last_ins, td->sp [-1].local); - td->ip += 5; - return TRUE; - } else if (!strcmp (tm, "GetRawData")) { - interp_add_ins (td, MINT_LDFLDA_UNSAFE); - td->last_ins->data [0] = (gint16) MONO_ABI_SIZEOF (MonoObject); - - td->sp--; - interp_ins_set_sreg (td->last_ins, td->sp [0].local); - push_simple_type (td, STACK_TYPE_MP); - interp_ins_set_dreg (td->last_ins, td->sp [-1].local); - - td->ip += 5; - return TRUE; - } else if (!strcmp (tm, "IsBitwiseEquatable")) { - g_assert (csignature->param_count == 0); - MonoGenericContext *ctx = mono_method_get_context (target_method); - g_assert (ctx); - g_assert (ctx->method_inst); - g_assert (ctx->method_inst->type_argc == 1); - MonoType *t = mini_get_underlying_type (ctx->method_inst->type_argv [0]); - - if (MONO_TYPE_IS_PRIMITIVE (t) && t->type != MONO_TYPE_R4 && t->type != MONO_TYPE_R8) - *op = MINT_LDC_I4_1; - else - *op = MINT_LDC_I4_0; - } else if (!strcmp (tm, "ObjectHasComponentSize")) { - *op = MINT_INTRINS_RUNTIMEHELPERS_OBJECT_HAS_COMPONENT_SIZE; - } else if (!strcmp (tm, "IsReferenceOrContainsReferences")) { - g_assert (csignature->param_count == 0); - MonoGenericContext *ctx = mono_method_get_context (target_method); - g_assert (ctx); - g_assert (ctx->method_inst); - g_assert (ctx->method_inst->type_argc == 1); - MonoType *t = mini_get_underlying_type (ctx->method_inst->type_argv [0]); - - gboolean has_refs; - - MonoClass *klass = mono_class_from_mono_type_internal (t); - mono_class_init_internal (klass); - if (MONO_TYPE_IS_REFERENCE (t)) - has_refs = TRUE; - else if (MONO_TYPE_IS_PRIMITIVE (t)) - has_refs = FALSE; - else - has_refs = m_class_has_references (klass); - - *op = has_refs ? MINT_LDC_I4_1 : MINT_LDC_I4_0; - } -#endif } else if (in_corlib && !strcmp (klass_name_space, "System") && !strcmp (klass_name, "RuntimeMethodHandle") && !strcmp (tm, "GetFunctionPointer") && csignature->param_count == 1) { // We must intrinsify this method on interp so we don't return a pointer to native code entering interpreter *op = MINT_LDFTN_DYNAMIC; @@ -2429,20 +2322,6 @@ interp_handle_intrinsics (TransformData *td, MonoMethod *target_method, MonoClas } } } -#ifdef ENABLE_NETCORE - else if (in_corlib && - !strcmp ("System.Runtime.CompilerServices", klass_name_space) && - !strcmp ("RuntimeFeature", klass_name)) { - if (!strcmp (tm, "get_IsDynamicCodeSupported")) - *op = MINT_LDC_I4_1; - else if (!strcmp (tm, "get_IsDynamicCodeCompiled")) - *op = MINT_LDC_I4_0; - } else if (in_corlib && - !strncmp ("System.Runtime.Intrinsics", klass_name_space, 25) && - !strcmp (tm, "get_IsSupported")) { - *op = MINT_LDC_I4_0; - } -#endif return FALSE; } @@ -3074,13 +2953,11 @@ interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target #endif } -#ifndef ENABLE_NETCORE if (op == MINT_CALLRUN) { interp_ins_set_dreg (td->last_ins, dreg); td->last_ins->data [0] = get_data_item_index (td, target_method); td->last_ins->data [1] = get_data_item_index (td, mono_method_signature_internal (target_method)); } -#endif } else if (!calli && !is_delegate_invoke && !is_virtual && mono_interp_jit_call_supported (target_method, csignature)) { interp_add_ins (td, MINT_JIT_CALL); interp_ins_set_dreg (td->last_ins, dreg); diff --git a/mono/mini/intrinsics.c b/mono/mini/intrinsics.c index c8b9d9249d2..f9151792977 100644 --- a/mono/mini/intrinsics.c +++ b/mono/mini/intrinsics.c @@ -569,21 +569,6 @@ emit_unsafe_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignatu ins->type = STACK_PTR; return ins; } -#ifdef ENABLE_NETCORE - else if (!strcmp (cmethod->name, "InitBlockUnaligned")) { - g_assert (fsig->param_count == 3); - - mini_emit_memory_init_bytes (cfg, args [0], args [1], args [2], MONO_INST_UNALIGNED); - MONO_INST_NEW (cfg, ins, OP_NOP); - MONO_ADD_INS (cfg->cbb, ins); - return ins; - } - else if (!strcmp (cmethod->name, "SkipInit")) { - MONO_INST_NEW (cfg, ins, OP_NOP); - MONO_ADD_INS (cfg->cbb, ins); - return ins; - } -#endif return NULL; } @@ -1926,57 +1911,6 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign } } -#ifdef ENABLE_NETCORE - // Return false for IsSupported for all types in System.Runtime.Intrinsics.* - // if it's not handled in mono_emit_simd_intrinsics - if (in_corlib && - !strncmp ("System.Runtime.Intrinsics", cmethod_klass_name_space, 25) && - !strcmp (cmethod->name, "get_IsSupported")) { - EMIT_NEW_ICONST (cfg, ins, 0); - ins->type = STACK_I4; - return ins; - } - - // Return false for RuntimeFeature.IsDynamicCodeSupported and RuntimeFeature.IsDynamicCodeCompiled on FullAOT, otherwise true - if (in_corlib && - !strcmp ("System.Runtime.CompilerServices", cmethod_klass_name_space) && - !strcmp ("RuntimeFeature", cmethod_klass_name)) { - if (!strcmp (cmethod->name, "get_IsDynamicCodeSupported") || !strcmp (cmethod->name, "get_IsDynamicCodeCompiled")) { - EMIT_NEW_ICONST (cfg, ins, cfg->full_aot ? 0 : 1); - ins->type = STACK_I4; - return ins; - } - } - - if (in_corlib && - !strcmp ("System", cmethod_klass_name_space) && - !strcmp ("ThrowHelper", cmethod_klass_name) && - !strcmp ("ThrowForUnsupportedVectorBaseType", cmethod->name)) { - /* The mono JIT can't optimize the body of this method away */ - MonoGenericContext *ctx = mono_method_get_context (cmethod); - g_assert (ctx); - g_assert (ctx->method_inst); - - MonoType *t = ctx->method_inst->type_argv [0]; - switch (t->type) { - case MONO_TYPE_I1: - case MONO_TYPE_U1: - case MONO_TYPE_I2: - case MONO_TYPE_U2: - case MONO_TYPE_I4: - case MONO_TYPE_U4: - case MONO_TYPE_I8: - case MONO_TYPE_U8: - case MONO_TYPE_R4: - case MONO_TYPE_R8: - MONO_INST_NEW (cfg, ins, OP_NOP); - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - break; - } - } -#endif ins = mono_emit_native_types_intrinsics (cfg, cmethod, fsig, args); if (ins) @@ -2112,7 +2046,6 @@ emit_array_unsafe_mov (MonoCompile *cfg, MonoMethodSignature *fsig, MonoInst **a return NULL; } -#ifndef ENABLE_NETCORE MonoInst* mini_emit_inst_for_sharable_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) { @@ -2127,7 +2060,6 @@ mini_emit_inst_for_sharable_method (MonoCompile *cfg, MonoMethod *cmethod, MonoM return NULL; } -#endif MonoInst* mini_emit_inst_for_field_load (MonoCompile *cfg, MonoClassField *field) @@ -2145,12 +2077,6 @@ mini_emit_inst_for_field_load (MonoCompile *cfg, MonoClassField *field) EMIT_NEW_ICONST (cfg, ins, is_le); return ins; } -#ifdef ENABLE_NETCORE - else if ((klass == mono_defaults.int_class || klass == mono_defaults.uint_class) && strcmp (field->name, "Zero") == 0) { - EMIT_NEW_PCONST (cfg, ins, 0); - return ins; - } -#endif return NULL; } #else diff --git a/mono/mini/jit-icalls.c b/mono/mini/jit-icalls.c index 29d13e32963..3104418350c 100644 --- a/mono/mini/jit-icalls.c +++ b/mono/mini/jit-icalls.c @@ -1420,19 +1420,6 @@ mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *kl gpointer this_arg; gpointer new_args [16]; -#ifdef ENABLE_NETCORE - /* Object.GetType () is an intrinsic under netcore */ - if (!mono_class_is_ginst (cmethod->klass) && !cmethod->is_inflated && !strcmp (cmethod->name, "GetType")) { - MonoVTable *vt; - - vt = mono_class_vtable_checked (mono_domain_get (), klass, error); - if (!is_ok (error)) { - mono_error_set_pending_exception (error); - return NULL; - } - return vt->type; - } -#endif m = constrained_gsharedvt_call_setup (mp, cmethod, klass, &this_arg, error); if (!is_ok (error)) { diff --git a/mono/mini/main-core.c b/mono/mini/main-core.c deleted file mode 100644 index 29f575fcf5d..00000000000 --- a/mono/mini/main-core.c +++ /dev/null @@ -1,126 +0,0 @@ -#include <config.h> -#include <mono/utils/mono-compiler.h> - -#if ENABLE_NETCORE - -#include "mini.h" -#include "mini-runtime.h" -#include <mono/metadata/assembly.h> -#include <mono/metadata/assembly-internals.h> -#include <mono/metadata/environment.h> -#include <mono/metadata/loader-internals.h> -#include <mono/mini/monovm.h> -#include <mono/utils/mono-logger-internals.h> - -#ifndef STDAPICALLTYPE -#define STDAPICALLTYPE -#endif - -#if defined(_MSC_VER) && defined(HOST_WIN32) && defined(HOST_X86) -// Ensure that the exported symbols are not decorated and that only one set is exported -#pragma comment(linker, "/export:coreclr_initialize=_coreclr_initialize@28") -#pragma comment(linker, "/export:coreclr_execute_assembly=_coreclr_execute_assembly@24") -#pragma comment(linker, "/export:coreclr_shutdown_2=_coreclr_shutdown_2@12") -#pragma comment(linker, "/export:coreclr_create_delegate=_coreclr_create_delegate@24") -#undef MONO_API -#define MONO_API MONO_EXTERN_C -#endif - -MONO_API int STDAPICALLTYPE coreclr_initialize (const char* exePath, const char* appDomainFriendlyName, - int propertyCount, const char** propertyKeys, const char** propertyValues, - void** hostHandle, unsigned int* domainId); - -MONO_API int STDAPICALLTYPE coreclr_execute_assembly (void* hostHandle, unsigned int domainId, - int argc, const char** argv, - const char* managedAssemblyPath, unsigned int* exitCode); - -MONO_API int STDAPICALLTYPE coreclr_shutdown_2 (void* hostHandle, unsigned int domainId, int* latchedExitCode); - -MONO_API int STDAPICALLTYPE coreclr_create_delegate (void* hostHandle, unsigned int domainId, - const char* entryPointAssemblyName, const char* entryPointTypeName, const char* entryPointMethodName, - void** delegate); - -// -// Initialize the CoreCLR. Creates and starts CoreCLR host and creates an app domain -// -// Parameters: -// exePath - Absolute path of the executable that invoked the ExecuteAssembly -// appDomainFriendlyName - Friendly name of the app domain that will be created to execute the assembly -// propertyCount - Number of properties (elements of the following two arguments) -// propertyKeys - Keys of properties of the app domain -// propertyValues - Values of properties of the app domain -// hostHandle - Output parameter, handle of the created host -// domainId - Output parameter, id of the created app domain -// -// Returns: -// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed -// -int STDAPICALLTYPE coreclr_initialize (const char* exePath, const char* appDomainFriendlyName, - int propertyCount, const char** propertyKeys, const char** propertyValues, - void** hostHandle, unsigned int* domainId) -{ - return monovm_initialize (propertyCount, propertyKeys, propertyValues); -} - -// -// Execute a managed assembly with given arguments -// -// Parameters: -// hostHandle - Handle of the host -// domainId - Id of the domain -// argc - Number of arguments passed to the executed assembly -// argv - Array of arguments passed to the executed assembly -// managedAssemblyPath - Path of the managed assembly to execute (or NULL if using a custom entrypoint). -// exitCode - Exit code returned by the executed assembly -// -// Returns: -// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed -// -int STDAPICALLTYPE coreclr_execute_assembly (void* hostHandle, unsigned int domainId, - int argc, const char** argv, - const char* managedAssemblyPath, unsigned int* exitCode) -{ - return monovm_execute_assembly (argc, argv, managedAssemblyPath, exitCode); -} - -// -// Shutdown CoreCLR. It unloads the app domain and stops the CoreCLR host. -// -// Parameters: -// hostHandle - Handle of the host -// domainId - Id of the domain -// latchedExitCode - Latched exit code after domain unloaded -// -// Returns: -// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed -// -int STDAPICALLTYPE coreclr_shutdown_2 (void* hostHandle, unsigned int domainId, int* latchedExitCode) -{ - return monovm_shutdown (latchedExitCode); -} - -// -// Create a native callable delegate for a managed method. -// -// Parameters: -// hostHandle - Handle of the host -// domainId - Id of the domain -// entryPointAssemblyName - Name of the assembly which holds the custom entry point -// entryPointTypeName - Name of the type which holds the custom entry point -// entryPointMethodName - Name of the method which is the custom entry point -// delegate - Output parameter, the function stores a pointer to the delegate at the specified address -// -// Returns: -// HRESULT indicating status of the operation. S_OK if the assembly was successfully executed -// -int STDAPICALLTYPE coreclr_create_delegate (void* hostHandle, unsigned int domainId, - const char* entryPointAssemblyName, const char* entryPointTypeName, const char* entryPointMethodName, - void** delegate) -{ - g_error ("Not implemented"); - return 0; -} -#else - -MONO_EMPTY_SOURCE_FILE (main_core); -#endif // ENABLE_NETCORE diff --git a/mono/mini/memory-access.c b/mono/mini/memory-access.c index b666d4c4e81..f65105085df 100644 --- a/mono/mini/memory-access.c +++ b/mono/mini/memory-access.c @@ -17,11 +17,7 @@ #include "ir-emit.h" #include "jit-icalls.h" -#ifdef ENABLE_NETCORE -#define MAX_INLINE_COPIES 16 -#else #define MAX_INLINE_COPIES 10 -#endif #define MAX_INLINE_COPY_SIZE 10000 void diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index aec34bf2000..0944915708b 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -97,11 +97,7 @@ * while the jit only sees one method, so we have to inline things ourselves. */ /* Used by LLVM AOT */ -#ifdef ENABLE_NETCORE -#define LLVM_AOT_INLINE_LENGTH_LIMIT 30 -#else #define LLVM_AOT_INLINE_LENGTH_LIMIT INLINE_LENGTH_LIMIT -#endif /* Used to LLVM JIT */ #define LLVM_JIT_INLINE_LENGTH_LIMIT 100 @@ -3495,21 +3491,6 @@ method_needs_stack_walk (MonoCompile *cfg, MonoMethod *cmethod) return TRUE; } -#if defined(ENABLE_NETCORE) - /* - * In corelib code, methods which need to do a stack walk declare a StackCrawlMark local and pass it as an - * arguments until it reaches an icall. Its hard to detect which methods do that especially with - * StackCrawlMark.LookForMyCallersCaller, so for now, just hardcode the classes which contain the public - * methods whose caller is needed. - */ - if (mono_is_corlib_image (m_class_get_image (cmethod->klass))) { - const char *cname = m_class_get_name (cmethod->klass); - if (!strcmp (cname, "Assembly") || - !strcmp (cname, "AssemblyLoadContext") || - (!strcmp (cname, "Activator"))) - return TRUE; - } -#endif return FALSE; } @@ -7498,7 +7479,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b if ((m_class_get_parent (cmethod->klass) == mono_defaults.multicastdelegate_class) && !strcmp (cmethod->name, "Invoke")) delegate_invoke = TRUE; -#ifndef ENABLE_NETCORE if ((cfg->opt & MONO_OPT_INTRINS) && (ins = mini_emit_inst_for_sharable_method (cfg, cmethod, fsig, sp))) { if (!MONO_TYPE_IS_VOID (fsig->ret)) { mini_type_to_eval_stack_type ((cfg), fsig->ret, ins); @@ -7509,7 +7489,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b mono_tailcall_print ("missed tailcall intrins_sharable %s -> %s\n", method->name, cmethod->name); goto call_end; } -#endif /* * Implement a workaround for the inherent races involved in locking: @@ -7748,11 +7727,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b } } -#ifdef ENABLE_NETCORE - if (save_last_error) { - mono_emit_jit_icall (cfg, mono_marshal_clear_last_error, NULL); - } -#endif /* Tail prefix / tailcall optimization */ @@ -9262,129 +9236,6 @@ calli_end: } } -#ifdef ENABLE_NETCORE - // Optimize - // - // box - // ldnull - // ceq (or cgt.un) - // - // to just - // - // ldc.i4.0 (or 1) - guchar* ldnull_ip; - if ((ldnull_ip = il_read_op (next_ip, end, CEE_LDNULL, MONO_CEE_LDNULL)) && ip_in_bb (cfg, cfg->cbb, ldnull_ip)) { - gboolean is_eq = FALSE, is_neq = FALSE; - if ((ip = il_read_op (ldnull_ip, end, CEE_PREFIX1, MONO_CEE_CEQ))) - is_eq = TRUE; - else if ((ip = il_read_op (ldnull_ip, end, CEE_PREFIX1, MONO_CEE_CGT_UN))) - is_neq = TRUE; - - if ((is_eq || is_neq) && ip_in_bb (cfg, cfg->cbb, ip) && - !mono_class_is_nullable (klass) && !mini_is_gsharedvt_klass (klass)) { - next_ip = ip; - il_op = (MonoOpcodeEnum) (is_eq ? CEE_LDC_I4_0 : CEE_LDC_I4_1); - EMIT_NEW_ICONST (cfg, ins, is_eq ? 0 : 1); - ins->type = STACK_I4; - *sp++ = ins; - break; - } - } - - guint32 isinst_tk = 0; - if ((ip = il_read_op_and_token (next_ip, end, CEE_ISINST, MONO_CEE_ISINST, &isinst_tk)) && - ip_in_bb (cfg, cfg->cbb, ip)) { - MonoClass *isinst_class = mini_get_class (method, isinst_tk, generic_context); - if (!mono_class_is_nullable (klass) && !mono_class_is_nullable (isinst_class) && - !mini_is_gsharedvt_variable_klass (klass) && !mini_is_gsharedvt_variable_klass (isinst_class) && - !mono_class_is_open_constructed_type (m_class_get_byval_arg (klass)) && - !mono_class_is_open_constructed_type (m_class_get_byval_arg (isinst_class))) { - - // Optimize - // - // box - // isinst [Type] - // brfalse/brtrue - // - // to - // - // ldc.i4.0 (or 1) - // brfalse/brtrue - // - guchar* br_ip = NULL; - if ((br_ip = il_read_brtrue (ip, end, &target)) || (br_ip = il_read_brtrue_s (ip, end, &target)) || - (br_ip = il_read_brfalse (ip, end, &target)) || (br_ip = il_read_brfalse_s (ip, end, &target))) { - - gboolean isinst = mono_class_is_assignable_from_internal (isinst_class, klass); - next_ip = ip; - il_op = (MonoOpcodeEnum) (isinst ? CEE_LDC_I4_1 : CEE_LDC_I4_0); - EMIT_NEW_ICONST (cfg, ins, isinst ? 1 : 0); - ins->type = STACK_I4; - *sp++ = ins; - break; - } - - // Optimize - // - // box - // isinst [Type] - // ldnull - // ceq/cgt.un - // - // to - // - // ldc.i4.0 (or 1) - // - guchar* ldnull_ip = NULL; - if ((ldnull_ip = il_read_op (ip, end, CEE_LDNULL, MONO_CEE_LDNULL)) && ip_in_bb (cfg, cfg->cbb, ldnull_ip)) { - gboolean is_eq = FALSE, is_neq = FALSE; - if ((ip = il_read_op (ldnull_ip, end, CEE_PREFIX1, MONO_CEE_CEQ))) - is_eq = TRUE; - else if ((ip = il_read_op (ldnull_ip, end, CEE_PREFIX1, MONO_CEE_CGT_UN))) - is_neq = TRUE; - - if ((is_eq || is_neq) && ip_in_bb (cfg, cfg->cbb, ip) && - !mono_class_is_nullable (klass) && !mini_is_gsharedvt_klass (klass)) { - gboolean isinst = mono_class_is_assignable_from_internal (isinst_class, klass); - next_ip = ip; - if (is_eq) - isinst = !isinst; - il_op = (MonoOpcodeEnum) (isinst ? CEE_LDC_I4_1 : CEE_LDC_I4_0); - EMIT_NEW_ICONST (cfg, ins, isinst ? 1 : 0); - ins->type = STACK_I4; - *sp++ = ins; - break; - } - } - - // Optimize - // - // box - // isinst [Type] - // unbox.any - // - // to - // - // nop - // - guchar* unbox_ip = NULL; - guint32 unbox_token = 0; - if ((unbox_ip = il_read_unbox_any (ip, end, &unbox_token)) && ip_in_bb (cfg, cfg->cbb, unbox_ip)) { - MonoClass *unbox_klass = mini_get_class (method, unbox_token, generic_context); - CHECK_TYPELOAD (unbox_klass); - if (!mono_class_is_nullable (unbox_klass) && - !mini_is_gsharedvt_klass (unbox_klass) && - klass == isinst_class && - klass == unbox_klass) - { - *sp++ = val; - next_ip = unbox_ip; - break; - } - } - } - } -#endif gboolean is_true; diff --git a/mono/mini/mini-arm64.h b/mono/mini/mini-arm64.h index 244857326b2..69a67986337 100644 --- a/mono/mini/mini-arm64.h +++ b/mono/mini/mini-arm64.h @@ -21,9 +21,6 @@ #define MONO_MAX_FREGS 32 #define MONO_MAX_XREGS 32 -#if !defined(DISABLE_SIMD) && defined(ENABLE_NETCORE) -#define MONO_ARCH_SIMD_INTRINSICS 1 -#endif #define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->regs [0] = (gsize)exc; } while (0) diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index e0f4f1d094e..144a61ad654 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -2722,9 +2722,6 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu MONO_PROFILER_RAISE (exception_throw, (obj)); jit_tls->orig_ex_ctx_set = FALSE; -#ifdef ENABLE_NETCORE - mono_first_chance_exception_internal (obj); -#endif StackFrameInfo catch_frame; MonoFirstPassResult res; @@ -2754,12 +2751,10 @@ mono_handle_exception_internal (MonoContext *ctx, MonoObject *obj, gboolean resu * FIXME: The check below is hackish, but its hard to distinguish * these runtime invoke calls from others in the runtime. */ -#ifndef ENABLE_NETCORE if (ji && jinfo_get_method (ji)->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE) { if (prev_ji && jinfo_get_method (prev_ji) == mono_defaults.threadpool_perform_wait_callback_method) unhandled = TRUE; } -#endif if (unhandled) mini_get_dbg_callbacks ()->handle_exception ((MonoException *)obj, ctx, NULL, NULL); diff --git a/mono/mini/mini-llvm-cpp.cpp b/mono/mini/mini-llvm-cpp.cpp index 7240b067bdf..fab42463c93 100644 --- a/mono/mini/mini-llvm-cpp.cpp +++ b/mono/mini/mini-llvm-cpp.cpp @@ -323,22 +323,6 @@ mono_llvm_set_func_nonnull_arg (LLVMValueRef func, int argNo) gboolean mono_llvm_can_be_gep (LLVMValueRef base, LLVMValueRef* gep_base, LLVMValueRef* gep_offset) { -#ifdef ENABLE_NETCORE - // Look for a pattern like this: - // %1 = ptrtoint i8* %gep_base to i64 - // %2 = add i64 %1, %gep_offset - if (Instruction *base_inst = dyn_cast<Instruction> (unwrap (base))) { - if (base_inst->getOpcode () == Instruction::Add) { - if (Instruction *base_ptr_ins = dyn_cast<Instruction> (base_inst->getOperand (0))) { - if (base_ptr_ins->getOpcode () == Instruction::PtrToInt) { - *gep_base = wrap (base_ptr_ins->getOperand (0)); - *gep_offset = wrap (base_inst->getOperand (1)); - return TRUE; - } - } - } - } -#endif return FALSE; } diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 29658abd89d..c29cf857a60 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -3730,11 +3730,6 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) case LLVMArgVtypeInReg: case LLVMArgVtypeByVal: case LLVMArgAsIArgs: -#ifdef ENABLE_NETCORE - // FIXME: Enabling this fails on windows - case LLVMArgVtypeAddr: - case LLVMArgVtypeByRef: -#endif { if (MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type_internal (ainfo->type))) /* Treat these as normal values */ @@ -6986,11 +6981,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMValueRef mask [32], v; int i; -#ifdef ENABLE_NETCORE - t = simd_class_to_llvm_type (ctx, ins->klass); -#else t = simd_op_to_llvm_type (ins->opcode); -#endif for (i = 0; i < 32; ++i) mask [i] = LLVMConstInt (LLVMInt32Type (), 0, FALSE); @@ -8794,369 +8785,10 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) } #endif -#ifdef ENABLE_NETCORE - case OP_XCAST: { - LLVMTypeRef t = simd_class_to_llvm_type (ctx, ins->klass); - - values [ins->dreg] = LLVMBuildBitCast (builder, lhs, t, ""); - break; - } - case OP_XCOMPARE_FP: { - LLVMRealPredicate pred = fpcond_to_llvm_cond [ins->inst_c0]; - LLVMValueRef cmp = LLVMBuildFCmp (builder, pred, lhs, rhs, ""); - int nelems = LLVMGetVectorSize (LLVMTypeOf (cmp)); - g_assert (LLVMTypeOf (lhs) == LLVMTypeOf (rhs)); - if (ins->inst_c1 == MONO_TYPE_R8) - values [ins->dreg] = LLVMBuildBitCast (builder, LLVMBuildSExt (builder, cmp, LLVMVectorType (LLVMInt64Type (), nelems), ""), LLVMTypeOf (lhs), ""); - else - values [ins->dreg] = LLVMBuildBitCast (builder, LLVMBuildSExt (builder, cmp, LLVMVectorType (LLVMInt32Type (), nelems), ""), LLVMTypeOf (lhs), ""); - break; - } - case OP_XCOMPARE: { - LLVMIntPredicate pred = cond_to_llvm_cond [ins->inst_c0]; - LLVMValueRef cmp = LLVMBuildICmp (builder, pred, lhs, rhs, ""); - g_assert (LLVMTypeOf (lhs) == LLVMTypeOf (rhs)); - values [ins->dreg] = LLVMBuildSExt (builder, cmp, LLVMTypeOf (lhs), ""); - break; - } - case OP_XEQUAL: { - LLVMTypeRef t; - LLVMValueRef cmp, mask [32], shuffle; - int nelems; - -#if defined(TARGET_WASM) && LLVM_API_VERSION >= 800 - /* The wasm code generator doesn't understand the shuffle/and code sequence below */ - LLVMValueRef val; - if (LLVMIsNull (lhs) || LLVMIsNull (rhs)) { - val = LLVMIsNull (lhs) ? rhs : lhs; - nelems = LLVMGetVectorSize (LLVMTypeOf (lhs)); - - IntrinsicId intrins = (IntrinsicId)0; - switch (nelems) { - case 16: - intrins = INTRINS_WASM_ANYTRUE_V16; - break; - case 8: - intrins = INTRINS_WASM_ANYTRUE_V8; - break; - case 4: - intrins = INTRINS_WASM_ANYTRUE_V4; - break; - case 2: - intrins = INTRINS_WASM_ANYTRUE_V2; - break; - default: - g_assert_not_reached (); - } - /* res = !wasm.anytrue (val) */ - values [ins->dreg] = call_intrins (ctx, intrins, &val, ""); - values [ins->dreg] = LLVMBuildZExt (builder, LLVMBuildICmp (builder, LLVMIntEQ, values [ins->dreg], LLVMConstInt (LLVMInt32Type (), 0, FALSE), ""), LLVMInt32Type (), dname); - break; - } -#endif - LLVMTypeRef srcelemt = LLVMGetElementType (LLVMTypeOf (lhs)); - - //%c = icmp sgt <16 x i8> %a0, %a1 - if (srcelemt == LLVMDoubleType () || srcelemt == LLVMFloatType ()) - cmp = LLVMBuildFCmp (builder, LLVMRealOEQ, lhs, rhs, ""); - else - cmp = LLVMBuildICmp (builder, LLVMIntEQ, lhs, rhs, ""); - nelems = LLVMGetVectorSize (LLVMTypeOf (cmp)); - - LLVMTypeRef elemt; - if (srcelemt == LLVMDoubleType ()) - elemt = LLVMInt64Type (); - else if (srcelemt == LLVMFloatType ()) - elemt = LLVMInt32Type (); - else - elemt = srcelemt; - - t = LLVMVectorType (elemt, nelems); - cmp = LLVMBuildSExt (builder, cmp, t, ""); - // cmp is a <nelems x elemt> vector, each element is either 0xff... or 0 - int half = nelems / 2; - while (half >= 1) { - // AND the top and bottom halfes into the bottom half - for (int i = 0; i < half; ++i) - mask [i] = LLVMConstInt (LLVMInt32Type (), half + i, FALSE); - for (int i = half; i < nelems; ++i) - mask [i] = LLVMConstInt (LLVMInt32Type (), 0, FALSE); - shuffle = LLVMBuildShuffleVector (builder, cmp, LLVMGetUndef (t), LLVMConstVector (mask, LLVMGetVectorSize (t)), ""); - cmp = LLVMBuildAnd (builder, cmp, shuffle, ""); - half = half / 2; - } - // Extract [0] - LLVMValueRef first_elem = LLVMBuildExtractElement (builder, cmp, LLVMConstInt (LLVMInt32Type (), 0, FALSE), ""); - // convert to 0/1 - LLVMValueRef cmp_zero = LLVMBuildICmp (builder, LLVMIntNE, first_elem, LLVMConstInt (elemt, 0, FALSE), ""); - values [ins->dreg] = LLVMBuildZExt (builder, cmp_zero, LLVMInt8Type (), ""); - break; - } - case OP_XBINOP: { - switch (ins->inst_c0) { - case OP_IADD: - values [ins->dreg] = LLVMBuildAdd (builder, lhs, rhs, ""); - break; - case OP_ISUB: - values [ins->dreg] = LLVMBuildSub (builder, lhs, rhs, ""); - break; - case OP_IAND: - values [ins->dreg] = LLVMBuildAnd (builder, lhs, rhs, ""); - break; - case OP_IOR: - values [ins->dreg] = LLVMBuildOr (builder, lhs, rhs, ""); - break; - case OP_IXOR: - values [ins->dreg] = LLVMBuildXor (builder, lhs, rhs, ""); - break; - case OP_FADD: - values [ins->dreg] = LLVMBuildFAdd (builder, lhs, rhs, ""); - break; - case OP_FSUB: - values [ins->dreg] = LLVMBuildFSub (builder, lhs, rhs, ""); - break; - case OP_FMUL: - values [ins->dreg] = LLVMBuildFMul (builder, lhs, rhs, ""); - break; - case OP_FDIV: - values [ins->dreg] = LLVMBuildFDiv (builder, lhs, rhs, ""); - break; - case OP_FMAX: - case OP_FMIN: { -#if defined(TARGET_X86) || defined(TARGET_AMD64) - LLVMValueRef args [] = { lhs, rhs }; - - gboolean is_r4 = ins->inst_c1 == MONO_TYPE_R4; - if (ins->inst_c0 == OP_FMAX) - values [ins->dreg] = call_intrins (ctx, is_r4 ? INTRINS_SSE_MAXPS : INTRINS_SSE_MAXPD, args, dname); - else - values [ins->dreg] = call_intrins (ctx, is_r4 ? INTRINS_SSE_MINPS : INTRINS_SSE_MINPD, args, dname); -#else - NOT_IMPLEMENTED; -#endif - break; - } - case OP_IMAX: { - gboolean is_unsigned = ins->inst_c1 == MONO_TYPE_U1 || ins->inst_c1 == MONO_TYPE_U2 || ins->inst_c1 == MONO_TYPE_U4 || ins->inst_c1 == MONO_TYPE_U8; - LLVMValueRef cmp = LLVMBuildICmp (builder, is_unsigned ? LLVMIntUGT : LLVMIntSGT, lhs, rhs, ""); - values [ins->dreg] = LLVMBuildSelect (builder, cmp, lhs, rhs, ""); - break; - } - case OP_IMIN: { - gboolean is_unsigned = ins->inst_c1 == MONO_TYPE_U1 || ins->inst_c1 == MONO_TYPE_U2 || ins->inst_c1 == MONO_TYPE_U4 || ins->inst_c1 == MONO_TYPE_U8; - LLVMValueRef cmp = LLVMBuildICmp (builder, is_unsigned ? LLVMIntULT : LLVMIntSLT, lhs, rhs, ""); - values [ins->dreg] = LLVMBuildSelect (builder, cmp, lhs, rhs, ""); - } - break; - - default: - g_assert_not_reached (); - } - break; - } - case OP_XEXTRACT_I32: - case OP_XEXTRACT_I64: - case OP_XEXTRACT_R8: - case OP_XEXTRACT_R4: { - LLVMTypeRef rhst = LLVMTypeOf (rhs); - LLVMValueRef mask = NULL; - switch (ins->opcode) { - case OP_XEXTRACT_I32: case OP_XEXTRACT_R4: - mask = LLVMConstInt (rhst, 0x3, FALSE); break; - case OP_XEXTRACT_I64: case OP_XEXTRACT_R8: - mask = LLVMConstInt (rhst, 0x1, FALSE); break; - default: - g_assert_not_reached (); - } - LLVMValueRef selector = LLVMBuildAnd (builder, rhs, mask, ""); - values [ins->dreg] = LLVMBuildExtractElement (builder, lhs, selector, ""); - break; - } - case OP_POPCNT32: - values [ins->dreg] = call_intrins (ctx, INTRINS_CTPOP_I32, &lhs, ""); - break; - case OP_POPCNT64: - values [ins->dreg] = call_intrins (ctx, INTRINS_CTPOP_I64, &lhs, ""); - break; - case OP_CTTZ32: - case OP_CTTZ64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = LLVMConstInt (LLVMInt1Type (), 0, FALSE); - values [ins->dreg] = call_intrins (ctx, ins->opcode == OP_CTTZ32 ? INTRINS_CTTZ_I32 : INTRINS_CTTZ_I64, args, ""); - break; - } - case OP_BEXTR32: - case OP_BEXTR64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = convert (ctx, rhs, ins->opcode == OP_BEXTR32 ? LLVMInt32Type () : LLVMInt64Type ()); // cast ushort to u32/u64 - values [ins->dreg] = call_intrins (ctx, ins->opcode == OP_BEXTR32 ? INTRINS_BEXTR_I32 : INTRINS_BEXTR_I64, args, ""); - break; - } - case OP_BZHI32: - case OP_BZHI64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = rhs; - values [ins->dreg] = call_intrins (ctx, ins->opcode == OP_BZHI32 ? INTRINS_BZHI_I32 : INTRINS_BZHI_I64, args, ""); - break; - } - case OP_MULX_H32: - case OP_MULX_H64: - case OP_MULX_HL32: - case OP_MULX_HL64: { - gboolean is_64 = ins->opcode == OP_MULX_H64 || ins->opcode == OP_MULX_HL64; - gboolean only_high = ins->opcode == OP_MULX_H32 || ins->opcode == OP_MULX_H64; - LLVMValueRef lx = LLVMBuildZExt (ctx->builder, lhs, LLVMInt128Type (), ""); - LLVMValueRef rx = LLVMBuildZExt (ctx->builder, rhs, LLVMInt128Type (), ""); - LLVMValueRef mulx = LLVMBuildMul (ctx->builder, lx, rx, ""); - if (!only_high) { - LLVMValueRef lowx = LLVMBuildTrunc (ctx->builder, mulx, is_64 ? LLVMInt64Type () : LLVMInt32Type (), ""); - LLVMBuildStore (ctx->builder, lowx, values [ins->sreg3]); - } - LLVMValueRef shift = LLVMConstInt (LLVMInt128Type (), is_64 ? 64 : 32, FALSE); - LLVMValueRef highx = LLVMBuildLShr (ctx->builder, mulx, shift, ""); - values [ins->dreg] = LLVMBuildTrunc (ctx->builder, highx, is_64 ? LLVMInt64Type () : LLVMInt32Type (), ""); - break; - } - case OP_PEXT32: - case OP_PEXT64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = rhs; - values [ins->dreg] = call_intrins (ctx, ins->opcode == OP_PEXT32 ? INTRINS_PEXT_I32 : INTRINS_PEXT_I64, args, ""); - break; - } - case OP_PDEP32: - case OP_PDEP64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = rhs; - values [ins->dreg] = call_intrins (ctx, ins->opcode == OP_PDEP32 ? INTRINS_PDEP_I32 : INTRINS_PDEP_I64, args, ""); - break; - } -#endif /* ENABLE_NETCORE */ #endif /* defined(TARGET_X86) || defined(TARGET_AMD64) */ // Shared between ARM64 and X86 -#if defined(ENABLE_NETCORE) && (defined(TARGET_ARM64) || defined(TARGET_X86) || defined(TARGET_AMD64)) - case OP_LZCNT32: - case OP_LZCNT64: { - LLVMValueRef args [2]; - args [0] = lhs; - args [1] = LLVMConstInt (LLVMInt1Type (), 1, FALSE); - values [ins->dreg] = LLVMBuildCall (builder, get_intrins (ctx, ins->opcode == OP_LZCNT32 ? INTRINS_CTLZ_I32 : INTRINS_CTLZ_I64), args, 2, ""); - break; - } -#endif - -#if defined(ENABLE_NETCORE) && defined(TARGET_ARM64) - case OP_XOP_I4_I4: - case OP_XOP_I8_I8: { - IntrinsicId id = (IntrinsicId)0; - switch (ins->inst_c0) { - case SIMD_OP_ARM64_RBIT32: id = INTRINS_BITREVERSE_I32; break; - case SIMD_OP_ARM64_RBIT64: id = INTRINS_BITREVERSE_I64; break; - default: g_assert_not_reached (); break; - } - values [ins->dreg] = call_intrins (ctx, id, &lhs, ""); - break; - } - case OP_XOP_X_X_X: - case OP_XOP_I4_I4_I4: - case OP_XOP_I4_I4_I8: { - IntrinsicId id = (IntrinsicId)0; - gboolean zext_last = FALSE; - switch (ins->inst_c0) { - case SIMD_OP_ARM64_CRC32B: id = INTRINS_AARCH64_CRC32B; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32H: id = INTRINS_AARCH64_CRC32H; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32W: id = INTRINS_AARCH64_CRC32W; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32X: id = INTRINS_AARCH64_CRC32X; break; - case SIMD_OP_ARM64_CRC32CB: id = INTRINS_AARCH64_CRC32CB; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32CH: id = INTRINS_AARCH64_CRC32CH; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32CW: id = INTRINS_AARCH64_CRC32CW; zext_last = TRUE; break; - case SIMD_OP_ARM64_CRC32CX: id = INTRINS_AARCH64_CRC32CX; break; - case SIMD_OP_ARM64_SHA1SU1: id = INTRINS_AARCH64_SHA1SU1; break; - case SIMD_OP_ARM64_SHA256SU0: id = INTRINS_AARCH64_SHA256SU0; break; - default: g_assert_not_reached (); break; - } - LLVMValueRef arg1 = rhs; - if (zext_last) - arg1 = LLVMBuildZExt (ctx->builder, arg1, LLVMInt32Type (), ""); - LLVMValueRef args [] = { lhs, arg1 }; - values [ins->dreg] = call_intrins (ctx, id, args, ""); - break; - } - case OP_XOP_X_X_X_X: { - IntrinsicId id = (IntrinsicId)0; - switch (ins->inst_c0) { - case SIMD_OP_ARM64_SHA1SU0: id = INTRINS_AARCH64_SHA1SU0; break; - case SIMD_OP_ARM64_SHA256H: id = INTRINS_AARCH64_SHA256H; break; - case SIMD_OP_ARM64_SHA256H2: id = INTRINS_AARCH64_SHA256H2; break; - case SIMD_OP_ARM64_SHA256SU1: id = INTRINS_AARCH64_SHA256SU1; break; - default: g_assert_not_reached (); break; - } - LLVMValueRef args [] = { lhs, rhs, arg3 }; - values [ins->dreg] = call_intrins (ctx, id, args, ""); - break; - } - case OP_XOP_X_X: { - IntrinsicId id = (IntrinsicId)0; - switch (ins->inst_c0) { - case SIMD_OP_LLVM_FABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_FLOAT; break; - case SIMD_OP_LLVM_DABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_DOUBLE; break; - case SIMD_OP_LLVM_I8ABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_INT8; break; - case SIMD_OP_LLVM_I16ABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_INT16; break; - case SIMD_OP_LLVM_I32ABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_INT32; break; - case SIMD_OP_LLVM_I64ABS: id = INTRINS_AARCH64_ADV_SIMD_ABS_INT64; break; - default: g_assert_not_reached (); break; - } - LLVMValueRef arg0 = lhs; - values [ins->dreg] = call_intrins (ctx, id, &arg0, ""); - break; - } - case OP_LSCNT32: - case OP_LSCNT64: { - // %shr = ashr i32 %x, 31 - // %xor = xor i32 %shr, %x - // %mul = shl i32 %xor, 1 - // %add = or i32 %mul, 1 - // %0 = tail call i32 @llvm.ctlz.i32(i32 %add, i1 false) - LLVMValueRef shr = LLVMBuildAShr (builder, lhs, ins->opcode == OP_LSCNT32 ? - LLVMConstInt (LLVMInt32Type (), 31, FALSE) : - LLVMConstInt (LLVMInt64Type (), 63, FALSE), ""); - LLVMValueRef one = ins->opcode == OP_LSCNT32 ? - LLVMConstInt (LLVMInt32Type (), 1, FALSE) : - LLVMConstInt (LLVMInt64Type (), 1, FALSE); - LLVMValueRef xor = LLVMBuildXor (builder, shr, lhs, ""); - LLVMValueRef mul = LLVMBuildShl (builder, xor, one, ""); - LLVMValueRef add = LLVMBuildOr (builder, mul, one, ""); - - LLVMValueRef args [2]; - args [0] = add; - args [1] = LLVMConstInt (LLVMInt1Type (), 0, FALSE); - values [ins->dreg] = LLVMBuildCall (builder, get_intrins (ctx, ins->opcode == OP_LSCNT32 ? INTRINS_CTLZ_I32 : INTRINS_CTLZ_I64), args, 2, ""); - break; - } - case OP_ARM64_SMULH: - case OP_ARM64_UMULH: { - LLVMValueRef op1, op2; - if (ins->opcode == OP_ARM64_SMULH) { - op1 = LLVMBuildSExt (builder, lhs, LLVMInt128Type (), ""); - op2 = LLVMBuildSExt (builder, rhs, LLVMInt128Type (), ""); - } else { - op1 = LLVMBuildZExt (builder, lhs, LLVMInt128Type (), ""); - op2 = LLVMBuildZExt (builder, rhs, LLVMInt128Type (), ""); - } - LLVMValueRef mul = LLVMBuildMul (builder, op1, op2, ""); - LLVMValueRef hi64 = LLVMBuildLShr (builder, mul, - LLVMConstInt (LLVMInt128Type (), 64, FALSE), ""); - values [ins->dreg] = LLVMBuildTrunc (builder, hi64, LLVMInt64Type (), ""); - break; - } -#endif case OP_DUMMY_USE: break; diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index e9c4914a0e2..b8df86ea538 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -85,9 +85,7 @@ #include <string.h> #include <ctype.h> #include "trace.h" -#ifndef ENABLE_NETCORE #include "version.h" -#endif #include "aot-compiler.h" #include "aot-runtime.h" #include "llvmonly-runtime.h" @@ -393,7 +391,6 @@ gboolean mono_method_same_domain (MonoJitInfo *caller, MonoJitInfo *callee) if (caller->domain_neutral && !callee->domain_neutral) return FALSE; -#ifndef ENABLE_NETCORE MonoMethod *cmethod; cmethod = jinfo_get_method (caller); @@ -402,7 +399,6 @@ gboolean mono_method_same_domain (MonoJitInfo *caller, MonoJitInfo *callee) /* The InvokeInDomain methods change the current appdomain */ return FALSE; } -#endif return TRUE; } @@ -4639,9 +4635,7 @@ mini_init (const char *filename, const char *runtime_version) mono_simd_intrinsics_init (); #endif -#ifndef ENABLE_NETCORE mono_tasklets_init (); -#endif register_trampolines (domain); @@ -5088,9 +5082,7 @@ mini_cleanup (MonoDomain *domain) mono_runtime_cleanup (domain); #endif -#ifndef ENABLE_NETCORE mono_threadpool_cleanup (); -#endif MONO_PROFILER_RAISE (runtime_shutdown_end, ()); diff --git a/mono/mini/mini-runtime.h b/mono/mini/mini-runtime.h index 52adc272c8f..15b7a033639 100644 --- a/mono/mini/mini-runtime.h +++ b/mono/mini/mini-runtime.h @@ -273,9 +273,6 @@ typedef struct MonoDebugOptions { */ gboolean top_runtime_invoke_unhandled; -#ifdef ENABLE_NETCORE - gboolean enabled; -#endif } MonoDebugOptions; /* diff --git a/mono/mini/mini-wasm.c b/mono/mini/mini-wasm.c index f8d3e1855be..76407a82d1c 100644 --- a/mono/mini/mini-wasm.c +++ b/mono/mini/mini-wasm.c @@ -545,11 +545,7 @@ mono_set_timeout_exec (int id) { ERROR_DECL (error); -#ifdef ENABLE_NETCORE - MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System.Threading", "TimerQueue"); -#else MonoClass *klass = mono_class_load_from_name (mono_defaults.corlib, "System.Threading", "WasmRuntime"); -#endif g_assert (klass); MonoMethod *method = mono_class_get_method_from_name_checked (klass, "TimeoutCallback", -1, 0, error); @@ -625,13 +621,8 @@ void mono_arch_register_icall (void) { #ifdef HOST_WASM -#ifdef ENABLE_NETCORE - mono_add_internal_call_internal ("System.Threading.TimerQueue::SetTimeout", mono_wasm_set_timeout); - mono_add_internal_call_internal ("System.Threading.ThreadPool::QueueCallback", mono_wasm_queue_tp_cb); -#else mono_add_internal_call_internal ("System.Threading.WasmRuntime::SetTimeout", mono_wasm_set_timeout); #endif -#endif } void diff --git a/mono/mini/mini-wasm.h b/mono/mini/mini-wasm.h index 57c73a4bc9a..1026fad0c2a 100644 --- a/mono/mini/mini-wasm.h +++ b/mono/mini/mini-wasm.h @@ -89,9 +89,6 @@ typedef struct { #define MONO_ARCH_GSHAREDVT_SUPPORTED 1 #define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1 -#ifdef ENABLE_NETCORE -#define MONO_ARCH_SIMD_INTRINSICS 1 -#endif #define MONO_ARCH_INTERPRETER_SUPPORTED 1 #define MONO_ARCH_HAS_REGISTER_ICALL 1 diff --git a/mono/mini/mini-x86.h b/mono/mini/mini-x86.h index 6d44cb5f2bf..991756ad8e1 100644 --- a/mono/mini/mini-x86.h +++ b/mono/mini/mini-x86.h @@ -65,11 +65,9 @@ LONG CALLBACK seh_handler(EXCEPTION_POINTERS* ep); #define MONO_ARCH_SUPPORT_TASKLETS 1 #ifndef DISABLE_SIMD -#ifndef ENABLE_NETCORE #define MONO_ARCH_SIMD_INTRINSICS 1 #define MONO_ARCH_NEED_SIMD_BANK 1 #endif -#endif /* we should lower this size and make sure we don't call heavy stack users in the segv handler */ #if defined(__APPLE__) diff --git a/mono/mini/mini.c b/mono/mini/mini.c index d12f3b07ed7..495babcd607 100644 --- a/mono/mini/mini.c +++ b/mono/mini/mini.c @@ -753,15 +753,6 @@ mono_compile_create_var (MonoCompile *cfg, MonoType *type, int opcode) { int dreg; -#ifdef ENABLE_NETCORE - if (type->type == MONO_TYPE_VALUETYPE && !type->byref) { - MonoClass *klass = mono_class_from_mono_type_internal (type); - if (m_class_is_enumtype (klass) && m_class_get_image (klass) == mono_get_corlib () && !strcmp (m_class_get_name (klass), "StackCrawlMark")) { - if (!(cfg->method->flags & METHOD_ATTRIBUTE_REQSECOBJ)) - g_error ("Method '%s' which contains a StackCrawlMark local variable must be decorated with [System.Security.DynamicSecurityMethod].", mono_method_get_full_name (cfg->method)); - } - } -#endif type = mini_get_underlying_type (type); diff --git a/mono/mini/mini.h b/mono/mini/mini.h index 0dba272e692..4cb01fc09f2 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -2285,9 +2285,7 @@ void mini_emit_memory_copy (MonoCompile *cfg, MonoInst *dest, MonoI MonoInst* mini_emit_array_store (MonoCompile *cfg, MonoClass *klass, MonoInst **sp, gboolean safety_checks); MonoInst* mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args); MonoInst* mini_emit_inst_for_ctor (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args); -#ifndef ENABLE_NETCORE MonoInst* mini_emit_inst_for_sharable_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args); -#endif MonoInst* mini_emit_inst_for_field_load (MonoCompile *cfg, MonoClassField *field); MonoInst* mini_handle_enum_has_flag (MonoCompile *cfg, MonoClass *klass, MonoInst *enum_this, int enum_val_reg, MonoInst *enum_flag); diff --git a/mono/mini/monovm.c b/mono/mini/monovm.c index bbde28cce1b..91f0f78f8ae 100644 --- a/mono/mini/monovm.c +++ b/mono/mini/monovm.c @@ -2,277 +2,6 @@ #include <mono/utils/mono-compiler.h> #include "monovm.h" -#if ENABLE_NETCORE - -#include <mono/metadata/assembly-internals.h> -#include <mono/metadata/assembly.h> -#include <mono/metadata/environment.h> -#include <mono/metadata/loader-internals.h> -#include <mono/metadata/native-library.h> -#include <mono/mini/mini-runtime.h> -#include <mono/mini/mini.h> -#include <mono/utils/mono-logger-internals.h> - -typedef struct { - int assembly_count; - char **basenames; /* Foo.dll */ - int *basename_lens; - char **assembly_filepaths; /* /blah/blah/blah/Foo.dll */ -} MonoCoreTrustedPlatformAssemblies; - -typedef struct { - int dir_count; - char **dirs; -} MonoCoreLookupPaths; - -static MonoCoreTrustedPlatformAssemblies *trusted_platform_assemblies; -static MonoCoreLookupPaths *native_lib_paths; -static MonoCoreLookupPaths *app_paths; -static MonoCoreLookupPaths *app_ni_paths; -static MonoCoreLookupPaths *platform_resource_roots; - -static void -mono_core_trusted_platform_assemblies_free (MonoCoreTrustedPlatformAssemblies *a) -{ - if (!a) - return; - g_strfreev (a->basenames); - g_strfreev (a->assembly_filepaths); - g_free (a); -} - -static void -mono_core_lookup_paths_free (MonoCoreLookupPaths *dl) -{ - if (!dl) - return; - g_strfreev (dl->dirs); - g_free (dl); -} - -static gboolean -parse_trusted_platform_assemblies (const char *assemblies_paths) -{ - // From - // https://docs.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting#step-3---prepare-runtime-properties - // this is ';' separated on Windows and ':' separated elsewhere. - char **parts = g_strsplit (assemblies_paths, G_SEARCHPATH_SEPARATOR_S, 0); - int asm_count = 0; - for (char **p = parts; *p != NULL && **p != '\0'; p++) { -#if 0 - const char *part = *p; - // can't use logger, it's not initialized yet. - printf ("\t\tassembly %d = <%s>\n", asm_count, part); -#endif - asm_count++; - } - MonoCoreTrustedPlatformAssemblies *a = g_new0 (MonoCoreTrustedPlatformAssemblies, 1); - a->assembly_count = asm_count; - a->assembly_filepaths = parts; - a->basenames = g_new0 (char*, asm_count + 1); - a->basename_lens = g_new0 (int, asm_count + 1); - for (int i = 0; i < asm_count; ++i) { - a->basenames [i] = g_path_get_basename (a->assembly_filepaths [i]); - a->basename_lens [i] = strlen (a->basenames [i]); - } - a->basenames [asm_count] = NULL; - a->basename_lens [asm_count] = 0; - - trusted_platform_assemblies = a; - return TRUE; -} - -static MonoCoreLookupPaths * -parse_lookup_paths (const char *search_path) -{ - char **parts = g_strsplit (search_path, G_SEARCHPATH_SEPARATOR_S, 0); - int dir_count = 0; - for (char **p = parts; *p != NULL && **p != '\0'; p++) { -#if 0 - const char *part = *p; - // can't use logger, it's not initialized yet. - printf ("\t\tnative search dir %d = <%s>\n", dir_count, part); -#endif - dir_count++; - } - MonoCoreLookupPaths *dl = g_new0 (MonoCoreLookupPaths, 1); - dl->dirs = parts; - dl->dir_count = dir_count; - return dl; -} - -static MonoAssembly* -mono_core_preload_hook (MonoAssemblyLoadContext *alc, MonoAssemblyName *aname, char **assemblies_path, gboolean refonly, gpointer user_data, MonoError *error) -{ - MonoAssembly *result = NULL; - MonoCoreTrustedPlatformAssemblies *a = (MonoCoreTrustedPlatformAssemblies *)user_data; - /* TODO: check that CoreCLR wants the strong name semantics here */ - MonoAssemblyCandidatePredicate predicate = &mono_assembly_candidate_predicate_sn_same_name; - void* predicate_ud = aname; - char *basename = NULL; - - if (a == NULL) // no TPA paths set - goto leave; - - g_assert (aname); - g_assert (aname->name); - g_assert (!refonly); - /* alc might be a user ALC - we get here from alc.LoadFromAssemblyName(), but we should load TPA assemblies into the default alc */ - MonoAssemblyLoadContext *default_alc; - default_alc = mono_domain_default_alc (mono_alc_domain (alc)); - - basename = g_strconcat (aname->name, ".dll", (const char*)NULL); /* TODO: make sure CoreCLR never needs to load .exe files */ - - size_t basename_len; - basename_len = strlen (basename); - - for (int i = 0; i < a->assembly_count; ++i) { - if (basename_len == a->basename_lens [i] && !g_strncasecmp (basename, a->basenames [i], a->basename_lens [i])) { - MonoAssemblyOpenRequest req; - mono_assembly_request_prepare_open (&req, MONO_ASMCTX_DEFAULT, default_alc); - req.request.predicate = predicate; - req.request.predicate_ud = predicate_ud; - - const char *fullpath = a->assembly_filepaths [i]; - - gboolean found = g_file_test (fullpath, G_FILE_TEST_IS_REGULAR); - - if (found) { - MonoImageOpenStatus status; - result = mono_assembly_request_open (fullpath, &req, &status); - /* TODO: do something with the status at the end? */ - if (result) - break; - } - } - } - -leave: - g_free (basename); - - if (!result) { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "netcore preload hook: did not find '%s'.", aname->name); - } else { - mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "netcore preload hook: loading '%s' from '%s'.", aname->name, result->image->name); - } - return result; -} - -static void -install_assembly_loader_hooks (void) -{ - mono_install_assembly_preload_hook_v2 (mono_core_preload_hook, (void*)trusted_platform_assemblies, FALSE, FALSE); -} - -static gboolean -parse_properties (int propertyCount, const char **propertyKeys, const char **propertyValues) -{ - // A partial list of relevant properties is at: - // https://docs.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting#step-3---prepare-runtime-properties - - for (int i = 0; i < propertyCount; ++i) { - size_t prop_len = strlen (propertyKeys [i]); - if (prop_len == 27 && !strncmp (propertyKeys [i], "TRUSTED_PLATFORM_ASSEMBLIES", 27)) { - parse_trusted_platform_assemblies (propertyValues[i]); - } else if (prop_len == 9 && !strncmp (propertyKeys [i], "APP_PATHS", 9)) { - app_paths = parse_lookup_paths (propertyValues [i]); - } else if (prop_len == 12 && !strncmp (propertyKeys [i], "APP_NI_PATHS", 12)) { - app_ni_paths = parse_lookup_paths (propertyValues [i]); - } else if (prop_len == 23 && !strncmp (propertyKeys [i], "PLATFORM_RESOURCE_ROOTS", 23)) { - platform_resource_roots = parse_lookup_paths (propertyValues [i]); - } else if (prop_len == 29 && !strncmp (propertyKeys [i], "NATIVE_DLL_SEARCH_DIRECTORIES", 29)) { - native_lib_paths = parse_lookup_paths (propertyValues [i]); - } else if (prop_len == 16 && !strncmp (propertyKeys [i], "PINVOKE_OVERRIDE", 16)) { - PInvokeOverrideFn override_fn = (PInvokeOverrideFn)(uintptr_t)strtoull (propertyValues [i], NULL, 0); - mono_loader_install_pinvoke_override (override_fn); - } else if (prop_len == 30 && !strncmp (propertyKeys [i], "System.Globalization.Invariant", 30)) { - // TODO: Ideally we should propagate this through AppContext options - g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", propertyValues [i], TRUE); - } else if (prop_len == 27 && !strncmp (propertyKeys [i], "System.Globalization.UseNls", 27)) { - // TODO: Ideally we should propagate this through AppContext options - g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_USENLS", propertyValues [i], TRUE); - } else if (prop_len == 32 && !strncmp (propertyKeys [i], "System.Globalization.AppLocalIcu", 32)) { - // TODO: Ideally we should propagate this through AppContext options - g_setenv ("DOTNET_SYSTEM_GLOBALIZATION_APPLOCALICU", propertyValues [i], TRUE); - } else { -#if 0 - // can't use mono logger, it's not initialized yet. - printf ("\t Unprocessed property %03d '%s': <%s>\n", i, propertyKeys[i], propertyValues[i]); -#endif - } - } - return TRUE; -} - -int -monovm_initialize (int propertyCount, const char **propertyKeys, const char **propertyValues) -{ - mono_runtime_register_appctx_properties (propertyCount, propertyKeys, propertyValues); - - if (!parse_properties (propertyCount, propertyKeys, propertyValues)) - return 0x80004005; /* E_FAIL */ - - install_assembly_loader_hooks (); - if (native_lib_paths != NULL) - mono_set_pinvoke_search_directories (native_lib_paths->dir_count, g_strdupv (native_lib_paths->dirs)); - // Our load hooks don't distinguish between normal, AOT'd, and satellite lookups the way CoreCLR's does. - // For now, just set assemblies_path with APP_PATHS and leave the rest. - if (app_paths != NULL) - mono_set_assemblies_path_direct (g_strdupv (app_paths->dirs)); - - /* - * Don't use Mono's legacy assembly name matching behavior - respect - * the requested version and culture. - */ - mono_loader_set_strict_assembly_name_check (TRUE); - - return 0; -} - -int -monovm_execute_assembly (int argc, const char **argv, const char *managedAssemblyPath, unsigned int *exitCode) -{ - if (exitCode == NULL) - { - return -1; - } - - // - // Make room for program name and executable assembly - // - int mono_argc = argc + 2; - - char **mono_argv = (char **) malloc (sizeof (char *) * (mono_argc + 1 /* null terminated */)); - const char **ptr = (const char **) mono_argv; - - *ptr++ = NULL; - - // executable assembly - *ptr++ = (char*) managedAssemblyPath; - - // the rest - for (int i = 0; i < argc; ++i) - *ptr++ = argv [i]; - - *ptr = NULL; - - mono_parse_env_options (&mono_argc, &mono_argv); - - // TODO: Should be return code of Main only (mono_jit_exec result) - *exitCode = mono_main (mono_argc, mono_argv); - - return 0; -} - -int -monovm_shutdown (int *latchedExitCode) -{ - *latchedExitCode = mono_environment_exitcode_get (); - - return 0; -} - -#else int monovm_initialize (int propertyCount, const char **propertyKeys, const char **propertyValues) @@ -292,4 +21,3 @@ monovm_shutdown (int *latchedExitCode) return -1; } -#endif // ENABLE_NETCORE diff --git a/mono/mini/simd-intrinsics-netcore.c b/mono/mini/simd-intrinsics-netcore.c deleted file mode 100644 index 33d307d5738..00000000000 --- a/mono/mini/simd-intrinsics-netcore.c +++ /dev/null @@ -1,2329 +0,0 @@ -/** - * SIMD Intrinsics support for netcore. - * Only LLVM is supported as a backend. - */ - -#include <config.h> -#include <mono/utils/mono-compiler.h> -#include <mono/metadata/icall-decl.h> -#include "mini.h" -#include "mini-runtime.h" -#include "ir-emit.h" -#ifdef ENABLE_LLVM -#include "mini-llvm.h" -#endif -#include "mono/utils/bsearch.h" -#include <mono/metadata/abi-details.h> -#include <mono/metadata/reflection-internals.h> -#include <mono/utils/mono-hwcap.h> - -#if defined (MONO_ARCH_SIMD_INTRINSICS) && defined(ENABLE_NETCORE) - -#if defined(DISABLE_JIT) - -void -mono_simd_intrinsics_init (void) -{ -} - -#else - -#define MSGSTRFIELD(line) MSGSTRFIELD1(line) -#define MSGSTRFIELD1(line) str##line -static const struct msgstr_t { -#define METHOD(name) char MSGSTRFIELD(__LINE__) [sizeof (#name)]; -#define METHOD2(str,name) char MSGSTRFIELD(__LINE__) [sizeof (str)]; -#include "simd-methods-netcore.h" -#undef METHOD -#undef METHOD2 -} method_names = { -#define METHOD(name) #name, -#define METHOD2(str,name) str, -#include "simd-methods-netcore.h" -#undef METHOD -#undef METHOD2 -}; - -enum { -#define METHOD(name) SN_ ## name = offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)), -#define METHOD2(str,name) SN_ ## name = offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)), -#include "simd-methods-netcore.h" -}; -#define method_name(idx) ((const char*)&method_names + (idx)) - -static int register_size; - -typedef struct { - // One of the SN_ constants - guint16 id; - // ins->opcode - int op; - // ins->inst_c0 - int instc0; -} SimdIntrinsic; - -void -mono_simd_intrinsics_init (void) -{ - register_size = 16; -#if FALSE - if ((mini_get_cpu_features () & MONO_CPU_X86_AVX) != 0) - register_size = 32; -#endif - /* Tell the class init code the size of the System.Numerics.Register type */ - mono_simd_register_size = register_size; -} - -MonoInst* -mono_emit_simd_field_load (MonoCompile *cfg, MonoClassField *field, MonoInst *addr) -{ - return NULL; -} - -static int -simd_intrinsic_compare_by_name (const void *key, const void *value) -{ - return strcmp ((const char*)key, method_name (*(guint16*)value)); -} - -static int -simd_intrinsic_info_compare_by_name (const void *key, const void *value) -{ - SimdIntrinsic *info = (SimdIntrinsic*)value; - return strcmp ((const char*)key, method_name (info->id)); -} - -static int -lookup_intrins (guint16 *intrinsics, int size, MonoMethod *cmethod) -{ - const guint16 *result = (const guint16 *)mono_binary_search (cmethod->name, intrinsics, size / sizeof (guint16), sizeof (guint16), &simd_intrinsic_compare_by_name); - - if (result == NULL) - return -1; - else - return (int)*result; -} - -static SimdIntrinsic* -lookup_intrins_info (SimdIntrinsic *intrinsics, int size, MonoMethod *cmethod) -{ -#if 0 - for (int i = 0; i < (size / sizeof (SimdIntrinsic)) - 1; ++i) { - const char *n1 = method_name (intrinsics [i].id); - const char *n2 = method_name (intrinsics [i + 1].id); - int len1 = strlen (n1); - int len2 = strlen (n2); - for (int j = 0; j < len1 && j < len2; ++j) { - if (n1 [j] > n2 [j]) { - printf ("%s %s\n", n1, n2); - g_assert_not_reached (); - } else if (n1 [j] < n2 [j]) { - break; - } - } - } -#endif - - return (SimdIntrinsic *)mono_binary_search (cmethod->name, intrinsics, size / sizeof (SimdIntrinsic), sizeof (SimdIntrinsic), &simd_intrinsic_info_compare_by_name); -} - -/* - * Return a simd vreg for the simd value represented by SRC. - * SRC is the 'this' argument to methods. - * Set INDIRECT to TRUE if the value was loaded from memory. - */ -static int -load_simd_vreg_class (MonoCompile *cfg, MonoClass *klass, MonoInst *src, gboolean *indirect) -{ - const char *spec = INS_INFO (src->opcode); - - if (indirect) - *indirect = FALSE; - if (src->opcode == OP_XMOVE) { - return src->sreg1; - } else if (src->opcode == OP_LDADDR) { - int res = ((MonoInst*)src->inst_p0)->dreg; - return res; - } else if (spec [MONO_INST_DEST] == 'x') { - return src->dreg; - } else if (src->type == STACK_PTR || src->type == STACK_MP) { - MonoInst *ins; - if (indirect) - *indirect = TRUE; - - MONO_INST_NEW (cfg, ins, OP_LOADX_MEMBASE); - ins->klass = klass; - ins->sreg1 = src->dreg; - ins->type = STACK_VTYPE; - ins->dreg = alloc_ireg (cfg); - MONO_ADD_INS (cfg->cbb, ins); - return ins->dreg; - } - g_warning ("load_simd_vreg:: could not infer source simd (%d) vreg for op", src->type); - mono_print_ins (src); - g_assert_not_reached (); -} - -static int -load_simd_vreg (MonoCompile *cfg, MonoMethod *cmethod, MonoInst *src, gboolean *indirect) -{ - return load_simd_vreg_class (cfg, cmethod->klass, src, indirect); -} - -/* Create and emit a SIMD instruction, dreg is auto-allocated */ -static MonoInst* -emit_simd_ins (MonoCompile *cfg, MonoClass *klass, int opcode, int sreg1, int sreg2) -{ - const char *spec = INS_INFO (opcode); - MonoInst *ins; - - MONO_INST_NEW (cfg, ins, opcode); - if (spec [MONO_INST_DEST] == 'x') { - ins->dreg = alloc_xreg (cfg); - ins->type = STACK_VTYPE; - } else if (spec [MONO_INST_DEST] == 'i') { - ins->dreg = alloc_ireg (cfg); - ins->type = STACK_I4; - } else if (spec [MONO_INST_DEST] == 'l') { - ins->dreg = alloc_lreg (cfg); - ins->type = STACK_I8; - } else if (spec [MONO_INST_DEST] == 'f') { - ins->dreg = alloc_freg (cfg); - ins->type = STACK_R8; - } - ins->sreg1 = sreg1; - ins->sreg2 = sreg2; - ins->klass = klass; - MONO_ADD_INS (cfg->cbb, ins); - return ins; -} - -static MonoInst* -emit_simd_ins_for_sig (MonoCompile *cfg, MonoClass *klass, int opcode, int instc0, int instc1, MonoMethodSignature *fsig, MonoInst **args) -{ - g_assert (fsig->param_count <= 3); - MonoInst* ins = emit_simd_ins (cfg, klass, opcode, - fsig->param_count > 0 ? args [0]->dreg : -1, - fsig->param_count > 1 ? args [1]->dreg : -1); - if (instc0 != -1) - ins->inst_c0 = instc0; - if (instc1 != -1) - ins->inst_c1 = instc1; - if (fsig->param_count == 3) - ins->sreg3 = args [2]->dreg; - return ins; -} - -static gboolean -is_hw_intrinsics_class (MonoClass *klass, const char *name, gboolean *is_64bit) -{ - const char *class_name = m_class_get_name (klass); - if ((!strcmp (class_name, "X64") || !strcmp (class_name, "Arm64")) && m_class_get_nested_in (klass)) { - *is_64bit = TRUE; - return !strcmp (m_class_get_name (m_class_get_nested_in (klass)), name); - } else { - *is_64bit = FALSE; - return !strcmp (class_name, name); - } -} - -static MonoTypeEnum -get_underlying_type (MonoType* type) -{ - MonoClass* klass = mono_class_from_mono_type_internal (type); - if (type->type == MONO_TYPE_PTR) // e.g. int* => MONO_TYPE_I4 - return m_class_get_byval_arg (m_class_get_element_class (klass))->type; - else if (type->type == MONO_TYPE_GENERICINST) // e.g. Vector128<int> => MONO_TYPE_I4 - return mono_class_get_context (klass)->class_inst->type_argv [0]->type; - else - return type->type; -} - -static MonoInst* -emit_xcompare (MonoCompile *cfg, MonoClass *klass, MonoTypeEnum etype, MonoInst *arg1, MonoInst *arg2) -{ - MonoInst *ins; - gboolean is_fp = etype == MONO_TYPE_R4 || etype == MONO_TYPE_R8; - - ins = emit_simd_ins (cfg, klass, is_fp ? OP_XCOMPARE_FP : OP_XCOMPARE, arg1->dreg, arg2->dreg); - ins->inst_c0 = CMP_EQ; - ins->inst_c1 = etype; - return ins; -} - -static MonoType* -get_vector_t_elem_type (MonoType *vector_type) -{ - MonoClass *klass; - MonoType *etype; - - g_assert (vector_type->type == MONO_TYPE_GENERICINST); - klass = mono_class_from_mono_type_internal (vector_type); - g_assert ( - !strcmp (m_class_get_name (klass), "Vector`1") || - !strcmp (m_class_get_name (klass), "Vector128`1") || - !strcmp (m_class_get_name (klass), "Vector256`1")); - etype = mono_class_get_context (klass)->class_inst->type_argv [0]; - return etype; -} - -static MonoInst * -emit_arch_vector128_create_multi (MonoCompile *cfg, MonoMethodSignature *fsig, MonoClass *klass, MonoType *etype, MonoInst **args) -{ -#if defined(TARGET_AMD64) - MonoInst *ins, *load; - - // FIXME: Optimize this - MONO_INST_NEW (cfg, ins, OP_LOCALLOC_IMM); - ins->dreg = alloc_preg (cfg); - ins->inst_imm = 16; - MONO_ADD_INS (cfg->cbb, ins); - - int esize = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); - int store_opcode = mono_type_to_store_membase (cfg, etype); - for (int i = 0; i < fsig->param_count; ++i) - MONO_EMIT_NEW_STORE_MEMBASE (cfg, store_opcode, ins->dreg, i * esize, args [i]->dreg); - - load = emit_simd_ins (cfg, klass, OP_SSE_LOADU, ins->dreg, -1); - load->inst_c0 = 16; - load->inst_c1 = get_underlying_type (etype); - return load; -#else - return NULL; -#endif -} - -#if defined(TARGET_AMD64) || defined(TARGET_ARM64) - -static int -type_to_expand_op (MonoType *type) -{ - switch (type->type) { - case MONO_TYPE_I1: - case MONO_TYPE_U1: - return OP_EXPAND_I1; - case MONO_TYPE_I2: - case MONO_TYPE_U2: - return OP_EXPAND_I2; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - return OP_EXPAND_I4; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - return OP_EXPAND_I8; - case MONO_TYPE_R4: - return OP_EXPAND_R4; - case MONO_TYPE_R8: - return OP_EXPAND_R8; - default: - g_assert_not_reached (); - } -} - -static guint16 vector_128_methods [] = { - SN_AsByte, - SN_AsDouble, - SN_AsInt16, - SN_AsInt32, - SN_AsInt64, - SN_AsSByte, - SN_AsSingle, - SN_AsUInt16, - SN_AsUInt32, - SN_AsUInt64, - SN_Create, - SN_CreateScalarUnsafe, -}; - -static MonoInst* -emit_vector128 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - if (!COMPILE_LLVM (cfg)) - return NULL; - - MonoClass *klass = cmethod->klass; - int id = lookup_intrins (vector_128_methods, sizeof (vector_128_methods), cmethod); - if (id == -1) - return NULL; - - if (!strcmp (m_class_get_name (cfg->method->klass), "Vector256")) - return NULL; // TODO: Fix Vector256.WithUpper/WithLower - - MonoTypeEnum arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID; - - switch (id) { - case SN_AsByte: - case SN_AsDouble: - case SN_AsInt16: - case SN_AsInt32: - case SN_AsInt64: - case SN_AsSByte: - case SN_AsSingle: - case SN_AsUInt16: - case SN_AsUInt32: - case SN_AsUInt64: - return emit_simd_ins (cfg, klass, OP_XCAST, args [0]->dreg, -1); - case SN_Create: { - MonoType *etype = get_vector_t_elem_type (fsig->ret); - if (fsig->param_count == 1 && mono_metadata_type_equal (fsig->params [0], etype)) - return emit_simd_ins (cfg, klass, type_to_expand_op (etype), args [0]->dreg, -1); - else - return emit_arch_vector128_create_multi (cfg, fsig, klass, etype, args); - } - case SN_CreateScalarUnsafe: - return emit_simd_ins_for_sig (cfg, klass, OP_CREATE_SCALAR_UNSAFE, -1, arg0_type, fsig, args); - default: - break; - } - - return NULL; -} - -#endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) - -#ifdef TARGET_AMD64 - -static guint16 vector_methods [] = { - SN_ConvertToDouble, - SN_ConvertToInt32, - SN_ConvertToInt64, - SN_ConvertToSingle, - SN_ConvertToUInt32, - SN_ConvertToUInt64, - SN_Narrow, - SN_Widen, - SN_get_IsHardwareAccelerated, -}; - -static MonoInst* -emit_sys_numerics_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *ins; - gboolean supported = FALSE; - int id; - MonoType *etype; - - id = lookup_intrins (vector_methods, sizeof (vector_methods), cmethod); - if (id == -1) - return NULL; - - //printf ("%s\n", mono_method_full_name (cmethod, 1)); - -#ifdef MONO_ARCH_SIMD_INTRINSICS - supported = TRUE; -#endif - - if (cfg->verbose_level > 1) { - char *name = mono_method_full_name (cmethod, TRUE); - printf (" SIMD intrinsic %s\n", name); - g_free (name); - } - - switch (id) { - case SN_get_IsHardwareAccelerated: - EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0); - ins->type = STACK_I4; - return ins; - case SN_ConvertToInt32: - etype = get_vector_t_elem_type (fsig->params [0]); - g_assert (etype->type == MONO_TYPE_R4); - return emit_simd_ins (cfg, mono_class_from_mono_type_internal (fsig->ret), OP_CVTPS2DQ, args [0]->dreg, -1); - case SN_ConvertToSingle: - etype = get_vector_t_elem_type (fsig->params [0]); - g_assert (etype->type == MONO_TYPE_I4 || etype->type == MONO_TYPE_U4); - // FIXME: - if (etype->type == MONO_TYPE_U4) - return NULL; - return emit_simd_ins (cfg, mono_class_from_mono_type_internal (fsig->ret), OP_CVTDQ2PS, args [0]->dreg, -1); - case SN_ConvertToDouble: - case SN_ConvertToInt64: - case SN_ConvertToUInt32: - case SN_ConvertToUInt64: - case SN_Narrow: - case SN_Widen: - // FIXME: - break; - default: - break; - } - - return NULL; -} - -static guint16 vector_t_methods [] = { - SN_ctor, - SN_CopyTo, - SN_Equals, - SN_GreaterThan, - SN_GreaterThanOrEqual, - SN_LessThan, - SN_LessThanOrEqual, - SN_Max, - SN_Min, - SN_get_AllBitsSet, - SN_get_Count, - SN_get_Item, - SN_get_One, - SN_get_Zero, - SN_op_Addition, - SN_op_BitwiseAnd, - SN_op_BitwiseOr, - SN_op_Division, - SN_op_Equality, - SN_op_ExclusiveOr, - SN_op_Explicit, - SN_op_Inequality, - SN_op_Multiply, - SN_op_Subtraction -}; - -static MonoInst* -emit_sys_numerics_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *ins; - MonoType *type, *etype; - MonoClass *klass; - int size, len, id; - gboolean is_unsigned; - - static const float r4_one = 1.0f; - static const double r8_one = 1.0; - - id = lookup_intrins (vector_t_methods, sizeof (vector_t_methods), cmethod); - if (id == -1) - return NULL; - - klass = cmethod->klass; - type = m_class_get_byval_arg (klass); - etype = mono_class_get_context (klass)->class_inst->type_argv [0]; - size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); - g_assert (size); - len = register_size / size; - - if (!MONO_TYPE_IS_PRIMITIVE (etype) || etype->type == MONO_TYPE_CHAR || etype->type == MONO_TYPE_BOOLEAN) - return NULL; - - if (cfg->verbose_level > 1) { - char *name = mono_method_full_name (cmethod, TRUE); - printf (" SIMD intrinsic %s\n", name); - g_free (name); - } - - switch (id) { - case SN_get_Count: - if (!(fsig->param_count == 0 && fsig->ret->type == MONO_TYPE_I4)) - break; - EMIT_NEW_ICONST (cfg, ins, len); - return ins; - case SN_get_Zero: - g_assert (fsig->param_count == 0 && mono_metadata_type_equal (fsig->ret, type)); - return emit_simd_ins (cfg, klass, OP_XZERO, -1, -1); - case SN_get_One: { - g_assert (fsig->param_count == 0 && mono_metadata_type_equal (fsig->ret, type)); - MonoInst *one = NULL; - int expand_opcode = type_to_expand_op (etype); - MONO_INST_NEW (cfg, one, -1); - switch (expand_opcode) { - case OP_EXPAND_R4: - one->opcode = OP_R4CONST; - one->type = STACK_R4; - one->inst_p0 = (void *) &r4_one; - break; - case OP_EXPAND_R8: - one->opcode = OP_R8CONST; - one->type = STACK_R8; - one->inst_p0 = (void *) &r8_one; - break; - default: - one->opcode = OP_ICONST; - one->type = STACK_I4; - one->inst_c0 = 1; - break; - } - one->dreg = alloc_dreg (cfg, (MonoStackType)one->type); - MONO_ADD_INS (cfg->cbb, one); - return emit_simd_ins (cfg, klass, expand_opcode, one->dreg, -1); - } - case SN_get_AllBitsSet: { - /* Compare a zero vector with itself */ - ins = emit_simd_ins (cfg, klass, OP_XZERO, -1, -1); - return emit_xcompare (cfg, klass, etype->type, ins, ins); - } - case SN_get_Item: { - if (!COMPILE_LLVM (cfg)) - return NULL; - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, args [1]->dreg, len); - MONO_EMIT_NEW_COND_EXC (cfg, GE_UN, "IndexOutOfRangeException"); - int opcode = -1; - int dreg; - gboolean is64 = FALSE; - switch (etype->type) { - case MONO_TYPE_I8: - case MONO_TYPE_U8: - opcode = OP_XEXTRACT_I64; - is64 = TRUE; - dreg = alloc_lreg (cfg); - break; - case MONO_TYPE_R8: - opcode = OP_XEXTRACT_R8; - dreg = alloc_freg (cfg); - break; - case MONO_TYPE_R4: - g_assert (cfg->r4fp); - opcode = OP_XEXTRACT_R4; - dreg = alloc_freg (cfg); - break; - default: - opcode = OP_XEXTRACT_I32; - dreg = alloc_ireg (cfg); - break; - } - MONO_INST_NEW (cfg, ins, opcode); - ins->dreg = dreg; - ins->sreg1 = load_simd_vreg (cfg, cmethod, args [0], NULL); - ins->sreg2 = args [1]->dreg; - ins->inst_c0 = etype->type; - mini_type_to_eval_stack_type (cfg, etype, ins); - MONO_ADD_INS (cfg->cbb, ins); - return ins; - } - case SN_ctor: - if (fsig->param_count == 1 && mono_metadata_type_equal (fsig->params [0], etype)) { - int dreg = load_simd_vreg (cfg, cmethod, args [0], NULL); - - int opcode = type_to_expand_op (etype); - ins = emit_simd_ins (cfg, klass, opcode, args [1]->dreg, -1); - ins->dreg = dreg; - return ins; - } - if ((fsig->param_count == 1 || fsig->param_count == 2) && (fsig->params [0]->type == MONO_TYPE_SZARRAY)) { - MonoInst *array_ins = args [1]; - MonoInst *index_ins; - MonoInst *ldelema_ins; - MonoInst *var; - int end_index_reg; - - if (args [0]->opcode != OP_LDADDR) - return NULL; - - /* .ctor (T[]) or .ctor (T[], index) */ - - if (fsig->param_count == 2) { - index_ins = args [2]; - } else { - EMIT_NEW_ICONST (cfg, index_ins, 0); - } - - /* Emit index check for the end (index + len - 1 < array length) */ - end_index_reg = alloc_ireg (cfg); - EMIT_NEW_BIALU_IMM (cfg, ins, OP_IADD_IMM, end_index_reg, index_ins->dreg, len - 1); - MONO_EMIT_BOUNDS_CHECK (cfg, array_ins->dreg, MonoArray, max_length, end_index_reg); - - /* Load the array slice into the simd reg */ - ldelema_ins = mini_emit_ldelema_1_ins (cfg, mono_class_from_mono_type_internal (etype), array_ins, index_ins, TRUE, FALSE); - g_assert (args [0]->opcode == OP_LDADDR); - var = (MonoInst*)args [0]->inst_p0; - EMIT_NEW_LOAD_MEMBASE (cfg, ins, OP_LOADX_MEMBASE, var->dreg, ldelema_ins->dreg, 0); - ins->klass = cmethod->klass; - return args [0]; - } - break; - case SN_CopyTo: - if ((fsig->param_count == 1 || fsig->param_count == 2) && (fsig->params [0]->type == MONO_TYPE_SZARRAY)) { - MonoInst *array_ins = args [1]; - MonoInst *index_ins; - MonoInst *ldelema_ins; - int val_vreg, end_index_reg; - - val_vreg = load_simd_vreg (cfg, cmethod, args [0], NULL); - - /* CopyTo (T[]) or CopyTo (T[], index) */ - - if (fsig->param_count == 2) { - index_ins = args [2]; - } else { - EMIT_NEW_ICONST (cfg, index_ins, 0); - } - - /* CopyTo () does complicated argument checks */ - mini_emit_bounds_check_offset (cfg, array_ins->dreg, MONO_STRUCT_OFFSET (MonoArray, max_length), index_ins->dreg, "ArgumentOutOfRangeException"); - end_index_reg = alloc_ireg (cfg); - int len_reg = alloc_ireg (cfg); - MONO_EMIT_NEW_LOAD_MEMBASE_OP_FLAGS (cfg, OP_LOADI4_MEMBASE, len_reg, array_ins->dreg, MONO_STRUCT_OFFSET (MonoArray, max_length), MONO_INST_INVARIANT_LOAD); - EMIT_NEW_BIALU (cfg, ins, OP_ISUB, end_index_reg, len_reg, index_ins->dreg); - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, end_index_reg, len); - MONO_EMIT_NEW_COND_EXC (cfg, LT, "ArgumentException"); - - /* Load the array slice into the simd reg */ - ldelema_ins = mini_emit_ldelema_1_ins (cfg, mono_class_from_mono_type_internal (etype), array_ins, index_ins, FALSE, FALSE); - EMIT_NEW_STORE_MEMBASE (cfg, ins, OP_STOREX_MEMBASE, ldelema_ins->dreg, 0, val_vreg); - ins->klass = cmethod->klass; - return ins; - } - break; - case SN_Equals: - if (fsig->param_count == 1 && fsig->ret->type == MONO_TYPE_BOOLEAN && mono_metadata_type_equal (fsig->params [0], type)) { - int sreg1 = load_simd_vreg (cfg, cmethod, args [0], NULL); - - return emit_simd_ins (cfg, klass, OP_XEQUAL, sreg1, args [1]->dreg); - } else if (fsig->param_count == 2 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)) { - /* Per element equality */ - return emit_xcompare (cfg, klass, etype->type, args [0], args [1]); - } - break; - case SN_op_Equality: - case SN_op_Inequality: - g_assert (fsig->param_count == 2 && fsig->ret->type == MONO_TYPE_BOOLEAN && - mono_metadata_type_equal (fsig->params [0], type) && - mono_metadata_type_equal (fsig->params [1], type)); - ins = emit_simd_ins (cfg, klass, OP_XEQUAL, args [0]->dreg, args [1]->dreg); - if (id == SN_op_Inequality) { - int sreg = ins->dreg; - int dreg = alloc_ireg (cfg); - MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, sreg, 0); - EMIT_NEW_UNALU (cfg, ins, OP_CEQ, dreg, -1); - } - return ins; - case SN_GreaterThan: - case SN_GreaterThanOrEqual: - case SN_LessThan: - case SN_LessThanOrEqual: - g_assert (fsig->param_count == 2 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)); - is_unsigned = etype->type == MONO_TYPE_U1 || etype->type == MONO_TYPE_U2 || etype->type == MONO_TYPE_U4 || etype->type == MONO_TYPE_U8; - ins = emit_xcompare (cfg, klass, etype->type, args [0], args [1]); - switch (id) { - case SN_GreaterThan: - ins->inst_c0 = is_unsigned ? CMP_GT_UN : CMP_GT; - break; - case SN_GreaterThanOrEqual: - ins->inst_c0 = is_unsigned ? CMP_GE_UN : CMP_GE; - break; - case SN_LessThan: - ins->inst_c0 = is_unsigned ? CMP_LT_UN : CMP_LT; - break; - case SN_LessThanOrEqual: - ins->inst_c0 = is_unsigned ? CMP_LE_UN : CMP_LE; - break; - default: - g_assert_not_reached (); - } - return ins; - case SN_op_Explicit: - return emit_simd_ins (cfg, klass, OP_XCAST, args [0]->dreg, -1); - case SN_op_Addition: - case SN_op_Subtraction: - case SN_op_Division: - case SN_op_Multiply: - case SN_op_BitwiseAnd: - case SN_op_BitwiseOr: - case SN_op_ExclusiveOr: - case SN_Max: - case SN_Min: - if (!(fsig->param_count == 2 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type))) - return NULL; - ins = emit_simd_ins (cfg, klass, OP_XBINOP, args [0]->dreg, args [1]->dreg); - ins->inst_c1 = etype->type; - - if (etype->type == MONO_TYPE_R4 || etype->type == MONO_TYPE_R8) { - switch (id) { - case SN_op_Addition: - ins->inst_c0 = OP_FADD; - break; - case SN_op_Subtraction: - ins->inst_c0 = OP_FSUB; - break; - case SN_op_Multiply: - ins->inst_c0 = OP_FMUL; - break; - case SN_op_Division: - ins->inst_c0 = OP_FDIV; - break; - case SN_Max: - ins->inst_c0 = OP_FMAX; - break; - case SN_Min: - ins->inst_c0 = OP_FMIN; - break; - default: - NULLIFY_INS (ins); - return NULL; - } - } else { - switch (id) { - case SN_op_Addition: - ins->inst_c0 = OP_IADD; - break; - case SN_op_Subtraction: - ins->inst_c0 = OP_ISUB; - break; - /* - case SN_op_Division: - ins->inst_c0 = OP_IDIV; - break; - case SN_op_Multiply: - ins->inst_c0 = OP_IMUL; - break; - */ - case SN_op_BitwiseAnd: - ins->inst_c0 = OP_IAND; - break; - case SN_op_BitwiseOr: - ins->inst_c0 = OP_IOR; - break; - case SN_op_ExclusiveOr: - ins->inst_c0 = OP_IXOR; - break; - case SN_Max: - ins->inst_c0 = OP_IMAX; - break; - case SN_Min: - ins->inst_c0 = OP_IMIN; - break; - default: - NULLIFY_INS (ins); - return NULL; - } - } - return ins; - default: - break; - } - - return NULL; -} -#endif // TARGET_AMD64 - -static MonoInst* -emit_invalid_operation (MonoCompile *cfg, const char* message) -{ - mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR); - mono_error_set_generic_error (cfg->error, "System", "InvalidOperationException", "%s", message); - return NULL; -} - -#ifdef TARGET_ARM64 - - -static SimdIntrinsic armbase_methods [] = { - {SN_LeadingSignCount}, - {SN_LeadingZeroCount}, - {SN_MultiplyHigh}, - {SN_ReverseElementBits}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic crc32_methods [] = { - {SN_ComputeCrc32}, - {SN_ComputeCrc32C}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sha1_methods [] = { - {SN_FixedRotate, OP_XOP_X_X, SIMD_OP_ARM64_SHA1H}, - {SN_HashUpdateChoose, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA1C}, - {SN_HashUpdateMajority, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA1M}, - {SN_HashUpdateParity, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA1P}, - {SN_ScheduleUpdate0, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA1SU0}, - {SN_ScheduleUpdate1, OP_XOP_X_X_X, SIMD_OP_ARM64_SHA1SU1}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sha256_methods [] = { - {SN_HashUpdate1, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA256H}, - {SN_HashUpdate2, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA256H2}, - {SN_ScheduleUpdate0, OP_XOP_X_X_X, SIMD_OP_ARM64_SHA256SU0}, - {SN_ScheduleUpdate1, OP_XOP_X_X_X_X, SIMD_OP_ARM64_SHA256SU1}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic advsimd_methods [] = { - {SN_Abs} -}; - -static MonoInst* -emit_arm64_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - // Arm64 intrinsics are LLVM-only - if (!COMPILE_LLVM (cfg)) - return NULL; - - MonoInst *ins; - gboolean supported, is_64bit; - MonoClass *klass = cmethod->klass; - MonoTypeEnum arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID; - gboolean arg0_i32 = (arg0_type == MONO_TYPE_I4) || (arg0_type == MONO_TYPE_U4); - SimdIntrinsic *info; - MonoCPUFeatures feature = -1; - SimdIntrinsic *intrinsics = NULL; - int intrinsics_size; - int id = -1; - gboolean jit_supported = FALSE; - - if (is_hw_intrinsics_class (klass, "ArmBase", &is_64bit)) { - info = lookup_intrins_info (armbase_methods, sizeof (armbase_methods), cmethod); - if (!info) - return NULL; - - supported = (mini_get_cpu_features (cfg) & MONO_CPU_ARM64_BASE) != 0; - - switch (info->id) { - case SN_get_IsSupported: - EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0); - ins->type = STACK_I4; - return ins; - case SN_LeadingZeroCount: - return emit_simd_ins_for_sig (cfg, klass, arg0_i32 ? OP_LZCNT32 : OP_LZCNT64, 0, arg0_type, fsig, args); - case SN_LeadingSignCount: - return emit_simd_ins_for_sig (cfg, klass, arg0_i32 ? OP_LSCNT32 : OP_LSCNT64, 0, arg0_type, fsig, args); - case SN_MultiplyHigh: - return emit_simd_ins_for_sig (cfg, klass, - (arg0_type == MONO_TYPE_I8 ? OP_ARM64_SMULH : OP_ARM64_UMULH), 0, arg0_type, fsig, args); - case SN_ReverseElementBits: - return emit_simd_ins_for_sig (cfg, klass, - (is_64bit ? OP_XOP_I8_I8 : OP_XOP_I4_I4), - (is_64bit ? SIMD_OP_ARM64_RBIT64 : SIMD_OP_ARM64_RBIT32), - arg0_type, fsig, args); - default: - g_assert_not_reached (); // if a new API is added we need to either implement it or change IsSupported to false - } - } - - if (is_hw_intrinsics_class (klass, "Crc32", &is_64bit)) { - info = lookup_intrins_info (crc32_methods, sizeof (crc32_methods), cmethod); - if (!info) - return NULL; - - supported = (mini_get_cpu_features (cfg) & MONO_CPU_ARM64_CRC) != 0; - - switch (info->id) { - case SN_get_IsSupported: - EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0); - ins->type = STACK_I4; - return ins; - case SN_ComputeCrc32: - case SN_ComputeCrc32C: { - SimdOp op = (SimdOp)0; - gboolean is_c = info->id == SN_ComputeCrc32C; - switch (get_underlying_type (fsig->params [1])) { - case MONO_TYPE_U1: op = is_c ? SIMD_OP_ARM64_CRC32CB : SIMD_OP_ARM64_CRC32B; break; - case MONO_TYPE_U2: op = is_c ? SIMD_OP_ARM64_CRC32CH : SIMD_OP_ARM64_CRC32H; break; - case MONO_TYPE_U4: op = is_c ? SIMD_OP_ARM64_CRC32CW : SIMD_OP_ARM64_CRC32W; break; - case MONO_TYPE_U8: op = is_c ? SIMD_OP_ARM64_CRC32CX : SIMD_OP_ARM64_CRC32X; break; - default: g_assert_not_reached (); break; - } - return emit_simd_ins_for_sig (cfg, klass, is_64bit ? OP_XOP_I4_I4_I8 : OP_XOP_I4_I4_I4, op, arg0_type, fsig, args); - } - default: - g_assert_not_reached (); // if a new API is added we need to either implement it or change IsSupported to false - } - } - - if (is_hw_intrinsics_class (klass, "Sha256", &is_64bit)) { - feature = MONO_CPU_ARM64_CRYPTO; - intrinsics = sha256_methods; - intrinsics_size = sizeof (sha256_methods); - } - - if (is_hw_intrinsics_class (klass, "Sha1", &is_64bit)) { - feature = MONO_CPU_ARM64_CRYPTO; - intrinsics = sha1_methods; - intrinsics_size = sizeof (sha1_methods); - } - - /* - * Common logic for all instruction sets - */ - if (intrinsics) { - if (!COMPILE_LLVM (cfg) && !jit_supported) - return NULL; - info = lookup_intrins_info (intrinsics, intrinsics_size, cmethod); - if (!info) - return NULL; - id = info->id; - - if (feature) - supported = (mini_get_cpu_features (cfg) & feature) != 0; - else - supported = TRUE; - if (id == SN_get_IsSupported) { - EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0); - return ins; - } - - if (!supported && cfg->compile_aot) { - // Can't emit non-supported llvm intrinsics - if (cfg->method != cmethod) { - // Keep the original call so we end up in the intrinsic method - return NULL; - } else { - // Emit an exception from the intrinsic method - mono_emit_jit_icall (cfg, mono_throw_not_supported, NULL); - return NULL; - } - } - - if (info->op != 0) - return emit_simd_ins_for_sig (cfg, klass, info->op, info->instc0, arg0_type, fsig, args); - } - - if (is_hw_intrinsics_class (klass, "AdvSimd", &is_64bit)) { - info = lookup_intrins_info (advsimd_methods, sizeof (advsimd_methods), cmethod); - - if (!info) - return NULL; - - supported = (mini_get_cpu_features (cfg) & MONO_CPU_ARM64_ADVSIMD) != 0; - - switch (info -> id) { - case SN_Abs: { - SimdOp op = (SimdOp)0; - switch (get_underlying_type (fsig->params [0])) { - case MONO_TYPE_R8: - op = SIMD_OP_LLVM_DABS; - break; - case MONO_TYPE_R4: - op = SIMD_OP_LLVM_FABS; - break; - case MONO_TYPE_I1: - op = SIMD_OP_LLVM_I8ABS; - break; - case MONO_TYPE_I2: - op = SIMD_OP_LLVM_I16ABS; - break; - case MONO_TYPE_I4: - op = SIMD_OP_LLVM_I32ABS; - break; - case MONO_TYPE_I8: - op = SIMD_OP_LLVM_I64ABS; - break; - } - - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X, op, arg0_type, fsig, args); - } - } - - } - - return NULL; -} -#endif // TARGET_ARM64 - -#ifdef TARGET_AMD64 - -static SimdIntrinsic sse_methods [] = { - {SN_Add, OP_XBINOP, OP_FADD}, - {SN_AddScalar, OP_SSE_ADDSS}, - {SN_And, OP_SSE_AND}, - {SN_AndNot, OP_SSE_ANDN}, - {SN_CompareEqual, OP_XCOMPARE_FP, CMP_EQ}, - {SN_CompareGreaterThan, OP_XCOMPARE_FP,CMP_GT}, - {SN_CompareGreaterThanOrEqual, OP_XCOMPARE_FP, CMP_GE}, - {SN_CompareLessThan, OP_XCOMPARE_FP, CMP_LT}, - {SN_CompareLessThanOrEqual, OP_XCOMPARE_FP, CMP_LE}, - {SN_CompareNotEqual, OP_XCOMPARE_FP, CMP_NE}, - {SN_CompareNotGreaterThan, OP_XCOMPARE_FP, CMP_LE}, - {SN_CompareNotGreaterThanOrEqual, OP_XCOMPARE_FP, CMP_LT}, - {SN_CompareNotLessThan, OP_XCOMPARE_FP, CMP_GE}, - {SN_CompareNotLessThanOrEqual, OP_XCOMPARE_FP, CMP_GT}, - {SN_CompareOrdered, OP_XCOMPARE_FP, CMP_ORD}, - {SN_CompareScalarEqual, OP_SSE_CMPSS, CMP_EQ}, - {SN_CompareScalarGreaterThan, OP_SSE_CMPSS, CMP_GT}, - {SN_CompareScalarGreaterThanOrEqual, OP_SSE_CMPSS, CMP_GE}, - {SN_CompareScalarLessThan, OP_SSE_CMPSS, CMP_LT}, - {SN_CompareScalarLessThanOrEqual, OP_SSE_CMPSS, CMP_LE}, - {SN_CompareScalarNotEqual, OP_SSE_CMPSS, CMP_NE}, - {SN_CompareScalarNotGreaterThan, OP_SSE_CMPSS, CMP_LE}, - {SN_CompareScalarNotGreaterThanOrEqual, OP_SSE_CMPSS, CMP_LT}, - {SN_CompareScalarNotLessThan, OP_SSE_CMPSS, CMP_GE}, - {SN_CompareScalarNotLessThanOrEqual, OP_SSE_CMPSS, CMP_GT}, - {SN_CompareScalarOrdered, OP_SSE_CMPSS, CMP_ORD}, - {SN_CompareScalarOrderedEqual, OP_SSE_COMISS, CMP_EQ}, - {SN_CompareScalarOrderedGreaterThan, OP_SSE_COMISS, CMP_GT}, - {SN_CompareScalarOrderedGreaterThanOrEqual, OP_SSE_COMISS, CMP_GE}, - {SN_CompareScalarOrderedLessThan, OP_SSE_COMISS, CMP_LT}, - {SN_CompareScalarOrderedLessThanOrEqual, OP_SSE_COMISS, CMP_LE}, - {SN_CompareScalarOrderedNotEqual, OP_SSE_COMISS, CMP_NE}, - {SN_CompareScalarUnordered, OP_SSE_CMPSS, CMP_UNORD}, - {SN_CompareScalarUnorderedEqual, OP_SSE_UCOMISS, CMP_EQ}, - {SN_CompareScalarUnorderedGreaterThan, OP_SSE_UCOMISS, CMP_GT}, - {SN_CompareScalarUnorderedGreaterThanOrEqual, OP_SSE_UCOMISS, CMP_GE}, - {SN_CompareScalarUnorderedLessThan, OP_SSE_UCOMISS, CMP_LT}, - {SN_CompareScalarUnorderedLessThanOrEqual, OP_SSE_UCOMISS, CMP_LE}, - {SN_CompareScalarUnorderedNotEqual, OP_SSE_UCOMISS, CMP_NE}, - {SN_CompareUnordered, OP_XCOMPARE_FP, CMP_UNORD}, - {SN_ConvertScalarToVector128Single}, - {SN_ConvertToInt32, OP_XOP_I4_X, SIMD_OP_SSE_CVTSS2SI}, - {SN_ConvertToInt32WithTruncation, OP_XOP_I4_X, SIMD_OP_SSE_CVTTSS2SI}, - {SN_ConvertToInt64, OP_XOP_I8_X, SIMD_OP_SSE_CVTSS2SI64}, - {SN_ConvertToInt64WithTruncation, OP_XOP_I8_X, SIMD_OP_SSE_CVTTSS2SI64}, - {SN_Divide, OP_XBINOP, OP_FDIV}, - {SN_DivideScalar, OP_SSE_DIVSS}, - {SN_LoadAlignedVector128, OP_SSE_LOADU, 16 /* alignment */}, - {SN_LoadHigh, OP_SSE_MOVHPS_LOAD}, - {SN_LoadLow, OP_SSE_MOVLPS_LOAD}, - {SN_LoadScalarVector128, OP_SSE_MOVSS}, - {SN_LoadVector128, OP_SSE_LOADU, 1 /* alignment */}, - {SN_Max, OP_XOP_X_X_X, SIMD_OP_SSE_MAXPS}, - {SN_MaxScalar, OP_XOP_X_X_X, SIMD_OP_SSE_MAXSS}, - {SN_Min, OP_XOP_X_X_X, SIMD_OP_SSE_MINPS}, - {SN_MinScalar, OP_XOP_X_X_X, SIMD_OP_SSE_MINSS}, - {SN_MoveHighToLow, OP_SSE_MOVEHL}, - {SN_MoveLowToHigh, OP_SSE_MOVELH}, - {SN_MoveMask, OP_SSE_MOVMSK}, - {SN_MoveScalar, OP_SSE_MOVS2}, - {SN_Multiply, OP_XBINOP, OP_FMUL}, - {SN_MultiplyScalar, OP_SSE_MULSS}, - {SN_Or, OP_SSE_OR}, - {SN_Prefetch0, OP_SSE_PREFETCHT0}, - {SN_Prefetch1, OP_SSE_PREFETCHT1}, - {SN_Prefetch2, OP_SSE_PREFETCHT2}, - {SN_PrefetchNonTemporal, OP_SSE_PREFETCHNTA}, - {SN_Reciprocal, OP_XOP_X_X, SIMD_OP_SSE_RCPPS}, - {SN_ReciprocalScalar}, - {SN_ReciprocalSqrt, OP_XOP_X_X, SIMD_OP_SSE_RSQRTPS}, - {SN_ReciprocalSqrtScalar}, - {SN_Shuffle}, - {SN_Sqrt, OP_XOP_X_X, SIMD_OP_SSE_SQRTPS}, - {SN_SqrtScalar}, - {SN_Store, OP_SSE_STORE, 1 /* alignment */}, - {SN_StoreAligned, OP_SSE_STORE, 16 /* alignment */}, - {SN_StoreAlignedNonTemporal, OP_SSE_MOVNTPS, 16 /* alignment */}, - {SN_StoreFence, OP_XOP, SIMD_OP_SSE_SFENCE}, - {SN_StoreHigh, OP_SSE_MOVHPS_STORE}, - {SN_StoreLow, OP_SSE_MOVLPS_STORE}, - {SN_StoreScalar, OP_SSE_MOVSS_STORE}, - {SN_Subtract, OP_XBINOP, OP_FSUB}, - {SN_SubtractScalar, OP_SSE_SUBSS}, - {SN_UnpackHigh, OP_SSE_UNPACKHI}, - {SN_UnpackLow, OP_SSE_UNPACKLO}, - {SN_Xor, OP_SSE_XOR}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sse2_methods [] = { - {SN_Add}, - {SN_AddSaturate, OP_SSE2_ADDS}, - {SN_AddScalar, OP_SSE2_ADDSD}, - {SN_And, OP_SSE_AND}, - {SN_AndNot, OP_SSE_ANDN}, - {SN_Average}, - {SN_CompareEqual}, - {SN_CompareGreaterThan}, - {SN_CompareGreaterThanOrEqual, OP_XCOMPARE_FP, CMP_GE}, - {SN_CompareLessThan}, - {SN_CompareLessThanOrEqual, OP_XCOMPARE_FP, CMP_LE}, - {SN_CompareNotEqual, OP_XCOMPARE_FP, CMP_NE}, - {SN_CompareNotGreaterThan, OP_XCOMPARE_FP, CMP_LE}, - {SN_CompareNotGreaterThanOrEqual, OP_XCOMPARE_FP, CMP_LT}, - {SN_CompareNotLessThan, OP_XCOMPARE_FP, CMP_GE}, - {SN_CompareNotLessThanOrEqual, OP_XCOMPARE_FP, CMP_GT}, - {SN_CompareOrdered, OP_XCOMPARE_FP, CMP_ORD}, - {SN_CompareScalarEqual, OP_SSE2_CMPSD, CMP_EQ}, - {SN_CompareScalarGreaterThan, OP_SSE2_CMPSD, CMP_GT}, - {SN_CompareScalarGreaterThanOrEqual, OP_SSE2_CMPSD, CMP_GE}, - {SN_CompareScalarLessThan, OP_SSE2_CMPSD, CMP_LT}, - {SN_CompareScalarLessThanOrEqual, OP_SSE2_CMPSD, CMP_LE}, - {SN_CompareScalarNotEqual, OP_SSE2_CMPSD, CMP_NE}, - {SN_CompareScalarNotGreaterThan, OP_SSE2_CMPSD, CMP_LE}, - {SN_CompareScalarNotGreaterThanOrEqual, OP_SSE2_CMPSD, CMP_LT}, - {SN_CompareScalarNotLessThan, OP_SSE2_CMPSD, CMP_GE}, - {SN_CompareScalarNotLessThanOrEqual, OP_SSE2_CMPSD, CMP_GT}, - {SN_CompareScalarOrdered, OP_SSE2_CMPSD, CMP_ORD}, - {SN_CompareScalarOrderedEqual, OP_SSE2_COMISD, CMP_EQ}, - {SN_CompareScalarOrderedGreaterThan, OP_SSE2_COMISD, CMP_GT}, - {SN_CompareScalarOrderedGreaterThanOrEqual, OP_SSE2_COMISD, CMP_GE}, - {SN_CompareScalarOrderedLessThan, OP_SSE2_COMISD, CMP_LT}, - {SN_CompareScalarOrderedLessThanOrEqual, OP_SSE2_COMISD, CMP_LE}, - {SN_CompareScalarOrderedNotEqual, OP_SSE2_COMISD, CMP_NE}, - {SN_CompareScalarUnordered, OP_SSE2_CMPSD, CMP_UNORD}, - {SN_CompareScalarUnorderedEqual, OP_SSE2_UCOMISD, CMP_EQ}, - {SN_CompareScalarUnorderedGreaterThan, OP_SSE2_UCOMISD, CMP_GT}, - {SN_CompareScalarUnorderedGreaterThanOrEqual, OP_SSE2_UCOMISD, CMP_GE}, - {SN_CompareScalarUnorderedLessThan, OP_SSE2_UCOMISD, CMP_LT}, - {SN_CompareScalarUnorderedLessThanOrEqual, OP_SSE2_UCOMISD, CMP_LE}, - {SN_CompareScalarUnorderedNotEqual, OP_SSE2_UCOMISD, CMP_NE}, - {SN_CompareUnordered, OP_XCOMPARE_FP, CMP_UNORD}, - {SN_ConvertScalarToVector128Double}, - {SN_ConvertScalarToVector128Int32}, - {SN_ConvertScalarToVector128Int64}, - {SN_ConvertScalarToVector128Single, OP_XOP_X_X_X, SIMD_OP_SSE_CVTSD2SS}, - {SN_ConvertScalarToVector128UInt32}, - {SN_ConvertScalarToVector128UInt64}, - {SN_ConvertToInt32}, - {SN_ConvertToInt32WithTruncation, OP_XOP_I4_X, SIMD_OP_SSE_CVTTSD2SI}, - {SN_ConvertToInt64}, - {SN_ConvertToInt64WithTruncation, OP_XOP_I8_X, SIMD_OP_SSE_CVTTSD2SI64}, - {SN_ConvertToUInt32}, - {SN_ConvertToUInt64}, - {SN_ConvertToVector128Double}, - {SN_ConvertToVector128Int32}, - {SN_ConvertToVector128Int32WithTruncation}, - {SN_ConvertToVector128Single}, - {SN_Divide, OP_XBINOP, OP_FDIV}, - {SN_DivideScalar, OP_SSE2_DIVSD}, - {SN_Extract}, - {SN_Insert}, - {SN_LoadAlignedVector128}, - {SN_LoadFence, OP_XOP, SIMD_OP_SSE_LFENCE}, - {SN_LoadHigh, OP_SSE2_MOVHPD_LOAD}, - {SN_LoadLow, OP_SSE2_MOVLPD_LOAD}, - {SN_LoadScalarVector128}, - {SN_LoadVector128}, - {SN_MaskMove, OP_SSE2_MASKMOVDQU}, - {SN_Max}, - {SN_MaxScalar, OP_XOP_X_X_X, SIMD_OP_SSE_MAXSD}, - {SN_MemoryFence, OP_XOP, SIMD_OP_SSE_MFENCE}, - {SN_Min}, // FIXME: - {SN_MinScalar, OP_XOP_X_X_X, SIMD_OP_SSE_MINSD}, - {SN_MoveMask, OP_SSE_MOVMSK}, - {SN_MoveScalar}, - {SN_Multiply}, - {SN_MultiplyAddAdjacent, OP_XOP_X_X_X, SIMD_OP_SSE_PMADDWD}, - {SN_MultiplyHigh}, - {SN_MultiplyLow, OP_PMULW}, - {SN_MultiplyScalar, OP_SSE2_MULSD}, - {SN_Or, OP_SSE_OR}, - {SN_PackSignedSaturate}, - {SN_PackUnsignedSaturate}, - {SN_ShiftLeftLogical}, - {SN_ShiftLeftLogical128BitLane}, - {SN_ShiftRightArithmetic}, - {SN_ShiftRightLogical}, - {SN_ShiftRightLogical128BitLane}, - {SN_Shuffle}, - {SN_ShuffleHigh}, - {SN_ShuffleLow}, - {SN_Sqrt, OP_XOP_X_X, SIMD_OP_SSE_SQRTPD}, - {SN_SqrtScalar}, - {SN_Store, OP_SSE_STORE, 1 /* alignment */}, - {SN_StoreAligned, OP_SSE_STORE, 16 /* alignment */}, - {SN_StoreAlignedNonTemporal, OP_SSE_MOVNTPS, 16 /* alignment */}, - {SN_StoreHigh, OP_SSE2_MOVHPD_STORE}, - {SN_StoreLow, OP_SSE2_MOVLPD_STORE}, - {SN_StoreNonTemporal, OP_SSE_MOVNTPS, 1 /* alignment */}, - {SN_StoreScalar, OP_SSE_STORES}, - {SN_Subtract}, - {SN_SubtractSaturate, OP_SSE2_SUBS}, - {SN_SubtractScalar, OP_SSE2_SUBSD}, - {SN_SumAbsoluteDifferences, OP_XOP_X_X_X, SIMD_OP_SSE_PSADBW}, - {SN_UnpackHigh, OP_SSE_UNPACKHI}, - {SN_UnpackLow, OP_SSE_UNPACKLO}, - {SN_Xor, OP_SSE_XOR}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sse3_methods [] = { - {SN_AddSubtract}, - {SN_HorizontalAdd}, - {SN_HorizontalSubtract}, - {SN_LoadAndDuplicateToVector128, OP_SSE3_MOVDDUP_MEM}, - {SN_LoadDquVector128, OP_XOP_X_I, SIMD_OP_SSE_LDDQU}, - {SN_MoveAndDuplicate, OP_SSE3_MOVDDUP}, - {SN_MoveHighAndDuplicate, OP_SSE3_MOVSHDUP}, - {SN_MoveLowAndDuplicate, OP_SSE3_MOVSLDUP}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic ssse3_methods [] = { - {SN_Abs, OP_SSSE3_ABS}, - {SN_AlignRight}, - {SN_HorizontalAdd}, - {SN_HorizontalAddSaturate, OP_XOP_X_X_X, SIMD_OP_SSE_PHADDSW}, - {SN_HorizontalSubtract}, - {SN_HorizontalSubtractSaturate, OP_XOP_X_X_X, SIMD_OP_SSE_PHSUBSW}, - {SN_MultiplyAddAdjacent, OP_XOP_X_X_X, SIMD_OP_SSE_PMADDUBSW}, - {SN_MultiplyHighRoundScale, OP_XOP_X_X_X, SIMD_OP_SSE_PMULHRSW}, - {SN_Shuffle, OP_SSSE3_SHUFFLE}, - {SN_Sign}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sse41_methods [] = { - {SN_Blend}, - {SN_BlendVariable}, - {SN_Ceiling, OP_SSE41_ROUNDP, 10 /*round mode*/}, - {SN_CeilingScalar, 0, 10 /*round mode*/}, - {SN_CompareEqual, OP_XCOMPARE, CMP_EQ}, - {SN_ConvertToVector128Int16, OP_SSE_CVTII, MONO_TYPE_I2}, - {SN_ConvertToVector128Int32, OP_SSE_CVTII, MONO_TYPE_I4}, - {SN_ConvertToVector128Int64, OP_SSE_CVTII, MONO_TYPE_I8}, - {SN_DotProduct}, - {SN_Extract}, - {SN_Floor, OP_SSE41_ROUNDP, 9 /*round mode*/}, - {SN_FloorScalar, 0, 9 /*round mode*/}, - {SN_Insert}, - {SN_LoadAlignedVector128NonTemporal, OP_SSE41_LOADANT}, - {SN_Max, OP_XBINOP, OP_IMAX}, - {SN_Min, OP_XBINOP, OP_IMIN}, - {SN_MinHorizontal, OP_XOP_X_X, SIMD_OP_SSE_PHMINPOSUW}, - {SN_MultipleSumAbsoluteDifferences}, - {SN_Multiply, OP_SSE41_MUL}, - {SN_MultiplyLow, OP_SSE41_MULLO}, - {SN_PackUnsignedSaturate, OP_XOP_X_X_X, SIMD_OP_SSE_PACKUSDW}, - {SN_RoundCurrentDirection, OP_SSE41_ROUNDP, 4 /*round mode*/}, - {SN_RoundCurrentDirectionScalar, 0, 4 /*round mode*/}, - {SN_RoundToNearestInteger, OP_SSE41_ROUNDP, 8 /*round mode*/}, - {SN_RoundToNearestIntegerScalar, 0, 8 /*round mode*/}, - {SN_RoundToNegativeInfinity, OP_SSE41_ROUNDP, 9 /*round mode*/}, - {SN_RoundToNegativeInfinityScalar, 0, 9 /*round mode*/}, - {SN_RoundToPositiveInfinity, OP_SSE41_ROUNDP, 10 /*round mode*/}, - {SN_RoundToPositiveInfinityScalar, 0, 10 /*round mode*/}, - {SN_RoundToZero, OP_SSE41_ROUNDP, 11 /*round mode*/}, - {SN_RoundToZeroScalar, 0, 11 /*round mode*/}, - {SN_TestC, OP_XOP_I4_X_X, SIMD_OP_SSE_TESTC}, - {SN_TestNotZAndNotC, OP_XOP_I4_X_X, SIMD_OP_SSE_TESTNZ}, - {SN_TestZ, OP_XOP_I4_X_X, SIMD_OP_SSE_TESTZ}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic sse42_methods [] = { - {SN_CompareGreaterThan, OP_XCOMPARE, CMP_GT}, - {SN_Crc32}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic pclmulqdq_methods [] = { - {SN_CarrylessMultiply}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic aes_methods [] = { - {SN_Decrypt, OP_XOP_X_X_X, SIMD_OP_AES_DEC}, - {SN_DecryptLast, OP_XOP_X_X_X, SIMD_OP_AES_DECLAST}, - {SN_Encrypt, OP_XOP_X_X_X, SIMD_OP_AES_ENC}, - {SN_EncryptLast, OP_XOP_X_X_X, SIMD_OP_AES_ENCLAST}, - {SN_InverseMixColumns, OP_XOP_X_X, SIMD_OP_AES_IMC}, - {SN_KeygenAssist}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic popcnt_methods [] = { - {SN_PopCount}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic lzcnt_methods [] = { - {SN_LeadingZeroCount}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic bmi1_methods [] = { - {SN_AndNot}, - {SN_BitFieldExtract}, - {SN_ExtractLowestSetBit}, - {SN_GetMaskUpToLowestSetBit}, - {SN_ResetLowestSetBit}, - {SN_TrailingZeroCount}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic bmi2_methods [] = { - {SN_MultiplyNoFlags}, - {SN_ParallelBitDeposit}, - {SN_ParallelBitExtract}, - {SN_ZeroHighBits}, - {SN_get_IsSupported} -}; - -static SimdIntrinsic x86base_methods [] = { - {SN_BitScanForward}, - {SN_BitScanReverse}, - {SN_get_IsSupported} -}; - -static MonoInst* -emit_x86_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *ins; - gboolean supported, is_64bit; - MonoClass *klass = cmethod->klass; - MonoTypeEnum arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID; - SimdIntrinsic *info = NULL; - MonoCPUFeatures feature = -1; - SimdIntrinsic *intrinsics = NULL; - int intrinsics_size; - int id = -1; - gboolean jit_supported = FALSE; - - if (is_hw_intrinsics_class (klass, "Sse", &is_64bit)) { - feature = MONO_CPU_X86_SSE; - intrinsics = sse_methods; - intrinsics_size = sizeof (sse_methods); - } else if (is_hw_intrinsics_class (klass, "Sse2", &is_64bit)) { - feature = MONO_CPU_X86_SSE2; - intrinsics = sse2_methods; - intrinsics_size = sizeof (sse2_methods); - } else if (is_hw_intrinsics_class (klass, "Sse3", &is_64bit)) { - feature = MONO_CPU_X86_SSE3; - intrinsics = sse3_methods; - intrinsics_size = sizeof (sse3_methods); - } else if (is_hw_intrinsics_class (klass, "Ssse3", &is_64bit)) { - feature = MONO_CPU_X86_SSSE3; - intrinsics = ssse3_methods; - intrinsics_size = sizeof (ssse3_methods); - } else if (is_hw_intrinsics_class (klass, "Sse41", &is_64bit)) { - feature = MONO_CPU_X86_SSE41; - intrinsics = sse41_methods; - intrinsics_size = sizeof (sse41_methods); - } else if (is_hw_intrinsics_class (klass, "Sse42", &is_64bit)) { - feature = MONO_CPU_X86_SSE42; - intrinsics = sse42_methods; - intrinsics_size = sizeof (sse42_methods); - } else if (is_hw_intrinsics_class (klass, "Pclmulqdq", &is_64bit)) { - feature = MONO_CPU_X86_PCLMUL; - intrinsics = pclmulqdq_methods; - intrinsics_size = sizeof (pclmulqdq_methods); - } else if (is_hw_intrinsics_class (klass, "Aes", &is_64bit)) { - feature = MONO_CPU_X86_AES; - intrinsics = aes_methods; - intrinsics_size = sizeof (aes_methods); - } else if (is_hw_intrinsics_class (klass, "Popcnt", &is_64bit)) { - feature = MONO_CPU_X86_POPCNT; - intrinsics = popcnt_methods; - intrinsics_size = sizeof (popcnt_methods); - jit_supported = TRUE; - } else if (is_hw_intrinsics_class (klass, "Lzcnt", &is_64bit)) { - feature = MONO_CPU_X86_LZCNT; - intrinsics = lzcnt_methods; - intrinsics_size = sizeof (lzcnt_methods); - jit_supported = TRUE; - } else if (is_hw_intrinsics_class (klass, "Bmi1", &is_64bit)) { - feature = MONO_CPU_X86_BMI1; - intrinsics = bmi1_methods; - intrinsics_size = sizeof (bmi1_methods); - } else if (is_hw_intrinsics_class (klass, "Bmi2", &is_64bit)) { - feature = MONO_CPU_X86_BMI2; - intrinsics = bmi2_methods; - intrinsics_size = sizeof (bmi2_methods); - } else if (is_hw_intrinsics_class (klass, "X86Base", &is_64bit)) { - feature = 0; - intrinsics = x86base_methods; - intrinsics_size = sizeof (x86base_methods); - } - - /* - * Common logic for all instruction sets - */ - if (intrinsics) { - if (!COMPILE_LLVM (cfg) && !jit_supported) - return NULL; - info = lookup_intrins_info (intrinsics, intrinsics_size, cmethod); - if (!info) - return NULL; - id = info->id; - - if (feature) - supported = (mini_get_cpu_features (cfg) & feature) != 0; - else - supported = TRUE; - if (id == SN_get_IsSupported) { - EMIT_NEW_ICONST (cfg, ins, supported ? 1 : 0); - return ins; - } - - if (!supported && cfg->compile_aot) { - /* Can't emit non-supported llvm intrinsics */ - if (cfg->method != cmethod) { - /* Keep the original call so we end up in the intrinsic method */ - return NULL; - } else { - /* Emit an exception from the intrinsic method */ - mono_emit_jit_icall (cfg, mono_throw_not_supported, NULL); - return NULL; - } - } - - if (info->op != 0) - return emit_simd_ins_for_sig (cfg, klass, info->op, info->instc0, arg0_type, fsig, args); - } - - /* - * Instruction set specific cases - */ - if (feature == MONO_CPU_X86_SSE) { - switch (id) { - case SN_Shuffle: - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE_SHUFFLE, args [2]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant mask (generate a switch) - return emit_invalid_operation (cfg, "mask in Sse.Shuffle must be constant"); - case SN_ConvertScalarToVector128Single: { - int op = 0; - switch (fsig->params [1]->type) { - case MONO_TYPE_I4: op = OP_SSE_CVTSI2SS; break; - case MONO_TYPE_I8: op = OP_SSE_CVTSI2SS64; break; - default: g_assert_not_reached (); break; - } - return emit_simd_ins_for_sig (cfg, klass, op, 0, 0, fsig, args); - } - case SN_ReciprocalScalar: - case SN_ReciprocalSqrtScalar: - case SN_SqrtScalar: { - int op = 0; - switch (id) { - case SN_ReciprocalScalar: op = OP_SSE_RCPSS; break; - case SN_ReciprocalSqrtScalar: op = OP_SSE_RSQRTSS; break; - case SN_SqrtScalar: op = OP_SSE_SQRTSS; break; - }; - if (fsig->param_count == 1) - return emit_simd_ins (cfg, klass, op, args [0]->dreg, args[0]->dreg); - else if (fsig->param_count == 2) - return emit_simd_ins (cfg, klass, op, args [0]->dreg, args[1]->dreg); - else - g_assert_not_reached (); - break; - } - case SN_LoadScalarVector128: - return NULL; - default: - return NULL; - } - } - - if (feature == MONO_CPU_X86_SSE2) { - switch (id) { - case SN_Subtract: - return emit_simd_ins_for_sig (cfg, klass, OP_XBINOP, arg0_type == MONO_TYPE_R8 ? OP_FSUB : OP_ISUB, arg0_type, fsig, args); - case SN_Add: - return emit_simd_ins_for_sig (cfg, klass, OP_XBINOP, arg0_type == MONO_TYPE_R8 ? OP_FADD : OP_IADD, arg0_type, fsig, args); - case SN_Average: - if (arg0_type == MONO_TYPE_U1) - return emit_simd_ins_for_sig (cfg, klass, OP_PAVGB_UN, -1, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_U2) - return emit_simd_ins_for_sig (cfg, klass, OP_PAVGW_UN, -1, arg0_type, fsig, args); - else - return NULL; - case SN_CompareNotEqual: - return emit_simd_ins_for_sig (cfg, klass, arg0_type == MONO_TYPE_R8 ? OP_XCOMPARE_FP : OP_XCOMPARE, CMP_NE, arg0_type, fsig, args); - case SN_CompareEqual: - return emit_simd_ins_for_sig (cfg, klass, arg0_type == MONO_TYPE_R8 ? OP_XCOMPARE_FP : OP_XCOMPARE, CMP_EQ, arg0_type, fsig, args); - case SN_CompareGreaterThan: - return emit_simd_ins_for_sig (cfg, klass, arg0_type == MONO_TYPE_R8 ? OP_XCOMPARE_FP : OP_XCOMPARE, CMP_GT, arg0_type, fsig, args); - case SN_CompareLessThan: - return emit_simd_ins_for_sig (cfg, klass, arg0_type == MONO_TYPE_R8 ? OP_XCOMPARE_FP : OP_XCOMPARE, CMP_LT, arg0_type, fsig, args); - case SN_ConvertToInt32: - if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_I4_X, SIMD_OP_SSE_CVTSD2SI, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_I4) - return emit_simd_ins_for_sig (cfg, klass, OP_EXTRACT_I4, 0, arg0_type, fsig, args); - else - return NULL; - case SN_ConvertToInt64: - if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_I8_X, SIMD_OP_SSE_CVTSD2SI64, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_I8) - return emit_simd_ins_for_sig (cfg, klass, OP_EXTRACT_I8, 0 /*element index*/, arg0_type, fsig, args); - else - g_assert_not_reached (); - break; - case SN_ConvertScalarToVector128Double: { - int op = OP_SSE2_CVTSS2SD; - switch (fsig->params [1]->type) { - case MONO_TYPE_I4: op = OP_SSE2_CVTSI2SD; break; - case MONO_TYPE_I8: op = OP_SSE2_CVTSI2SD64; break; - } - return emit_simd_ins_for_sig (cfg, klass, op, 0, 0, fsig, args); - } - case SN_ConvertScalarToVector128Int32: - case SN_ConvertScalarToVector128Int64: - case SN_ConvertScalarToVector128UInt32: - case SN_ConvertScalarToVector128UInt64: - return emit_simd_ins_for_sig (cfg, klass, OP_CREATE_SCALAR, -1, arg0_type, fsig, args); - case SN_ConvertToUInt32: - return emit_simd_ins_for_sig (cfg, klass, OP_EXTRACT_I4, 0 /*element index*/, arg0_type, fsig, args); - case SN_ConvertToUInt64: - return emit_simd_ins_for_sig (cfg, klass, OP_EXTRACT_I8, 0 /*element index*/, arg0_type, fsig, args); - case SN_ConvertToVector128Double: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTPS2PD, 0, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_I4) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTDQ2PD, 0, arg0_type, fsig, args); - else - return NULL; - case SN_ConvertToVector128Int32: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTPS2DQ, 0, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTPD2DQ, 0, arg0_type, fsig, args); - else - return NULL; - case SN_ConvertToVector128Int32WithTruncation: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTTPS2DQ, 0, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTTPD2DQ, 0, arg0_type, fsig, args); - else - return NULL; - case SN_ConvertToVector128Single: - if (arg0_type == MONO_TYPE_I4) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTDQ2PS, 0, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_CVTPD2PS, 0, arg0_type, fsig, args); - else - return NULL; - case SN_LoadAlignedVector128: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE_LOADU, 16 /*alignment*/, arg0_type, fsig, args); - case SN_LoadVector128: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE_LOADU, 1 /*alignment*/, arg0_type, fsig, args); - case SN_MoveScalar: - return emit_simd_ins_for_sig (cfg, klass, fsig->param_count == 2 ? OP_SSE_MOVS2 : OP_SSE_MOVS, -1, arg0_type, fsig, args); - case SN_Max: - switch (arg0_type) { - case MONO_TYPE_U1: - return emit_simd_ins_for_sig (cfg, klass, OP_PMAXB_UN, 0, arg0_type, fsig, args); - case MONO_TYPE_I2: - return emit_simd_ins_for_sig (cfg, klass, OP_PMAXW, 0, arg0_type, fsig, args); - case MONO_TYPE_R8: return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_MAXPD, arg0_type, fsig, args); - default: - g_assert_not_reached (); - break; - } - break; - case SN_Min: - switch (arg0_type) { - case MONO_TYPE_U1: - return emit_simd_ins_for_sig (cfg, klass, OP_PMINB_UN, 0, arg0_type, fsig, args); - case MONO_TYPE_I2: - return emit_simd_ins_for_sig (cfg, klass, OP_PMINW, 0, arg0_type, fsig, args); - case MONO_TYPE_R8: return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_MINPD, arg0_type, fsig, args); - default: - g_assert_not_reached (); - break; - } - break; - case SN_Multiply: - if (arg0_type == MONO_TYPE_U4) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PMULUDQ, 0, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_MULPD, 0, arg0_type, fsig, args); - else - g_assert_not_reached (); - case SN_MultiplyHigh: - if (arg0_type == MONO_TYPE_I2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PMULHW, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_U2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PMULHUW, arg0_type, fsig, args); - else - g_assert_not_reached (); - case SN_PackSignedSaturate: - if (arg0_type == MONO_TYPE_I2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PACKSSWB, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_I4) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PACKSSDW, arg0_type, fsig, args); - else - g_assert_not_reached (); - case SN_PackUnsignedSaturate: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PACKUS, -1, arg0_type, fsig, args); - case SN_Extract: - g_assert (arg0_type == MONO_TYPE_U2); - return emit_simd_ins_for_sig (cfg, klass, OP_XEXTRACT_I32, arg0_type, 0, fsig, args); - case SN_Insert: - g_assert (arg0_type == MONO_TYPE_I2 || arg0_type == MONO_TYPE_U2); - return emit_simd_ins_for_sig (cfg, klass, OP_XINSERT_I2, 0, arg0_type, fsig, args); - case SN_ShiftRightLogical: { - gboolean is_imm = fsig->params [1]->type == MONO_TYPE_U1; - SimdOp op = (SimdOp)0; - switch (arg0_type) { - case MONO_TYPE_I2: - case MONO_TYPE_U2: - op = is_imm ? SIMD_OP_SSE_PSRLW_IMM : SIMD_OP_SSE_PSRLW; - break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - op = is_imm ? SIMD_OP_SSE_PSRLD_IMM : SIMD_OP_SSE_PSRLD; - break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - op = is_imm ? SIMD_OP_SSE_PSRLQ_IMM : SIMD_OP_SSE_PSRLQ; - break; - default: g_assert_not_reached (); break; - } - return emit_simd_ins_for_sig (cfg, klass, is_imm ? OP_XOP_X_X_I4 : OP_XOP_X_X_X, op, arg0_type, fsig, args); - } - case SN_ShiftRightArithmetic: { - gboolean is_imm = fsig->params [1]->type == MONO_TYPE_U1; - SimdOp op = (SimdOp)0; - switch (arg0_type) { - case MONO_TYPE_I2: - case MONO_TYPE_U2: - op = is_imm ? SIMD_OP_SSE_PSRAW_IMM : SIMD_OP_SSE_PSRAW; - break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - op = is_imm ? SIMD_OP_SSE_PSRAD_IMM : SIMD_OP_SSE_PSRAD; - break; - default: g_assert_not_reached (); break; - } - return emit_simd_ins_for_sig (cfg, klass, is_imm ? OP_XOP_X_X_I4 : OP_XOP_X_X_X, op, arg0_type, fsig, args); - } - case SN_ShiftLeftLogical: { - gboolean is_imm = fsig->params [1]->type == MONO_TYPE_U1; - SimdOp op = (SimdOp)0; - switch (arg0_type) { - case MONO_TYPE_I2: - case MONO_TYPE_U2: - op = is_imm ? SIMD_OP_SSE_PSLLW_IMM : SIMD_OP_SSE_PSLLW; - break; - case MONO_TYPE_I4: - case MONO_TYPE_U4: - op = is_imm ? SIMD_OP_SSE_PSLLD_IMM : SIMD_OP_SSE_PSLLD; - break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: - op = is_imm ? SIMD_OP_SSE_PSLLQ_IMM : SIMD_OP_SSE_PSLLQ; - break; - default: g_assert_not_reached (); break; - } - return emit_simd_ins_for_sig (cfg, klass, is_imm ? OP_XOP_X_X_I4 : OP_XOP_X_X_X, op, arg0_type, fsig, args); - } - case SN_ShiftLeftLogical128BitLane: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PSLLDQ, 0, arg0_type, fsig, args); - case SN_ShiftRightLogical128BitLane: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PSRLDQ, 0, arg0_type, fsig, args); - case SN_Shuffle: { - if (fsig->param_count == 2) { - g_assert (arg0_type == MONO_TYPE_I4 || arg0_type == MONO_TYPE_U4); - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PSHUFD, 0, arg0_type, fsig, args); - } else if (fsig->param_count == 3) { - g_assert (arg0_type == MONO_TYPE_R8); - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_SHUFPD, 0, arg0_type, fsig, args); - } else { - g_assert_not_reached (); - break; - } - } - case SN_ShuffleHigh: - g_assert (fsig->param_count == 2); - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PSHUFHW, 0, arg0_type, fsig, args); - case SN_ShuffleLow: - g_assert (fsig->param_count == 2); - return emit_simd_ins_for_sig (cfg, klass, OP_SSE2_PSHUFLW, 0, arg0_type, fsig, args); - case SN_SqrtScalar: { - if (fsig->param_count == 1) - return emit_simd_ins (cfg, klass, OP_SSE2_SQRTSD, args [0]->dreg, args[0]->dreg); - else if (fsig->param_count == 2) - return emit_simd_ins (cfg, klass, OP_SSE2_SQRTSD, args [0]->dreg, args[1]->dreg); - else { - g_assert_not_reached (); - break; - } - } - case SN_LoadScalarVector128: { - int op = 0; - switch (arg0_type) { - case MONO_TYPE_I4: - case MONO_TYPE_U4: op = OP_SSE2_MOVD; break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: op = OP_SSE2_MOVQ; break; - case MONO_TYPE_R8: op = OP_SSE2_MOVUPD; break; - default: g_assert_not_reached(); break; - } - return emit_simd_ins_for_sig (cfg, klass, op, 0, 0, fsig, args); - } - default: - return NULL; - } - } - - if (feature == MONO_CPU_X86_SSE3) { - switch (id) { - case SN_AddSubtract: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_ADDSUBPS, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_ADDSUBPD, arg0_type, fsig, args); - else - g_assert_not_reached (); - break; - case SN_HorizontalAdd: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_HADDPS, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_HADDPD, arg0_type, fsig, args); - else - g_assert_not_reached (); - break; - case SN_HorizontalSubtract: - if (arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_HSUBPS, arg0_type, fsig, args); - else if (arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_HSUBPD, arg0_type, fsig, args); - else - g_assert_not_reached (); - break; - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_SSSE3) { - switch (id) { - case SN_AlignRight: - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_SSSE3_ALIGNR, args [2]->inst_c0, arg0_type, fsig, args); - return emit_invalid_operation (cfg, "mask in Ssse3.AlignRight must be constant"); - case SN_HorizontalAdd: - if (arg0_type == MONO_TYPE_I2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PHADDW, arg0_type, fsig, args); - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PHADDD, arg0_type, fsig, args); - case SN_HorizontalSubtract: - if (arg0_type == MONO_TYPE_I2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PHSUBW, arg0_type, fsig, args); - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PHSUBD, arg0_type, fsig, args); - case SN_Sign: - if (arg0_type == MONO_TYPE_I1) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PSIGNB, arg0_type, fsig, args); - if (arg0_type == MONO_TYPE_I2) - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PSIGNW, arg0_type, fsig, args); - return emit_simd_ins_for_sig (cfg, klass, OP_XOP_X_X_X, SIMD_OP_SSE_PSIGND, arg0_type, fsig, args); - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_SSE41) { - switch (id) { - case SN_DotProduct: - if (args [2]->opcode == OP_ICONST && arg0_type == MONO_TYPE_R4) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_DPPS_IMM, args [2]->inst_c0, arg0_type, fsig, args); - else if (args [2]->opcode == OP_ICONST && arg0_type == MONO_TYPE_R8) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_DPPD_IMM, args [2]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant control byte (generate a switch) - return emit_invalid_operation (cfg, "control byte in Sse41.DotProduct must be constant"); - case SN_MultipleSumAbsoluteDifferences: - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_MPSADBW_IMM, args [2]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant control byte (generate a switch) - return emit_invalid_operation (cfg, "control byte in Sse41.MultipleSumAbsoluteDifferences must be constant"); - case SN_Blend: - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_BLEND_IMM, args [2]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant control byte (generate a switch) - return emit_invalid_operation (cfg, "control byte in Sse41.Blend must be constant"); - case SN_BlendVariable: - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_BLENDV, -1, arg0_type, fsig, args); - case SN_Extract: { - int op = 0; - switch (arg0_type) { - case MONO_TYPE_U1: - case MONO_TYPE_U4: - case MONO_TYPE_I4: op = OP_XEXTRACT_I32; break; - case MONO_TYPE_I8: - case MONO_TYPE_U8: op = OP_XEXTRACT_I64; break; - case MONO_TYPE_R4: op = OP_XEXTRACT_R4; break; - default: g_assert_not_reached(); break; - } - return emit_simd_ins_for_sig (cfg, klass, op, arg0_type, 0, fsig, args); - } - case SN_Insert: - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_INSERT, -1, arg0_type, fsig, args); - // FIXME: handle non-constant index (generate a switch) - return emit_invalid_operation (cfg, "index in Sse41.Insert must be constant"); - case SN_CeilingScalar: - case SN_FloorScalar: - case SN_RoundCurrentDirectionScalar: - case SN_RoundToNearestIntegerScalar: - case SN_RoundToNegativeInfinityScalar: - case SN_RoundToPositiveInfinityScalar: - case SN_RoundToZeroScalar: - if (fsig->param_count == 2) { - return emit_simd_ins_for_sig (cfg, klass, OP_SSE41_ROUNDS, info->instc0, arg0_type, fsig, args); - } else { - MonoInst* ins = emit_simd_ins (cfg, klass, OP_SSE41_ROUNDS, args [0]->dreg, args [0]->dreg); - ins->inst_c0 = info->instc0; - ins->inst_c1 = arg0_type; - return ins; - } - break; - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_SSE42) { - switch (id) { - case SN_Crc32: { - MonoTypeEnum arg1_type = get_underlying_type (fsig->params [1]); - return emit_simd_ins_for_sig (cfg, klass, - arg1_type == MONO_TYPE_U8 ? OP_SSE42_CRC64 : OP_SSE42_CRC32, - arg1_type, arg0_type, fsig, args); - } - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_PCLMUL) { - switch (id) { - case SN_CarrylessMultiply: { - if (args [2]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_PCLMULQDQ_IMM, args [2]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant control byte (generate a switch) - return emit_invalid_operation (cfg, "index in Pclmulqdq.CarrylessMultiply must be constant"); - } - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_AES) { - switch (id) { - case SN_KeygenAssist: { - if (args [1]->opcode == OP_ICONST) - return emit_simd_ins_for_sig (cfg, klass, OP_AES_KEYGEN_IMM, args [1]->inst_c0, arg0_type, fsig, args); - // FIXME: handle non-constant control byte (generate a switch) - return emit_invalid_operation (cfg, "control byte in Aes.KeygenAssist must be constant"); - } - default: - g_assert_not_reached (); - break; - } - } - - if (feature == MONO_CPU_X86_POPCNT) { - switch (id) { - case SN_PopCount: - if (!supported) - return NULL; - MONO_INST_NEW (cfg, ins, is_64bit ? OP_POPCNT64 : OP_POPCNT32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - return NULL; - } - } - if (feature == MONO_CPU_X86_LZCNT) { - switch (id) { - case SN_LeadingZeroCount: - if (!supported) - return NULL; - MONO_INST_NEW (cfg, ins, is_64bit ? OP_LZCNT64 : OP_LZCNT32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - return NULL; - } - } - if (feature == MONO_CPU_X86_BMI1) { - switch (id) { - case SN_AndNot: { - // (a ^ -1) & b - // LLVM replaces it with `andn` - int tmp_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - int result_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - EMIT_NEW_BIALU_IMM (cfg, ins, is_64bit ? OP_LXOR_IMM : OP_IXOR_IMM, tmp_reg, args [0]->dreg, -1); - EMIT_NEW_BIALU (cfg, ins, is_64bit ? OP_LAND : OP_IAND, result_reg, tmp_reg, args [1]->dreg); - return ins; - } - case SN_BitFieldExtract: { - if (fsig->param_count == 2) { - MONO_INST_NEW (cfg, ins, is_64bit ? OP_BEXTR64 : OP_BEXTR32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - } - } - case SN_GetMaskUpToLowestSetBit: { - // x ^ (x - 1) - // LLVM replaces it with `blsmsk` - int tmp_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - int result_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - EMIT_NEW_BIALU_IMM (cfg, ins, is_64bit ? OP_LSUB_IMM : OP_ISUB_IMM, tmp_reg, args [0]->dreg, 1); - EMIT_NEW_BIALU (cfg, ins, is_64bit ? OP_LXOR : OP_IXOR, result_reg, args [0]->dreg, tmp_reg); - return ins; - } - case SN_ResetLowestSetBit: { - // x & (x - 1) - // LLVM replaces it with `blsr` - int tmp_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - int result_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - EMIT_NEW_BIALU_IMM (cfg, ins, is_64bit ? OP_LSUB_IMM : OP_ISUB_IMM, tmp_reg, args [0]->dreg, 1); - EMIT_NEW_BIALU (cfg, ins, is_64bit ? OP_LAND : OP_IAND, result_reg, args [0]->dreg, tmp_reg); - return ins; - } - case SN_ExtractLowestSetBit: { - // x & (0 - x) - // LLVM replaces it with `blsi` - int tmp_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - int result_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - int zero_reg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - MONO_EMIT_NEW_ICONST (cfg, zero_reg, 0); - EMIT_NEW_BIALU (cfg, ins, is_64bit ? OP_LSUB : OP_ISUB, tmp_reg, zero_reg, args [0]->dreg); - EMIT_NEW_BIALU (cfg, ins, is_64bit ? OP_LAND : OP_IAND, result_reg, args [0]->dreg, tmp_reg); - return ins; - } - case SN_TrailingZeroCount: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_CTTZ64 : OP_CTTZ32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - g_assert_not_reached (); - } - } - if (feature == MONO_CPU_X86_BMI2) { - switch (id) { - case SN_MultiplyNoFlags: - if (fsig->param_count == 2) { - MONO_INST_NEW (cfg, ins, is_64bit ? OP_MULX_H64 : OP_MULX_H32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - } else if (fsig->param_count == 3) { - MONO_INST_NEW (cfg, ins, is_64bit ? OP_MULX_HL64 : OP_MULX_HL32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->sreg3 = args [2]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - } else { - g_assert_not_reached (); - } - return ins; - case SN_ZeroHighBits: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_BZHI64 : OP_BZHI32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - case SN_ParallelBitExtract: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_PEXT64 : OP_PEXT32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - case SN_ParallelBitDeposit: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_PDEP64 : OP_PDEP32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->sreg2 = args [1]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - g_assert_not_reached (); - } - } - - if (intrinsics == x86base_methods) { - switch (id) { - case SN_BitScanForward: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_X86_BSF64 : OP_X86_BSF32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - case SN_BitScanReverse: - MONO_INST_NEW (cfg, ins, is_64bit ? OP_X86_BSR64 : OP_X86_BSR32); - ins->dreg = is_64bit ? alloc_lreg (cfg) : alloc_ireg (cfg); - ins->sreg1 = args [0]->dreg; - ins->type = is_64bit ? STACK_I8 : STACK_I4; - MONO_ADD_INS (cfg->cbb, ins); - return ins; - default: - g_assert_not_reached (); - } - } - - return NULL; -} - -static guint16 vector_128_t_methods [] = { - SN_get_Count, - SN_get_Zero, -}; - -static MonoInst* -emit_vector128_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *ins; - MonoType *type, *etype; - MonoClass *klass; - int size, len, id; - - id = lookup_intrins (vector_128_t_methods, sizeof (vector_128_t_methods), cmethod); - if (id == -1) - return NULL; - - klass = cmethod->klass; - type = m_class_get_byval_arg (klass); - etype = mono_class_get_context (klass)->class_inst->type_argv [0]; - size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); - g_assert (size); - len = 16 / size; - - if (!MONO_TYPE_IS_PRIMITIVE (etype) || etype->type == MONO_TYPE_CHAR || etype->type == MONO_TYPE_BOOLEAN) - return NULL; - - if (cfg->verbose_level > 1) { - char *name = mono_method_full_name (cmethod, TRUE); - printf (" SIMD intrinsic %s\n", name); - g_free (name); - } - - switch (id) { - case SN_get_Count: - if (!(fsig->param_count == 0 && fsig->ret->type == MONO_TYPE_I4)) - break; - EMIT_NEW_ICONST (cfg, ins, len); - return ins; - case SN_get_Zero: { - return emit_simd_ins (cfg, klass, OP_XZERO, -1, -1); - } - default: - break; - } - - return NULL; -} - -static guint16 vector_256_t_methods [] = { - SN_get_Count, -}; - -static MonoInst* -emit_vector256_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *ins; - MonoType *type, *etype; - MonoClass *klass; - int size, len, id; - - id = lookup_intrins (vector_256_t_methods, sizeof (vector_256_t_methods), cmethod); - if (id == -1) - return NULL; - - klass = cmethod->klass; - type = m_class_get_byval_arg (klass); - etype = mono_class_get_context (klass)->class_inst->type_argv [0]; - size = mono_class_value_size (mono_class_from_mono_type_internal (etype), NULL); - g_assert (size); - len = 32 / size; - - if (!MONO_TYPE_IS_PRIMITIVE (etype) || etype->type == MONO_TYPE_CHAR || etype->type == MONO_TYPE_BOOLEAN) - return NULL; - - if (cfg->verbose_level > 1) { - char *name = mono_method_full_name (cmethod, TRUE); - printf (" SIMD intrinsic %s\n", name); - g_free (name); - } - - switch (id) { - case SN_get_Count: - if (!(fsig->param_count == 0 && fsig->ret->type == MONO_TYPE_I4)) - break; - EMIT_NEW_ICONST (cfg, ins, len); - return ins; - default: - break; - } - - return NULL; -} - -static -MonoInst* -emit_amd64_intrinsics (const char *class_ns, const char *class_name, MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - if (!strcmp (class_ns, "System.Runtime.Intrinsics.X86")) { - return emit_x86_intrinsics (cfg, cmethod, fsig, args); - } - - if (!strcmp (class_ns, "System.Runtime.Intrinsics")) { - if (!strcmp (class_name, "Vector128`1")) - return emit_vector128_t (cfg, cmethod, fsig, args); - if (!strcmp (class_name, "Vector256`1")) - return emit_vector256_t (cfg, cmethod, fsig, args); - } - - if (!strcmp (class_ns, "System.Numerics")) { - if (!strcmp (class_name, "Vector")) - return emit_sys_numerics_vector (cfg, cmethod, fsig, args); - if (!strcmp (class_name, "Vector`1")) - return emit_sys_numerics_vector_t (cfg, cmethod, fsig, args); - } - - return NULL; -} -#endif // !TARGET_ARM64 - -#ifdef TARGET_ARM64 -static -MonoInst* -emit_simd_intrinsics (const char *class_ns, const char *class_name, MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - // FIXME: implement Vector64<T>, Vector128<T> and Vector<T> for Arm64 - if (!strcmp (class_ns, "System.Runtime.Intrinsics.Arm")) { - return emit_arm64_intrinsics (cfg, cmethod, fsig, args); - } - - return NULL; -} -#elif TARGET_AMD64 -// TODO: test and enable for x86 too -static -MonoInst* -emit_simd_intrinsics (const char *class_ns, const char *class_name, MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - MonoInst *simd_inst = emit_amd64_intrinsics (class_ns, class_name, cfg, cmethod, fsig, args); - if (simd_inst != NULL) { - cfg->uses_simd_intrinsics |= MONO_CFG_USES_SIMD_INTRINSICS; - cfg->uses_simd_intrinsics |= MONO_CFG_USES_SIMD_INTRINSICS_DECOMPOSE_VTYPE; - } - return simd_inst; -} -#else -static -MonoInst* -emit_simd_intrinsics (const char *class_ns, const char *class_name, MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - return NULL; -} -#endif - -MonoInst* -mono_emit_simd_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args) -{ - const char *class_name; - const char *class_ns; - MonoImage *image = m_class_get_image (cmethod->klass); - - if (image != mono_get_corlib ()) - return NULL; - - class_ns = m_class_get_name_space (cmethod->klass); - class_name = m_class_get_name (cmethod->klass); - - // If cmethod->klass is nested, the namespace is on the enclosing class. - if (m_class_get_nested_in (cmethod->klass)) - class_ns = m_class_get_name_space (m_class_get_nested_in (cmethod->klass)); - -#if defined(TARGET_AMD64) || defined(TARGET_ARM64) - if (!strcmp (class_ns, "System.Runtime.Intrinsics")) { - if (!strcmp (class_name, "Vector128")) - return emit_vector128 (cfg, cmethod, fsig, args); - } -#endif // defined(TARGET_AMD64) || defined(TARGET_ARM64) - - return emit_simd_intrinsics (class_ns, class_name, cfg, cmethod, fsig, args); -} - -/* -* Windows x64 value type ABI uses reg/stack references (ArgValuetypeAddrInIReg/ArgValuetypeAddrOnStack) -* for function arguments. When using SIMD intrinsics arguments optimized into OP_ARG needs to be decomposed -* into correspondig SIMD LOADX/STOREX instructions. -*/ -#if defined(TARGET_WIN32) && defined(TARGET_AMD64) -static gboolean -decompose_vtype_opt_uses_simd_intrinsics (MonoCompile *cfg, MonoInst *ins) -{ - if (cfg->uses_simd_intrinsics & MONO_CFG_USES_SIMD_INTRINSICS_DECOMPOSE_VTYPE) - return TRUE; - - switch (ins->opcode) { - case OP_XMOVE: - case OP_XZERO: - case OP_LOADX_MEMBASE: - case OP_LOADX_ALIGNED_MEMBASE: - case OP_STOREX_MEMBASE: - case OP_STOREX_ALIGNED_MEMBASE_REG: - return TRUE; - default: - return FALSE; - } -} - -static void -decompose_vtype_opt_load_arg (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, gint32 *sreg_int32) -{ - guint32 *sreg = (guint32*)sreg_int32; - MonoInst *src_var = get_vreg_to_inst (cfg, *sreg); - if (src_var && src_var->opcode == OP_ARG && src_var->klass && MONO_CLASS_IS_SIMD (cfg, src_var->klass)) { - MonoInst *varload_ins, *load_ins; - NEW_VARLOADA (cfg, varload_ins, src_var, src_var->inst_vtype); - mono_bblock_insert_before_ins (bb, ins, varload_ins); - MONO_INST_NEW (cfg, load_ins, OP_LOADX_MEMBASE); - load_ins->klass = src_var->klass; - load_ins->type = STACK_VTYPE; - load_ins->sreg1 = varload_ins->dreg; - load_ins->dreg = alloc_xreg (cfg); - mono_bblock_insert_after_ins (bb, varload_ins, load_ins); - *sreg = load_ins->dreg; - } -} - -void -mono_simd_decompose_intrinsic (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins) -{ - if (cfg->opt & MONO_OPT_SIMD && decompose_vtype_opt_uses_simd_intrinsics (cfg, ins)) { - decompose_vtype_opt_load_arg (cfg, bb, ins, &(ins->sreg1)); - decompose_vtype_opt_load_arg (cfg, bb, ins, &(ins->sreg2)); - decompose_vtype_opt_load_arg (cfg, bb, ins, &(ins->sreg3)); - MonoInst *dest_var = get_vreg_to_inst (cfg, ins->dreg); - if (dest_var && dest_var->opcode == OP_ARG && dest_var->klass && MONO_CLASS_IS_SIMD (cfg, dest_var->klass)) { - MonoInst *varload_ins, *store_ins; - ins->dreg = alloc_xreg (cfg); - NEW_VARLOADA (cfg, varload_ins, dest_var, dest_var->inst_vtype); - mono_bblock_insert_after_ins (bb, ins, varload_ins); - MONO_INST_NEW (cfg, store_ins, OP_STOREX_MEMBASE); - store_ins->klass = dest_var->klass; - store_ins->type = STACK_VTYPE; - store_ins->sreg1 = ins->dreg; - store_ins->dreg = varload_ins->dreg; - mono_bblock_insert_after_ins (bb, varload_ins, store_ins); - } - } -} -#else -void -mono_simd_decompose_intrinsic (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins) -{ -} -#endif /*defined(TARGET_WIN32) && defined(TARGET_AMD64)*/ - -void -mono_simd_simplify_indirection (MonoCompile *cfg) -{ -} - -#endif /* DISABLE_JIT */ -#endif /* MONO_ARCH_SIMD_INTRINSICS */ - -#if defined(ENABLE_NETCORE) && defined(TARGET_AMD64) -void -ves_icall_System_Runtime_Intrinsics_X86_X86Base___cpuidex (int abcd[4], int function_id, int subfunction_id) -{ -#ifndef MONO_CROSS_COMPILE - mono_hwcap_x86_call_cpuidex (function_id, subfunction_id, - &abcd [0], &abcd [1], &abcd [2], &abcd [3]); -#endif -} -#endif - -MONO_EMPTY_SOURCE_FILE (simd_intrinsics_netcore); diff --git a/mono/mini/simd-intrinsics.c b/mono/mini/simd-intrinsics.c index cadf38ae1c9..613a529dea7 100644 --- a/mono/mini/simd-intrinsics.c +++ b/mono/mini/simd-intrinsics.c @@ -64,7 +64,7 @@ The advantage of this change is that it could have a _membase version and promot without a OP_LDADDR. */ -#if defined (MONO_ARCH_SIMD_INTRINSICS) && !defined(ENABLE_NETCORE) +#if defined (MONO_ARCH_SIMD_INTRINSICS) #if defined (DISABLE_JIT) diff --git a/mono/mini/simd-methods-netcore.h b/mono/mini/simd-methods-netcore.h deleted file mode 100644 index a19958c9e3e..00000000000 --- a/mono/mini/simd-methods-netcore.h +++ /dev/null @@ -1,247 +0,0 @@ -METHOD2(".ctor", ctor) -METHOD(CopyTo) -METHOD(Equals) -METHOD(GreaterThan) -METHOD(GreaterThanOrEqual) -METHOD(LessThan) -METHOD(LessThanOrEqual) -METHOD(Min) -METHOD(Max) -METHOD(MinScalar) -METHOD(MaxScalar) -METHOD(PopCount) -METHOD(LeadingZeroCount) -METHOD(get_Count) -METHOD(get_IsHardwareAccelerated) -METHOD(get_IsSupported) -METHOD(get_AllBitsSet) -METHOD(get_Item) -METHOD(get_One) -METHOD(get_Zero) -METHOD(op_Addition) -METHOD(op_BitwiseAnd) -METHOD(op_BitwiseOr) -METHOD(op_Division) -METHOD(op_Equality) -METHOD(op_ExclusiveOr) -METHOD(op_Explicit) -METHOD(op_Inequality) -METHOD(op_Multiply) -METHOD(op_Subtraction) -// Vector -METHOD(ConvertToInt32) -METHOD(ConvertToInt32WithTruncation) -METHOD(ConvertToUInt32) -METHOD(ConvertToInt64) -METHOD(ConvertToInt64WithTruncation) -METHOD(ConvertToUInt64) -METHOD(ConvertToSingle) -METHOD(ConvertToDouble) -METHOD(Narrow) -METHOD(Widen) -// Vector128 -METHOD(AsByte) -METHOD(AsDouble) -METHOD(AsInt16) -METHOD(AsInt32) -METHOD(AsInt64) -METHOD(AsSByte) -METHOD(AsSingle) -METHOD(AsUInt16) -METHOD(AsUInt32) -METHOD(AsUInt64) -METHOD(Create) -METHOD(CreateScalarUnsafe) -// Bmi1 -METHOD(AndNot) -METHOD(BitFieldExtract) -METHOD(ExtractLowestSetBit) -METHOD(GetMaskUpToLowestSetBit) -METHOD(ResetLowestSetBit) -METHOD(TrailingZeroCount) -// Bmi2 -METHOD(ZeroHighBits) -METHOD(MultiplyNoFlags) -METHOD(ParallelBitDeposit) -METHOD(ParallelBitExtract) -// Sse -METHOD(Add) -METHOD(CompareGreaterThanOrEqual) -METHOD(CompareLessThanOrEqual) -METHOD(CompareNotEqual) -METHOD(CompareNotGreaterThan) -METHOD(CompareNotGreaterThanOrEqual) -METHOD(CompareNotLessThan) -METHOD(CompareNotLessThanOrEqual) -METHOD(CompareScalarGreaterThan) -METHOD(CompareScalarGreaterThanOrEqual) -METHOD(CompareScalarLessThan) -METHOD(CompareScalarLessThanOrEqual) -METHOD(CompareScalarNotEqual) -METHOD(CompareScalarNotGreaterThan) -METHOD(CompareScalarNotGreaterThanOrEqual) -METHOD(CompareScalarNotLessThan) -METHOD(CompareScalarNotLessThanOrEqual) -METHOD(CompareScalarOrderedEqual) -METHOD(CompareScalarOrderedGreaterThan) -METHOD(CompareScalarOrderedGreaterThanOrEqual) -METHOD(CompareScalarOrderedLessThan) -METHOD(CompareScalarOrderedLessThanOrEqual) -METHOD(CompareScalarOrderedNotEqual) -METHOD(CompareScalarUnorderedEqual) -METHOD(CompareScalarUnorderedGreaterThan) -METHOD(CompareScalarUnorderedGreaterThanOrEqual) -METHOD(CompareScalarUnorderedLessThan) -METHOD(CompareScalarUnorderedLessThanOrEqual) -METHOD(CompareScalarUnorderedNotEqual) -METHOD(CompareOrdered) -METHOD(CompareUnordered) -METHOD(CompareScalarOrdered) -METHOD(CompareScalarUnordered) -METHOD(ConvertScalarToVector128Single) -METHOD(Divide) -METHOD(DivideScalar) -METHOD(Store) -METHOD(StoreFence) -METHOD(StoreHigh) -METHOD(StoreLow) -METHOD(Subtract) -METHOD(SubtractScalar) -METHOD(CompareEqual) -METHOD(Extract) -METHOD(LoadHigh) -METHOD(LoadLow) -METHOD(LoadVector128) -METHOD(LoadScalarVector128) -METHOD(MoveHighToLow) -METHOD(MoveLowToHigh) -METHOD(MoveMask) -METHOD(MoveScalar) -METHOD(Multiply) -METHOD(MultiplyAddAdjacent) -METHOD(MultiplyScalar) -METHOD(Shuffle) -METHOD(UnpackHigh) -METHOD(UnpackLow) -METHOD(Prefetch0) -METHOD(Prefetch1) -METHOD(Prefetch2) -METHOD(PrefetchNonTemporal) -METHOD(Reciprocal) -METHOD(ReciprocalScalar) -METHOD(ReciprocalSqrt) -METHOD(ReciprocalSqrtScalar) -METHOD(Sqrt) -METHOD(SqrtScalar) -// Sse2 -METHOD(AddSaturate) -METHOD(AddScalar) -METHOD(And) -METHOD(Average) -METHOD(Or) -METHOD(LoadAlignedVector128) -METHOD(Xor) -METHOD(CompareGreaterThan) -METHOD(CompareScalarEqual) -METHOD(ConvertScalarToVector128Double) -METHOD(ConvertScalarToVector128Int32) -METHOD(ConvertScalarToVector128Int64) -METHOD(ConvertScalarToVector128UInt32) -METHOD(ConvertScalarToVector128UInt64) -METHOD(ConvertToVector128Double) -METHOD(ConvertToVector128Int32) -METHOD(ConvertToVector128Int32WithTruncation) -METHOD(ConvertToVector128Single) -METHOD(MaskMove) -METHOD(MultiplyHigh) -METHOD(MultiplyLow) -METHOD(PackSignedSaturate) -METHOD(PackUnsignedSaturate) -METHOD(ShuffleHigh) -METHOD(ShuffleLow) -METHOD(SubtractSaturate) -METHOD(SumAbsoluteDifferences) -METHOD(StoreScalar) -METHOD(StoreAligned) -METHOD(StoreAlignedNonTemporal) -METHOD(StoreNonTemporal) -METHOD(ShiftLeftLogical) -METHOD(ShiftLeftLogical128BitLane) -METHOD(ShiftRightArithmetic) -METHOD(ShiftRightLogical) -METHOD(ShiftRightLogical128BitLane) -METHOD(CompareLessThan) -METHOD(LoadFence) -METHOD(MemoryFence) -// Sse3 -METHOD(HorizontalAdd) -METHOD(HorizontalSubtract) -METHOD(AddSubtract) -METHOD(LoadAndDuplicateToVector128) -METHOD(LoadDquVector128) -METHOD(MoveAndDuplicate) -METHOD(MoveHighAndDuplicate) -METHOD(MoveLowAndDuplicate) -// Ssse3 -METHOD(Abs) // Also used by ARM64 -METHOD(AlignRight) -METHOD(HorizontalAddSaturate) -METHOD(HorizontalSubtractSaturate) -METHOD(MultiplyHighRoundScale) -METHOD(Sign) -// Sse41 -METHOD(Blend) -METHOD(BlendVariable) -METHOD(Ceiling) -METHOD(CeilingScalar) -METHOD(ConvertToVector128Int16) -METHOD(ConvertToVector128Int64) -METHOD(Floor) -METHOD(FloorScalar) -METHOD(Insert) -METHOD(LoadAlignedVector128NonTemporal) -METHOD(RoundCurrentDirectionScalar) -METHOD(RoundToNearestInteger) -METHOD(RoundToNearestIntegerScalar) -METHOD(RoundToNegativeInfinity) -METHOD(RoundToNegativeInfinityScalar) -METHOD(RoundToPositiveInfinity) -METHOD(RoundToPositiveInfinityScalar) -METHOD(RoundToZero) -METHOD(RoundToZeroScalar) -METHOD(RoundCurrentDirection) -METHOD(MinHorizontal) -METHOD(TestC) -METHOD(TestNotZAndNotC) -METHOD(TestZ) -METHOD(DotProduct) -METHOD(MultipleSumAbsoluteDifferences) -// Sse42 -METHOD(Crc32) -// Aes -METHOD(Decrypt) -METHOD(DecryptLast) -METHOD(Encrypt) -METHOD(EncryptLast) -METHOD(InverseMixColumns) -METHOD(KeygenAssist) -// Pclmulqdq -METHOD(CarrylessMultiply) -// ArmBase -METHOD(LeadingSignCount) -METHOD(ReverseElementBits) -// Crc32 -METHOD(ComputeCrc32) -METHOD(ComputeCrc32C) -// X86Base -METHOD(BitScanForward) -METHOD(BitScanReverse) -// Crypto -METHOD(FixedRotate) -METHOD(HashUpdateChoose) -METHOD(HashUpdateMajority) -METHOD(HashUpdateParity) -METHOD(HashUpdate1) -METHOD(HashUpdate2) -METHOD(ScheduleUpdate0) -METHOD(ScheduleUpdate1) diff --git a/mono/mini/tasklets.c b/mono/mini/tasklets.c index 402a3a981c2..34642cd1ebd 100644 --- a/mono/mini/tasklets.c +++ b/mono/mini/tasklets.c @@ -12,7 +12,6 @@ #include "mono/metadata/loader-internals.h" #include "mono/utils/mono-tls-inline.h" -#if !defined(ENABLE_NETCORE) #if defined(MONO_SUPPORT_TASKLETS) #include "mono/metadata/loader-internals.h" @@ -216,5 +215,4 @@ mono_tasklets_init(void) } #endif /* MONO_SUPPORT_TASKLETS */ -#endif /* ENABLE_NETCORE */ diff --git a/mono/mini/tasklets.h b/mono/mini/tasklets.h index dd8750f3f2f..66823fff7b3 100644 --- a/mono/mini/tasklets.h +++ b/mono/mini/tasklets.h @@ -7,7 +7,6 @@ #include "mini.h" -#if !defined(ENABLE_NETCORE) typedef struct { MonoLMF *lmf; gpointer top_sp; @@ -32,7 +31,6 @@ void mono_tasklets_cleanup (void); MonoContinuationRestore mono_tasklets_arch_restore (void); -#endif /* ENABLE_NETCORE */ #endif /* __MONO_TASKLETS_H__ */ diff --git a/mono/sgen/sgen-debug.c b/mono/sgen/sgen-debug.c index b62c4cede31..e2546e49a11 100644 --- a/mono/sgen/sgen-debug.c +++ b/mono/sgen/sgen-debug.c @@ -947,7 +947,6 @@ sgen_scan_for_registered_roots_in_domain (MonoDomain *domain, int root_type) static gboolean is_xdomain_ref_allowed (GCObject **ptr, GCObject *obj, MonoDomain *domain) { -#ifndef ENABLE_NETCORE MonoObject *o = (MonoObject*)(obj); size_t offset = (char*)(ptr) - (char*)o; @@ -961,7 +960,6 @@ is_xdomain_ref_allowed (GCObject **ptr, GCObject *obj, MonoDomain *domain) offset == G_STRUCT_OFFSET (MonoRealProxy, unwrapped_server)) return TRUE; #endif -#endif return FALSE; } diff --git a/mono/tools/offsets-tool/offsets-tool.py b/mono/tools/offsets-tool/offsets-tool.py index 8af7cc1f34f..358d98cb297 100644 --- a/mono/tools/offsets-tool/offsets-tool.py +++ b/mono/tools/offsets-tool/offsets-tool.py @@ -63,7 +63,6 @@ class OffsetsTool: parser.add_argument ('--abi=', dest='abi', help='ABI triple to generate', required=True) parser.add_argument ('--sysroot=', dest='sysroot', help='path to sysroot headers of target') parser.add_argument ('--prefix=', dest='prefixes', action='append', help='prefix path to include directory of target') - parser.add_argument ('--netcore', dest='netcore', help='target runs with netcore', action='store_true') args = parser.parse_args () if not args.libclang or not os.path.isfile (args.libclang): @@ -201,9 +200,6 @@ class OffsetsTool: print ("ABI '" + args.abi + "' is not supported.", file=sys.stderr) sys.exit (1) - if args.netcore: - self.target_args += ["-DENABLE_NETCORE"] - self.args = args # diff --git a/mono/utils/mono-complex.h b/mono/utils/mono-complex.h index 6b3fe7544ae..6839f3f8c99 100644 --- a/mono/utils/mono-complex.h +++ b/mono/utils/mono-complex.h @@ -14,7 +14,6 @@ #define _USE_MATH_DEFINES // needed by MSVC to define math constants #include <math.h> -#ifndef ENABLE_NETCORE typedef struct double_complex { double real; @@ -62,4 +61,3 @@ double_complex mono_double_complex_sub(double_complex left, double_complex right #include "../../support/libm/complex.c" -#endif diff --git a/mono/utils/mono-dl-posix.c b/mono/utils/mono-dl-posix.c index 7b19cd5174a..d140e9bc6a1 100644 --- a/mono/utils/mono-dl-posix.c +++ b/mono/utils/mono-dl-posix.c @@ -134,15 +134,7 @@ mono_dl_convert_flags (int mono_flags, int native_flags) { int lflags = native_flags; -#ifdef ENABLE_NETCORE - // Specifying both will default to LOCAL - if (mono_flags & MONO_DL_GLOBAL && !(mono_flags & MONO_DL_LOCAL)) - lflags |= RTLD_GLOBAL; - else - lflags |= RTLD_LOCAL; -#else lflags = mono_flags & MONO_DL_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL; -#endif if (mono_flags & MONO_DL_LAZY) lflags |= RTLD_LAZY; diff --git a/mono/utils/mono-dl-wasm.c b/mono/utils/mono-dl-wasm.c index 333d54db799..3a904f04bca 100644 --- a/mono/utils/mono-dl-wasm.c +++ b/mono/utils/mono-dl-wasm.c @@ -62,15 +62,7 @@ mono_dl_convert_flags (int mono_flags, int native_flags) { int lflags = native_flags; -#ifdef ENABLE_NETCORE - // Specifying both will default to LOCAL - if (mono_flags & MONO_DL_GLOBAL && !(mono_flags & MONO_DL_LOCAL)) - lflags |= RTLD_GLOBAL; - else - lflags |= RTLD_LOCAL; -#else lflags = mono_flags & MONO_DL_LOCAL ? RTLD_LOCAL : RTLD_GLOBAL; -#endif if (mono_flags & MONO_DL_LAZY) lflags |= RTLD_LAZY; diff --git a/mono/utils/mono-dl.c b/mono/utils/mono-dl.c index ab4712778e2..92b0f07a0a3 100644 --- a/mono/utils/mono-dl.c +++ b/mono/utils/mono-dl.c @@ -21,9 +21,6 @@ #include <ctype.h> #include <string.h> #include <glib.h> -#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) -#include <dlfcn.h> -#endif // Contains LIBC_SO definition #ifdef HAVE_GNU_LIB_NAMES_H @@ -151,25 +148,6 @@ get_dl_name_from_libtool (const char *libtool_file) return line; } -#ifdef ENABLE_NETCORE -static const char * -fix_libc_name (const char *name) -{ - if (name != NULL && strcmp (name, "libc") == 0) { - // Taken from CoreCLR: https://github.com/dotnet/coreclr/blob/6b0dab793260d36e35d66c82678c63046828d01b/src/pal/src/loader/module.cpp#L568-L576 -#if defined (HOST_DARWIN) - return "/usr/lib/libc.dylib"; -#elif defined (__FreeBSD__) - return "libc.so.7"; -#elif defined (LIBC_SO) - return LIBC_SO; -#else - return "libc.so"; -#endif - } - return name; -} -#endif /** * mono_dl_open_self: @@ -182,24 +160,7 @@ fix_libc_name (const char *name) MonoDl* mono_dl_open_self (char **error_msg) { -#if defined(ENABLE_NETCORE) && defined(TARGET_ANDROID) - MonoDl *module; - if (error_msg) - *error_msg = NULL; - module = (MonoDl *) g_malloc (sizeof (MonoDl)); - if (!module) { - if (error_msg) - *error_msg = g_strdup ("Out of memory"); - return NULL; - } - mono_refcount_init (module, NULL); - module->handle = RTLD_DEFAULT; - module->dl_fallback = NULL; - module->full_name = NULL; - return module; -#else return mono_dl_open (NULL, MONO_DL_LAZY, error_msg); -#endif } /** @@ -244,9 +205,6 @@ mono_dl_open_full (const char *name, int mono_flags, int native_flags, char **er } module->main_module = name == NULL? TRUE: FALSE; -#ifdef ENABLE_NETCORE - name = fix_libc_name (name); -#endif // No GC safe transition because this is called early in main.c lib = mono_dl_open_file (name, lflags); @@ -438,17 +396,9 @@ mono_dl_build_path (const char *directory, const char *name, void **iter) need_suffix = FALSE; suffix = ""; } else if (idx == 1) { -#ifdef ENABLE_NETCORE - /* netcore system libs have a suffix but no prefix */ - need_prefix = FALSE; - need_suffix = TRUE; - suffix = mono_dl_get_so_suffixes () [0]; - suffixlen = strlen (suffix); -#else suffix = mono_dl_get_so_suffixes () [idx - 1]; if (suffix [0] == '\0') return NULL; -#endif } else { /* Prefix.Name.suffix */ suffix = mono_dl_get_so_suffixes () [idx - 2]; diff --git a/mono/utils/mono-threads-posix.c b/mono/utils/mono-threads-posix.c index c3ddb64d565..78a171ab329 100644 --- a/mono/utils/mono-threads-posix.c +++ b/mono/utils/mono-threads-posix.c @@ -32,7 +32,7 @@ #include <errno.h> -#if !defined(ENABLE_NETCORE) && defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) +#if defined(HOST_ANDROID) && !defined(TARGET_ARM64) && !defined(TARGET_AMD64) // tkill was deprecated and removed in the recent versions of Android NDK #define USE_TKILL_ON_ANDROID 1 extern int tkill (pid_t tid, int signal); diff --git a/mono/utils/mono-threads-windows.c b/mono/utils/mono-threads-windows.c index faeecbba4c3..deb9321b54a 100644 --- a/mono/utils/mono-threads-windows.c +++ b/mono/utils/mono-threads-windows.c @@ -383,12 +383,7 @@ mono_threads_suspend_get_abort_signal (void) #if defined (HOST_WIN32) -#ifndef ENABLE_NETCORE #define MONO_WIN32_DEFAULT_NATIVE_STACK_SIZE (1024 * 1024) -#else -// Use default stack size on netcore. -#define MONO_WIN32_DEFAULT_NATIVE_STACK_SIZE 0 -#endif gboolean mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *tid) |