diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index d3137f27a8bd2c..cdff32677c0f5c 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -20,9 +20,6 @@ set(CMAKE_CXX_FLAGS_CHECKED "") set(CMAKE_EXE_LINKER_FLAGS_CHECKED "") set(CMAKE_SHARED_LINKER_FLAGS_CHECKED "") -# This is always enabled now, and we should go through the code to remove the case here it is not defined -set(ENABLE_ILGEN 1) - if(NOT MONO_LIB_NAME) set(MONO_LIB_NAME "monosgen-2.0") endif() diff --git a/src/mono/cmake/config.h.in b/src/mono/cmake/config.h.in index 71753f1d47e097..f53d12433aae82 100644 --- a/src/mono/cmake/config.h.in +++ b/src/mono/cmake/config.h.in @@ -260,9 +260,6 @@ /* Disable the interpreter. */ #cmakedefine DISABLE_INTERPRETER 1 -/* Some VES is available at runtime */ -#cmakedefine ENABLE_ILGEN 1 - /* Disable non-blittable marshalling */ #cmakedefine DISABLE_NONBLITTABLE diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index d83c9144af07f9..ef815af4782478 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -93,8 +93,6 @@ list(APPEND components_for_aot set(${MONO_MARSHAL_ILGEN_COMPONENT_NAME}-sources ${MONO_COMPONENT_PATH}/marshal-ilgen.c ${MONO_COMPONENT_PATH}/marshal-ilgen.h - ${MONO_COMPONENT_PATH}/marshal-ilgen-noilgen.c - ${MONO_COMPONENT_PATH}/marshal-ilgen-noilgen.h ) # For every component not build into the AOT compiler, build the stub instead diff --git a/src/mono/mono/component/marshal-ilgen-internals.h b/src/mono/mono/component/marshal-ilgen-internals.h index 558a4d7478aa64..f0742610eda699 100644 --- a/src/mono/mono/component/marshal-ilgen-internals.h +++ b/src/mono/mono/component/marshal-ilgen-internals.h @@ -3,7 +3,4 @@ #include "mono/component/marshal-ilgen.h" -void -mono_install_marshal_callbacks_ilgen (MonoMarshalILgenCallbacks *cb); - -#endif // __MARSHAL_ILGEN_INTERNALS_H__ \ No newline at end of file +#endif // __MARSHAL_ILGEN_INTERNALS_H__ diff --git a/src/mono/mono/component/marshal-ilgen-noilgen.c b/src/mono/mono/component/marshal-ilgen-noilgen.c deleted file mode 100644 index e3fd19e95c6dab..00000000000000 --- a/src/mono/mono/component/marshal-ilgen-noilgen.c +++ /dev/null @@ -1,187 +0,0 @@ -#include "mono/component/marshal-ilgen.h" -#include "mono/component/marshal-ilgen-internals.h" -#include "mono/component/marshal-ilgen-noilgen.h" - -#ifndef ENABLE_ILGEN -static int -emit_marshal_array_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - MonoType *object_type = mono_get_object_type (); - switch (action) { - case MARSHAL_ACTION_CONV_IN: - *conv_arg_type = object_type; - break; - case MARSHAL_ACTION_MANAGED_CONV_IN: - *conv_arg_type = int_type; - break; - } - return conv_arg; -} - -static int -emit_marshal_ptr_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, int conv_arg, - MonoType **conv_arg_type, MarshalAction action) -{ - return conv_arg; -} -#endif - -#if !defined(ENABLE_ILGEN) || defined(DISABLE_NONBLITTABLE) -static int -emit_marshal_vtype_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - return conv_arg; -} - -static int -emit_marshal_string_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - switch (action) { - case MARSHAL_ACTION_CONV_IN: - *conv_arg_type = int_type; - break; - case MARSHAL_ACTION_MANAGED_CONV_IN: - *conv_arg_type = int_type; - break; - } - return conv_arg; -} - -static int -emit_marshal_safehandle_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, int conv_arg, - MonoType **conv_arg_type, MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - if (action == MARSHAL_ACTION_CONV_IN) - *conv_arg_type = int_type; - return conv_arg; -} - -static int -emit_marshal_handleref_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, int conv_arg, - MonoType **conv_arg_type, MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - if (action == MARSHAL_ACTION_CONV_IN) - *conv_arg_type = int_type; - return conv_arg; -} - -static int -emit_marshal_object_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - if (action == MARSHAL_ACTION_CONV_IN) - *conv_arg_type = int_type; - return conv_arg; -} - -static int -emit_marshal_variant_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - g_assert_not_reached (); -} - -static int -emit_marshal_asany_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - return conv_arg; -} - -static int -emit_marshal_boolean_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - switch (action) { - case MARSHAL_ACTION_CONV_IN: - if (m_type_is_byref (t)) - *conv_arg_type = int_type; - else - *conv_arg_type = mono_marshal_boolean_conv_in_get_local_type (spec, NULL); - break; - - case MARSHAL_ACTION_MANAGED_CONV_IN: { - MonoClass* conv_arg_class = mono_marshal_boolean_managed_conv_in_get_conv_arg_class (spec, NULL); - if (m_type_is_byref (t)) - *conv_arg_type = m_class_get_this_arg (conv_arg_class); - else - *conv_arg_type = m_class_get_byval_arg (conv_arg_class); - break; - } - - } - return conv_arg; -} - -static int -emit_marshal_char_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, int conv_arg, - MonoType **conv_arg_type, MarshalAction action) -{ - return conv_arg; -} - -static int -emit_marshal_custom_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, - int conv_arg, MonoType **conv_arg_type, - MarshalAction action) -{ - MonoType *int_type = mono_get_int_type (); - if (action == MARSHAL_ACTION_CONV_IN && t->type == MONO_TYPE_VALUETYPE) - *conv_arg_type = int_type; - return conv_arg; -} -#endif - -#ifndef ENABLE_ILGEN - -void -mono_marshal_noilgen_init_heavyweight (void) -{ - MonoMarshalILgenCallbacks ilgen_cb; - - ilgen_cb.version = MONO_MARSHAL_CALLBACKS_VERSION; - ilgen_cb.emit_marshal_array = emit_marshal_array_noilgen; - ilgen_cb.emit_marshal_vtype = emit_marshal_vtype_noilgen; - ilgen_cb.emit_marshal_string = emit_marshal_string_noilgen; - ilgen_cb.emit_marshal_safehandle = emit_marshal_safehandle_noilgen; - ilgen_cb.emit_marshal_handleref = emit_marshal_handleref_noilgen; - ilgen_cb.emit_marshal_object = emit_marshal_object_noilgen; - ilgen_cb.emit_marshal_variant = emit_marshal_variant_noilgen; - ilgen_cb.emit_marshal_asany = emit_marshal_asany_noilgen; - ilgen_cb.emit_marshal_boolean = emit_marshal_boolean_noilgen; - ilgen_cb.emit_marshal_custom = emit_marshal_custom_noilgen; - ilgen_cb.emit_marshal_ptr = emit_marshal_ptr_noilgen; - - ilgen_cb.emit_marshal_char = emit_marshal_char_noilgen; - mono_install_marshal_callbacks_ilgen(&ilgen_cb); -} - -#endif \ No newline at end of file diff --git a/src/mono/mono/component/marshal-ilgen-noilgen.h b/src/mono/mono/component/marshal-ilgen-noilgen.h deleted file mode 100644 index 5e877c223833c7..00000000000000 --- a/src/mono/mono/component/marshal-ilgen-noilgen.h +++ /dev/null @@ -1,11 +0,0 @@ -/** - * \file - * Copyright 2022 Microsoft - * Licensed under the MIT license. See LICENSE file in the project root for full license information. - */ -#ifndef __MARSHAL_ILGEN_NOILGEN_H__ -#define __MARSHAL_ILGEN_NOILGEN_H__ - -void mono_marshal_noilgen_init_heavyweight (void); - -#endif // __MARSHAL_ILGEN_NOILGEN_H__ \ No newline at end of file diff --git a/src/mono/mono/component/marshal-ilgen.c b/src/mono/mono/component/marshal-ilgen.c index 3d36a3c45d6931..2c928af78f06f8 100644 --- a/src/mono/mono/component/marshal-ilgen.c +++ b/src/mono/mono/component/marshal-ilgen.c @@ -4,7 +4,6 @@ #include "component/marshal-ilgen.h" #include "mono/component/marshal-ilgen.h" #include "mono/component/marshal-ilgen-internals.h" -#include "mono/component/marshal-ilgen-noilgen.h" #include "metadata/marshal-lightweight.h" #include "metadata/marshal-shared.h" #include "metadata/method-builder-ilgen.h" @@ -33,8 +32,6 @@ static void emit_string_free_icall (MonoMethodBuilder *mb, MonoMarshalConv conv) static void mono_marshal_ilgen_legacy_init (void); -static MonoMarshalILgenCallbacks ilgen_marshal_cb; - static IlgenCallbacksToMono *cb_to_mono; static void ilgen_init_internal (void); @@ -57,9 +54,6 @@ static MonoComponentMarshalILgen component_func_table = { &ilgen_init_internal, &emit_marshal_ilgen, &ilgen_install_callbacks_mono, -#ifndef ENABLE_ILGEN - &mono_marshal_noilgen_init_heavyweight -#endif }; @@ -69,18 +63,6 @@ mono_component_marshal_ilgen_init (void) return &component_func_table; } -static gboolean ilgen_cb_inited = FALSE; -static MonoMarshalILgenCallbacks ilgen_marshal_cb; - -void -mono_install_marshal_callbacks_ilgen (MonoMarshalILgenCallbacks *cb) -{ - g_assert (!ilgen_cb_inited); - g_assert (cb->version == MONO_MARSHAL_CALLBACKS_VERSION); - memcpy (&ilgen_marshal_cb, cb, sizeof (MonoMarshalILgenCallbacks)); - ilgen_cb_inited = TRUE; -} - static void ilgen_install_callbacks_mono (IlgenCallbacksToMono *callbacks) { @@ -126,10 +108,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.emit_icall_id (mb, cb_to_mono->conv_to_icall (MONO_MARSHAL_CONV_ARRAY_LPARRAY, NULL)); cb_to_mono->methodBuilder.emit_stloc (mb, conv_arg); } else { -#ifdef DISABLE_NONBLITTABLE - char *msg = g_strdup ("Non-blittable marshalling conversion is disabled"); - cb_to_mono->methodBuilder.emit_exception_marshal_directive (mb, msg); -#else guint32 label1, label2, label3; int index_var, src_var, dest_ptr, esize; MonoMarshalConv conv; @@ -241,13 +219,11 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, } cb_to_mono->methodBuilder.patch_branch (mb, label1); -#endif } break; case MARSHAL_ACTION_CONV_OUT: { -#ifndef DISABLE_NONBLITTABLE gboolean need_convert, need_free; /* Unicode character arrays are implicitly marshalled as [Out] under MS.NET */ need_convert = ((eklass == cb_to_mono->mono_defaults->char_class) && (encoding == MONO_NATIVE_LPWSTR)) || (eklass == cb_to_mono->try_get_stringbuilder_class ()) || (t->attrs & PARAM_ATTRIBUTE_OUT); @@ -387,7 +363,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.patch_branch (mb, label1); cb_to_mono->methodBuilder.patch_branch (mb, label3); } -#endif if (m_class_is_blittable (eklass)) { /* free memory allocated (if any) by MONO_MARSHAL_CONV_ARRAY_LPARRAY */ @@ -474,7 +449,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, /* FIXME: Optimize blittable case */ -#ifndef DISABLE_NONBLITTABLE if (eklass == cb_to_mono->mono_defaults->string_class) { is_string = TRUE; gboolean need_free; @@ -487,7 +461,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, } else conv = MONO_MARSHAL_CONV_INVALID; -#endif cb_to_mono->load_type_info (eklass); @@ -570,12 +543,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.patch_branch (mb, label1); break; } -#ifdef DISABLE_NONBLITTABLE - else { - char *msg = g_strdup ("Non-blittable marshalling conversion is disabled"); - cb_to_mono->methodBuilder.emit_exception_marshal_directive (mb, msg); - } -#else /* Emit marshalling loop */ index_var = cb_to_mono->methodBuilder.add_local (mb, int_type); cb_to_mono->methodBuilder.emit_byte (mb, CEE_LDC_I4_0); @@ -612,7 +579,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.patch_branch (mb, label1); cb_to_mono->methodBuilder.patch_branch (mb, label3); -#endif break; } @@ -646,7 +612,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, /* FIXME: Optimize blittable case */ -#ifndef DISABLE_NONBLITTABLE if (eklass == cb_to_mono->mono_defaults->string_class) { is_string = TRUE; conv = cb_to_mono->get_string_to_ptr_conv (m->piinfo, spec); @@ -657,7 +622,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, } else conv = MONO_MARSHAL_CONV_INVALID; -#endif cb_to_mono->load_type_info (eklass); @@ -694,7 +658,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, break; } -#ifndef DISABLE_NONBLITTABLE /* Emit marshalling loop */ index_var = cb_to_mono->methodBuilder.add_local (mb, int_type); cb_to_mono->methodBuilder.emit_byte (mb, CEE_LDC_I4_0); @@ -735,12 +698,10 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.patch_branch (mb, label1); cb_to_mono->methodBuilder.patch_branch (mb, label3); -#endif break; } case MARSHAL_ACTION_MANAGED_CONV_RESULT: { -#ifndef DISABLE_NONBLITTABLE guint32 label1, label2, label3; int index_var, src, dest, esize; MonoMarshalConv conv = MONO_MARSHAL_CONV_INVALID; @@ -832,7 +793,6 @@ emit_marshal_array_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, cb_to_mono->methodBuilder.patch_branch (mb, label3); cb_to_mono->methodBuilder.patch_branch (mb, label1); -#endif break; } default: @@ -2760,37 +2720,30 @@ emit_marshal_variant_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, } -static MonoMarshalILgenCallbacks * -get_marshal_cb (void) -{ - g_assert(ilgen_cb_inited); - return &ilgen_marshal_cb; -} - static int emit_marshal_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action, MonoMarshalLightweightCallbacks* lightweigth_cb) { if (spec && spec->native == MONO_NATIVE_CUSTOM) - return get_marshal_cb ()->emit_marshal_custom (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_custom_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); if (spec && spec->native == MONO_NATIVE_ASANY) - return get_marshal_cb ()->emit_marshal_asany (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_asany_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); switch (t->type) { case MONO_TYPE_VALUETYPE: if (t->data.klass == cb_to_mono->class_try_get_handleref_class ()) - return get_marshal_cb ()->emit_marshal_handleref (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_handleref_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); - return get_marshal_cb ()->emit_marshal_vtype (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_vtype_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_STRING: - return get_marshal_cb ()->emit_marshal_string (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_string_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_CLASS: case MONO_TYPE_OBJECT: #if !defined(DISABLE_COM) if (spec && spec->native == MONO_NATIVE_STRUCT) - return get_marshal_cb ()->emit_marshal_variant (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_variant_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); #endif #if !defined(DISABLE_COM) @@ -2807,18 +2760,18 @@ emit_marshal_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, if (cb_to_mono->try_get_safehandle_class () != NULL && t->data.klass && cb_to_mono->is_subclass_of_internal (t->data.klass, cb_to_mono->try_get_safehandle_class (), FALSE)) - return get_marshal_cb ()->emit_marshal_safehandle (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_safehandle_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); - return get_marshal_cb ()->emit_marshal_object (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_object_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_ARRAY: case MONO_TYPE_SZARRAY: - return get_marshal_cb ()->emit_marshal_array (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_array_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_BOOLEAN: - return get_marshal_cb ()->emit_marshal_boolean (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_boolean_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_PTR: - return get_marshal_cb ()->emit_marshal_ptr (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_ptr_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_CHAR: - return get_marshal_cb ()->emit_marshal_char (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_char_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_I1: case MONO_TYPE_U1: case MONO_TYPE_I2: @@ -2835,9 +2788,9 @@ emit_marshal_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, return lightweigth_cb->emit_marshal_scalar (m, argnum, t, spec, conv_arg, conv_arg_type, action); case MONO_TYPE_GENERICINST: if (mono_type_generic_inst_is_valuetype (t)) - return get_marshal_cb ()->emit_marshal_vtype (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_vtype_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); else - return get_marshal_cb ()->emit_marshal_object (m, argnum, t, spec, conv_arg, conv_arg_type, action); + return emit_marshal_object_ilgen (m, argnum, t, spec, conv_arg, conv_arg_type, action); default: return conv_arg; } @@ -2846,26 +2799,6 @@ emit_marshal_ilgen (EmitMarshalContext *m, int argnum, MonoType *t, static void ilgen_init_internal (void) { - - MonoMarshalILgenCallbacks cb; - cb.version = MONO_MARSHAL_CALLBACKS_VERSION; - cb.emit_marshal_array = emit_marshal_array_ilgen; - cb.emit_marshal_ptr = emit_marshal_ptr_ilgen; - cb.emit_marshal_char = emit_marshal_char_ilgen; - cb.emit_marshal_vtype = emit_marshal_vtype_ilgen; - cb.emit_marshal_string = emit_marshal_string_ilgen; - cb.emit_marshal_variant = emit_marshal_variant_ilgen; - cb.emit_marshal_safehandle = emit_marshal_safehandle_ilgen; - cb.emit_marshal_object = emit_marshal_object_ilgen; - cb.emit_marshal_boolean = emit_marshal_boolean_ilgen; - cb.emit_marshal_custom = emit_marshal_custom_ilgen; - cb.emit_marshal_asany = emit_marshal_asany_ilgen; - cb.emit_marshal_handleref = emit_marshal_handleref_ilgen; - -#ifdef DISABLE_NONBLITTABLE - mono_marshal_noilgen_init_blittable (&cb); -#endif - mono_install_marshal_callbacks_ilgen (&cb); } diff --git a/src/mono/mono/component/marshal-ilgen.h b/src/mono/mono/component/marshal-ilgen.h index bee078a5187f16..b737a526cfeb6e 100644 --- a/src/mono/mono/component/marshal-ilgen.h +++ b/src/mono/mono/component/marshal-ilgen.h @@ -10,10 +10,6 @@ #include "metadata/marshal.h" #include "mono/component/component.h" -#if !defined(ENABLE_ILGEN) -# error ENABLE_ILGEN is always required now -#endif - typedef struct MonoComponentMarshalILgen { MonoComponent component; void (*ilgen_init_internal) (void); @@ -21,28 +17,9 @@ typedef struct MonoComponentMarshalILgen { MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action, MonoMarshalLightweightCallbacks* lightweigth_cb); void (*install_callbacks_mono) (IlgenCallbacksToMono *callbacks); -#ifndef ENABLE_ILGEN - void (*noilgen_init_heavyweight) (void); -#endif } MonoComponentMarshalILgen; -typedef struct { - int version; - int (*emit_marshal_vtype) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_string) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_variant) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_safehandle) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_object) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_array) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_boolean) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_ptr) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_char) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_custom) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_asany) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); - int (*emit_marshal_handleref) (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, MonoType **conv_arg_type, MarshalAction action); -} MonoMarshalILgenCallbacks; - MONO_COMPONENT_EXPORT_ENTRYPOINT MonoComponentMarshalILgen* mono_component_marshal_ilgen_init (void); -#endif // __MARSHAL_ILGEN_H__ \ No newline at end of file +#endif // __MARSHAL_ILGEN_H__ diff --git a/src/mono/mono/metadata/CMakeLists.txt b/src/mono/mono/metadata/CMakeLists.txt index 69394f0aba1d08..cd1a8df43aea30 100644 --- a/src/mono/mono/metadata/CMakeLists.txt +++ b/src/mono/mono/metadata/CMakeLists.txt @@ -23,15 +23,7 @@ set(ilgen_base_sources sgen-mono-ilgen.c sgen-mono-ilgen.h) -if(NOT ENABLE_ILGEN) - addprefix(mono_ilgen_sources ../metadata "${ilgen_base_sources}") - set_source_files_properties(${mono_ilgen_sources} PROPERTIES COMPILE_DEFINITIONS "HAVE_SGEN_GC") - add_library(mono-ilgen STATIC "${mono_ilgen_sources}") - target_link_libraries(mono-ilgen monoapi) - install(TARGETS mono-ilgen LIBRARY) -else() - set(ilgen_sources ${ilgen_base_sources}) -endif() +set(ilgen_sources ${ilgen_base_sources}) set(metadata_win32_sources w32event-win32.c) @@ -94,8 +86,6 @@ set(metadata_common_sources marshal.c marshal.h marshal-internals.h - marshal-noilgen.c - marshal-noilgen.h mempool.c mempool.h mempool-internals.h diff --git a/src/mono/mono/metadata/external-only.c b/src/mono/mono/metadata/external-only.c index 9adadc9f631adc..93a43ff80ca9b3 100644 --- a/src/mono/mono/metadata/external-only.c +++ b/src/mono/mono/metadata/external-only.c @@ -742,3 +742,47 @@ mono_method_get_unmanaged_callers_only_ftnptr (MonoMethod *method, MonoError *er { MONO_EXTERNAL_ONLY_GC_UNSAFE (gpointer, mono_method_get_unmanaged_wrapper_ftnptr_internal (method, TRUE, error)); } + +void +mono_marshal_ilgen_init (void) +{ +} + +/* + * The mono_win32_compat_* functions are implementations of inline + * Windows kernel32 APIs, which are DllImport-able under MS.NET, + * although not exported by kernel32. + * + * We map the appropriate kernel32 entries to these functions using + * dllmaps declared in the global etc/mono/config. + */ + +void +mono_win32_compat_CopyMemory (gpointer dest, gconstpointer source, gsize length) +{ + if (!dest || !source) + return; + + memcpy (dest, source, length); +} + +void +mono_win32_compat_FillMemory (gpointer dest, gsize length, guchar fill) +{ + memset (dest, fill, length); +} + +void +mono_win32_compat_MoveMemory (gpointer dest, gconstpointer source, gsize length) +{ + if (!dest || !source) + return; + + memmove (dest, source, length); +} + +void +mono_win32_compat_ZeroMemory (gpointer dest, gsize length) +{ + memset (dest, 0, length); +} diff --git a/src/mono/mono/metadata/marshal-internals.h b/src/mono/mono/metadata/marshal-internals.h index 7d8fa9b0a7fbd1..28b720eb4339e8 100644 --- a/src/mono/mono/metadata/marshal-internals.h +++ b/src/mono/mono/metadata/marshal-internals.h @@ -20,7 +20,4 @@ typedef enum { void mono_marshal_noilgen_init (void); -void -mono_marshal_noilgen_init_blittable (MonoMarshalLightweightCallbacks *cb); - #endif /* __MONO_METADATA_MARSHAL_INTERNALS_H__ */ diff --git a/src/mono/mono/metadata/marshal-lightweight.c b/src/mono/mono/metadata/marshal-lightweight.c index a5cd09f4efac70..964fd84823a6c5 100644 --- a/src/mono/mono/metadata/marshal-lightweight.c +++ b/src/mono/mono/metadata/marshal-lightweight.c @@ -68,19 +68,6 @@ get_method_image (MonoMethod *method) return m_class_get_image (method->klass); } -static gboolean ilgen_callbacks_requested = FALSE; -MONO_API void -mono_marshal_ilgen_init (void) -{ - ilgen_callbacks_requested = TRUE; -} - -gboolean -mono_marshal_is_ilgen_requested (void) -{ - return ilgen_callbacks_requested; -} - /** * mono_mb_strdup: * \param mb the MethodBuilder @@ -1010,6 +997,7 @@ emit_native_wrapper_ilgen (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSi klass = mono_class_from_mono_type_internal (sig->ret); mono_class_init_internal (klass); if (!(mono_class_is_explicit_layout (klass) || m_class_is_blittable (klass))) { + /* TODO: marshal-lightweight: can this move to marshal-ilgen? */ /* This is used by emit_marshal_vtype (), but it needs to go right before the call */ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); mono_mb_emit_byte (mb, CEE_MONO_VTADDR); @@ -2609,6 +2597,7 @@ emit_managed_wrapper_ilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_s MonoClass *klass = mono_class_from_mono_type_internal (sig->ret); mono_class_init_internal (klass); if (!(mono_class_is_explicit_layout (klass) || m_class_is_blittable (klass))) { + /* TODO: marshal-lightweight: can this move to marshal-ilgen? */ /* This is used by get_marshal_cb ()->emit_marshal_vtype (), but it needs to go right before the call */ mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX); mono_mb_emit_byte (mb, CEE_MONO_VTADDR); @@ -3149,8 +3138,5 @@ mono_marshal_lightweight_init (void) cb.mb_emit_exception_for_error = mb_emit_exception_for_error_ilgen; cb.mb_emit_byte = mb_emit_byte_ilgen; cb.emit_marshal_directive_exception = emit_marshal_directive_exception_ilgen; -#ifdef DISABLE_NONBLITTABLE - mono_marshal_noilgen_init_blittable (&cb); -#endif mono_install_marshal_callbacks (&cb); } diff --git a/src/mono/mono/metadata/marshal-lightweight.h b/src/mono/mono/metadata/marshal-lightweight.h index 18ddfd1331d76a..83eb1b45dcbb54 100644 --- a/src/mono/mono/metadata/marshal-lightweight.h +++ b/src/mono/mono/metadata/marshal-lightweight.h @@ -10,7 +10,7 @@ MONO_API void mono_marshal_lightweight_init (void); -MONO_API void +MONO_API MONO_RT_EXTERNAL_ONLY void mono_marshal_ilgen_init (void); gboolean diff --git a/src/mono/mono/metadata/marshal-noilgen.c b/src/mono/mono/metadata/marshal-noilgen.c deleted file mode 100644 index 8d6f75981cd87d..00000000000000 --- a/src/mono/mono/metadata/marshal-noilgen.c +++ /dev/null @@ -1,283 +0,0 @@ -#include "config.h" -#include -#include -#include -#include -#include "utils/mono-compiler.h" - -#ifndef ENABLE_ILGEN - - - -static int -emit_marshal_scalar_noilgen (EmitMarshalContext *m, int argnum, MonoType *t, - MonoMarshalSpec *spec, int conv_arg, - MonoType **conv_arg_type, MarshalAction action) -{ - return conv_arg; -} -#endif - -#ifndef ENABLE_ILGEN -static void -emit_managed_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *invoke_sig, MonoMarshalSpec **mspecs, EmitMarshalContext* m, MonoMethod *method, MonoGCHandle target_handle, MonoError *error) -{ - MonoMethodSignature *sig, *csig; - int i; - MonoType *int_type = mono_get_int_type (); - - sig = m->sig; - csig = m->csig; - - /* we first do all conversions */ - for (i = 0; i < sig->param_count; i ++) { - MonoType *t = sig->params [i]; - - switch (t->type) { - case MONO_TYPE_OBJECT: - case MONO_TYPE_CLASS: - case MONO_TYPE_VALUETYPE: - case MONO_TYPE_ARRAY: - case MONO_TYPE_SZARRAY: - case MONO_TYPE_STRING: - case MONO_TYPE_BOOLEAN: - mono_emit_marshal (m, i, sig->params [i], mspecs [i + 1], 0, &csig->params [i], MARSHAL_ACTION_MANAGED_CONV_IN); - } - } - - if (!m_type_is_byref (sig->ret)) { - switch (sig->ret->type) { - case MONO_TYPE_STRING: - csig->ret = int_type; - break; - default: - break; - } - } -} - -static void -emit_synchronized_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethod *method, MonoGenericContext *ctx, MonoGenericContainer *container, MonoMethod *enter_method, MonoMethod *exit_method, MonoMethod *gettypefromhandle_method) -{ - if (m_class_is_valuetype (method->klass) && !(method->flags & MONO_METHOD_ATTR_STATIC)) { - /* FIXME Is this really the best way to signal an error here? Isn't this called much later after class setup? -AK */ - mono_class_set_type_load_failure (method->klass, ""); - return; - } - -} - -static void -emit_delegate_begin_invoke_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *sig) -{ -} - -static void -emit_delegate_end_invoke_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *sig) -{ -} - -static void -mb_skip_visibility_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -mb_set_dynamic_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -mb_emit_exception_noilgen (MonoMethodBuilder *mb, const char *exc_nspace, const char *exc_name, const char *msg) -{ -} - -static void -emit_marshal_directive_exception_noilgen (EmitMarshalContext *m, int argnum, const char* msg) -{ -} - -static void -mb_emit_exception_for_error_noilgen (MonoMethodBuilder *mb, const MonoError *error) -{ -} - -static void -emit_delegate_invoke_internal_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodSignature *invoke_sig, gboolean static_method_with_first_arg_bound, gboolean callvirt, gboolean closed_over_null, MonoMethod *method, MonoMethod *target_method, MonoClass *target_class, MonoGenericContext *ctx, MonoGenericContainer *container) -{ -} - -static void -emit_runtime_invoke_body_noilgen (MonoMethodBuilder *mb, const char **param_names, MonoImage *image, MonoMethod *method, - MonoMethodSignature *sig, MonoMethodSignature *callsig, - gboolean virtual_, gboolean need_direct_wrapper) -{ -} - -static void -emit_runtime_invoke_dynamic_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -emit_icall_wrapper_noilgen (MonoMethodBuilder *mb, MonoJitICallInfo *callinfo, MonoMethodSignature *csig2, gboolean check_exceptions) -{ -} - -static void -emit_return_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -emit_create_string_hack_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *csig, MonoMethod *res) -{ -} - -static void -emit_native_icall_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethod *method, MonoMethodSignature *csig, gboolean check_exceptions, gboolean aot, MonoMethodPInvoke *pinfo) -{ -} - -static void -emit_vtfixup_ftnptr_noilgen (MonoMethodBuilder *mb, MonoMethod *method, int param_count, guint16 type) -{ -} - -static void -emit_castclass_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -emit_isinst_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -emit_struct_to_ptr_noilgen (MonoMethodBuilder *mb, MonoClass *klass) -{ -} - -static void -emit_ptr_to_struct_noilgen (MonoMethodBuilder *mb, MonoClass *klass) -{ -} - -static void -emit_unbox_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethod *method) -{ -} - -static void -emit_virtual_stelemref_noilgen (MonoMethodBuilder *mb, const char **param_names, MonoStelemrefKind kind) -{ -} - -static void -emit_stelemref_noilgen (MonoMethodBuilder *mb) -{ -} - -static void -mb_emit_byte_noilgen (MonoMethodBuilder *mb, guint8 op) -{ -} - -static void -emit_array_address_noilgen (MonoMethodBuilder *mb, int rank, int elem_size) -{ -} - -static void -emit_array_accessor_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethod *method, MonoMethodSignature *sig, MonoGenericContext *ctx) -{ -} - -static void -emit_generic_array_helper_noilgen (MonoMethodBuilder *mb, MonoMethod *method, MonoMethodSignature *csig) -{ -} - -static void -emit_thunk_invoke_wrapper_noilgen (MonoMethodBuilder *mb, MonoMethod *method, MonoMethodSignature *csig) -{ -} - -static void -emit_native_wrapper_noilgen (MonoImage *image, MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethodPInvoke *piinfo, MonoMarshalSpec **mspecs, gpointer func, MonoNativeWrapperFlags flags) -{ -} - -void -mono_marshal_noilgen_init_lightweight (void) -{ - MonoMarshalLightweightCallbacks lightweight_cb; - - lightweight_cb.version = MONO_MARSHAL_CALLBACKS_VERSION; - lightweight_cb.emit_marshal_scalar = emit_marshal_scalar_noilgen; - lightweight_cb.emit_castclass = emit_castclass_noilgen; - lightweight_cb.emit_struct_to_ptr = emit_struct_to_ptr_noilgen; - lightweight_cb.emit_ptr_to_struct = emit_ptr_to_struct_noilgen; - lightweight_cb.emit_isinst = emit_isinst_noilgen; - lightweight_cb.emit_virtual_stelemref = emit_virtual_stelemref_noilgen; - lightweight_cb.emit_stelemref = emit_stelemref_noilgen; - lightweight_cb.emit_array_address = emit_array_address_noilgen; - lightweight_cb.emit_native_wrapper = emit_native_wrapper_noilgen; - lightweight_cb.emit_managed_wrapper = emit_managed_wrapper_noilgen; - lightweight_cb.emit_runtime_invoke_body = emit_runtime_invoke_body_noilgen; - lightweight_cb.emit_runtime_invoke_dynamic = emit_runtime_invoke_dynamic_noilgen; - lightweight_cb.emit_delegate_begin_invoke = emit_delegate_begin_invoke_noilgen; - lightweight_cb.emit_delegate_end_invoke = emit_delegate_end_invoke_noilgen; - lightweight_cb.emit_delegate_invoke_internal = emit_delegate_invoke_internal_noilgen; - lightweight_cb.emit_synchronized_wrapper = emit_synchronized_wrapper_noilgen; - lightweight_cb.emit_unbox_wrapper = emit_unbox_wrapper_noilgen; - lightweight_cb.emit_array_accessor_wrapper = emit_array_accessor_wrapper_noilgen; - lightweight_cb.emit_generic_array_helper = emit_generic_array_helper_noilgen; - lightweight_cb.emit_thunk_invoke_wrapper = emit_thunk_invoke_wrapper_noilgen; - lightweight_cb.emit_create_string_hack = emit_create_string_hack_noilgen; - lightweight_cb.emit_native_icall_wrapper = emit_native_icall_wrapper_noilgen; - lightweight_cb.emit_icall_wrapper = emit_icall_wrapper_noilgen; - lightweight_cb.emit_return = emit_return_noilgen; - lightweight_cb.emit_vtfixup_ftnptr = emit_vtfixup_ftnptr_noilgen; - lightweight_cb.mb_skip_visibility = mb_skip_visibility_noilgen; - lightweight_cb.mb_set_dynamic = mb_set_dynamic_noilgen; - lightweight_cb.mb_emit_exception = mb_emit_exception_noilgen; - lightweight_cb.mb_emit_exception_for_error = mb_emit_exception_for_error_noilgen; - lightweight_cb.emit_marshal_directive_exception = emit_marshal_directive_exception_noilgen; - lightweight_cb.mb_emit_byte = mb_emit_byte_noilgen; - - mono_install_marshal_callbacks (&lightweight_cb); - -} - -#else -void -mono_marshal_noilgen_init_lightweight (void) -{ -} - - -#endif - -#ifdef DISABLE_NONBLITTABLE -void -mono_marshal_noilgen_init_blittable (MonoMarshalCallbacks *cb) -{ - cb->emit_marshal_boolean = emit_marshal_boolean_noilgen; - cb->emit_marshal_char = emit_marshal_char_noilgen; - cb->emit_marshal_custom = emit_marshal_custom_noilgen; - cb->emit_marshal_asany = emit_marshal_asany_noilgen; - cb->emit_marshal_vtype = emit_marshal_vtype_noilgen; - cb->emit_marshal_string = emit_marshal_string_noilgen; - cb->emit_marshal_safehandle = emit_marshal_safehandle_noilgen; - cb->emit_marshal_handleref = emit_marshal_handleref_noilgen; - cb->emit_marshal_object = emit_marshal_object_noilgen; - cb->emit_marshal_variant = emit_marshal_variant_noilgen; -} -#else -void -mono_marshal_noilgen_init_blittable (MonoMarshalLightweightCallbacks *cb) -{ -} -#endif diff --git a/src/mono/mono/metadata/marshal-noilgen.h b/src/mono/mono/metadata/marshal-noilgen.h deleted file mode 100644 index c9cafee09fbbd7..00000000000000 --- a/src/mono/mono/metadata/marshal-noilgen.h +++ /dev/null @@ -1,15 +0,0 @@ -/** - * \file - * Copyright 2022 Microsoft - * Licensed under the MIT license. See LICENSE file in the project root for full license information. - */ -#ifndef __MARSHAL_NOILGEN_H__ -#define __MARSHAL_NOILGEN_H__ - -void -mono_marshal_noilgen_init_lightweight (void); - -void -mono_marshal_noilgen_init_heavyweight (void); - -#endif // __MARSHAL_NOILGEN_H__ \ No newline at end of file diff --git a/src/mono/mono/metadata/marshal.c b/src/mono/mono/metadata/marshal.c index 198c416a2d162a..bd8581e836d6bc 100644 --- a/src/mono/mono/metadata/marshal.c +++ b/src/mono/mono/metadata/marshal.c @@ -44,7 +44,6 @@ MONO_PRAGMA_WARNING_POP() #include "mono/metadata/components.h" #include "mono/metadata/debug-helpers.h" #include "mono/metadata/threads.h" -#include "mono/metadata/marshal-noilgen.h" #include "mono/metadata/monitor.h" #include "mono/metadata/class-init.h" #include "mono/metadata/class-internals.h" @@ -6103,45 +6102,6 @@ mono_marshal_get_generic_array_helper (MonoClass *klass, const gchar *name, Mono return res; } -/* - * The mono_win32_compat_* functions are implementations of inline - * Windows kernel32 APIs, which are DllImport-able under MS.NET, - * although not exported by kernel32. - * - * We map the appropriate kernel32 entries to these functions using - * dllmaps declared in the global etc/mono/config. - */ - -void -mono_win32_compat_CopyMemory (gpointer dest, gconstpointer source, gsize length) -{ - if (!dest || !source) - return; - - memcpy (dest, source, length); -} - -void -mono_win32_compat_FillMemory (gpointer dest, gsize length, guchar fill) -{ - memset (dest, fill, length); -} - -void -mono_win32_compat_MoveMemory (gpointer dest, gconstpointer source, gsize length) -{ - if (!dest || !source) - return; - - memmove (dest, source, length); -} - -void -mono_win32_compat_ZeroMemory (gpointer dest, gsize length) -{ - memset (dest, 0, length); -} - void mono_marshal_find_nonzero_bit_offset (guint8 *buf, int len, int *byte_offset, guint8 *bitmask) { diff --git a/src/mono/mono/metadata/marshal.h b/src/mono/mono/metadata/marshal.h index 163c8f0656e427..89b306d7def0c3 100644 --- a/src/mono/mono/metadata/marshal.h +++ b/src/mono/mono/metadata/marshal.h @@ -310,7 +310,7 @@ typedef enum { G_ENUM_FUNCTIONS(MonoNativeWrapperFlags); -#define MONO_MARSHAL_CALLBACKS_VERSION 6 +#define MONO_MARSHAL_CALLBACKS_VERSION 7 typedef struct { @@ -700,16 +700,16 @@ ICALL_EXPORT int ves_icall_System_Runtime_InteropServices_Marshal_ReleaseInternal (MonoIUnknown *pUnk); -MONO_API void +MONO_API MONO_RT_EXTERNAL_ONLY void mono_win32_compat_CopyMemory (gpointer dest, gconstpointer source, gsize length); -MONO_API void +MONO_API MONO_RT_EXTERNAL_ONLY void mono_win32_compat_FillMemory (gpointer dest, gsize length, guchar fill); -MONO_API void +MONO_API MONO_RT_EXTERNAL_ONLY void mono_win32_compat_MoveMemory (gpointer dest, gconstpointer source, gsize length); -MONO_API void +MONO_API MONO_RT_EXTERNAL_ONLY void mono_win32_compat_ZeroMemory (gpointer dest, gsize length); void diff --git a/src/mono/mono/metadata/method-builder.c b/src/mono/mono/metadata/method-builder.c index ee816e5900ceb7..3e940f45e9e2df 100644 --- a/src/mono/mono/metadata/method-builder.c +++ b/src/mono/mono/metadata/method-builder.c @@ -56,92 +56,6 @@ static MonoDisHelper marshal_dh = { static MonoMethodBuilderCallbacks mb_cb; static gboolean cb_inited = FALSE; -#ifndef ENABLE_ILGEN -static MonoMethodBuilder * -new_base_noilgen (MonoClass *klass, MonoWrapperType type) -{ - MonoMethodBuilder *mb; - MonoMethod *m; - - g_assert (klass != NULL); - - mb = g_new0 (MonoMethodBuilder, 1); - - mb->method = m = (MonoMethod *)g_new0 (MonoMethodWrapper, 1); - - m->klass = klass; - m->inline_info = 1; - m->wrapper_type = type; - - /* placeholder for the wrapper always at index 1 */ - mono_mb_add_data (mb, NULL); - - return mb; -} - -static void -free_noilgen (MonoMethodBuilder *mb) -{ - g_free (mb->method); - if (!mb->no_dup_name) - g_free (mb->name); - g_free (mb); -} - -static MonoMethod * -create_method_noilgen (MonoMethodBuilder *mb, MonoMethodSignature *signature, int max_stack) -{ - MonoMethodWrapper *mw; - MonoImage *image; - MonoMethod *method; - GList *l; - int i; - - g_assert (mb != NULL); - - image = m_class_get_image (mb->method->klass); - - { - /* Realloc the method info into a mempool */ - - method = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodWrapper)); - memcpy (method, mb->method, sizeof (MonoMethodWrapper)); - mw = (MonoMethodWrapper*) method; - - if (mb->no_dup_name) - method->name = mb->name; - else - method->name = mono_image_strdup (image, mb->name); - } - - method->signature = signature; - if (!signature->hasthis) - method->flags |= METHOD_ATTRIBUTE_STATIC; - - i = g_list_length ((GList *)mw->method_data); - if (i) { - GList *tmp; - void **data; - l = g_list_reverse ((GList *)mw->method_data); - if (method_is_dynamic (method)) - data = (void **)g_malloc (sizeof (gpointer) * (i + 1)); - else - data = (void **)mono_image_alloc (image, sizeof (gpointer) * (i + 1)); - /* store the size in the first element */ - data [0] = GUINT_TO_POINTER (i); - i = 1; - for (tmp = l; tmp; tmp = tmp->next) { - data [i++] = tmp->data; - } - g_list_free (l); - - mw->method_data = data; - } - - return method; -} -#endif - void mono_install_method_builder_callbacks (MonoMethodBuilderCallbacks *cb) { @@ -151,28 +65,11 @@ mono_install_method_builder_callbacks (MonoMethodBuilderCallbacks *cb) cb_inited = TRUE; } -#ifndef ENABLE_ILGEN -static void -install_noilgen (void) -{ - MonoMethodBuilderCallbacks cb; - cb.version = MONO_METHOD_BUILDER_CALLBACKS_VERSION; - cb.new_base = new_base_noilgen; - cb.free = free_noilgen; - cb.create_method = create_method_noilgen; - mono_install_method_builder_callbacks (&cb); -} -#endif - static MonoMethodBuilderCallbacks * get_mb_cb (void) { if (G_UNLIKELY (!cb_inited)) { -#ifdef ENABLE_ILGEN mono_method_builder_ilgen_init (); -#else - install_noilgen (); -#endif } return &mb_cb; } diff --git a/src/mono/mono/metadata/sgen-mono.c b/src/mono/mono/metadata/sgen-mono.c index 603f4e93a2ae15..446ddb2c2e65e2 100644 --- a/src/mono/mono/metadata/sgen-mono.c +++ b/src/mono/mono/metadata/sgen-mono.c @@ -254,39 +254,11 @@ mono_install_sgen_mono_callbacks (MonoSgenMonoCallbacks *cb) cb_inited = TRUE; } -#if !ENABLE_ILGEN - -static void -emit_nursery_check_noilgen (MonoMethodBuilder *mb, gboolean is_concurrent) -{ -} - -static void -emit_managed_allocator_noilgen (MonoMethodBuilder *mb, gboolean slowpath, gboolean profiler, int atype) -{ -} - -static void -install_noilgen (void) -{ - MonoSgenMonoCallbacks cb; - cb.version = MONO_SGEN_MONO_CALLBACKS_VERSION; - cb.emit_nursery_check = emit_nursery_check_noilgen; - cb.emit_managed_allocator = emit_managed_allocator_noilgen; - mono_install_sgen_mono_callbacks (&cb); -} - -#endif - static MonoSgenMonoCallbacks * get_sgen_mono_cb (void) { if (G_UNLIKELY (!cb_inited)) { -#ifdef ENABLE_ILGEN mono_sgen_mono_ilgen_init (); -#else - install_noilgen (); -#endif } return &sgenmono_cb; } diff --git a/src/mono/mono/mini/mini-generic-sharing.c b/src/mono/mono/mini/mini-generic-sharing.c index 8b9dee5522ec9b..a348a501e22db3 100644 --- a/src/mono/mono/mini/mini-generic-sharing.c +++ b/src/mono/mono/mini/mini-generic-sharing.c @@ -1503,12 +1503,10 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) memcpy (csig, sig, mono_metadata_signature_size (sig)); csig->param_count ++; csig->params [sig->param_count] = mono_get_int_type (); -#ifdef ENABLE_ILGEN char ** const param_names = g_new0 (char*, csig->param_count); for (int i = 0; i < sig->param_count; ++i) param_names [i] = g_strdup_printf ("%d", i); param_names [sig->param_count] = g_strdup ("ftndesc"); -#endif /* Create the signature for the gsharedvt callconv */ gsharedvt_sig = g_malloc0 (MONO_SIZEOF_METHOD_SIGNATURE + ((sig->param_count + 2) * sizeof (MonoType*))); @@ -1533,9 +1531,7 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) // FIXME: Use shared signatures mb = mono_mb_new (mono_defaults.object_class, sig->hasthis ? "gsharedvt_in_sig" : "gsharedvt_in_sig_static", MONO_WRAPPER_OTHER); -#ifdef ENABLE_ILGEN mono_mb_set_param_names (mb, (const char**)param_names); -#endif #ifndef DISABLE_JIT int retval_var = 0; @@ -1571,11 +1567,9 @@ mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig) info->d.gsharedvt.sig = sig; res = mono_mb_create (mb, csig, sig->param_count + 16, info); -#ifdef ENABLE_ILGEN for (int i = 0; i < sig->param_count + 1; ++i) g_free (param_names [i]); g_free (param_names); -#endif gshared_lock (); cached = (MonoMethod*)g_hash_table_lookup (cache, sig); @@ -1656,9 +1650,7 @@ mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig) // FIXME: Use shared signatures mb = mono_mb_new (mono_defaults.object_class, "gsharedvt_out_sig", MONO_WRAPPER_OTHER); -#ifdef ENABLE_ILGEN mono_mb_set_param_names (mb, (const char**)param_names); -#endif #ifndef DISABLE_JIT guint8 ldind_op, stind_op; diff --git a/src/mono/mono/mini/mini-runtime.c b/src/mono/mono/mini/mini-runtime.c index b285d51905cd20..f68c6a78bbd0fb 100644 --- a/src/mono/mono/mini/mini-runtime.c +++ b/src/mono/mono/mini/mini-runtime.c @@ -52,7 +52,6 @@ #include #include #include -#include #define MONO_MATH_DECLARE_ALL 1 #include #include @@ -4491,22 +4490,9 @@ mini_init (const char *filename) mono_ee_interp_init (mono_interp_opts_string); #endif -#ifdef ENABLE_ILGEN mono_marshal_lightweight_init (); mono_component_marshal_ilgen()->ilgen_init_internal (); mono_component_marshal_ilgen()->install_callbacks_mono(mono_marshal_get_mono_callbacks_for_ilgen()); -#else - if (mono_marshal_is_ilgen_requested ()) - { - mono_marshal_lightweight_init (); - mono_component_marshal_ilgen()->ilgen_init_internal (); - mono_component_marshal_ilgen()->install_callbacks_mono(mono_marshal_get_mono_callbacks_for_ilgen()); - } - else{ - mono_marshal_noilgen_init_lightweight(); - mono_component_marshal_ilgen()->noilgen_init_heavyweight (); - } -#endif mono_os_mutex_init_recursive (&jit_mutex);