Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reflection] Remove sre-save and DISABLE_REFLECTION_EMIT_SAVE #47915

Merged
merged 2 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ set(MONO_CORLIB_VERSION 1A5E0066-58DC-428A-B21C-0AD6CDAE2789)
set(ENABLE_NETCORE 1)

set(DISABLE_REMOTING 1)
set(DISABLE_REFLECTION_EMIT_SAVE 1)
set(DISABLE_APPDOMAINS 1)
set(DISABLE_SHADOW_COPY 1)
set(DISABLE_CLEANUP 1)
Expand Down
3 changes: 0 additions & 3 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,6 @@
/* Disable reflection emit support */
#cmakedefine DISABLE_REFLECTION_EMIT 1

/* Disable assembly saving support in reflection emit */
#cmakedefine DISABLE_REFLECTION_EMIT_SAVE 1

/* Disable support for huge assemblies */
#cmakedefine DISABLE_LARGE_CODE 1

Expand Down
1 change: 0 additions & 1 deletion src/mono/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ option (DISABLE_DECIMAL "Disable System.Decimal support")
option (DISABLE_PINVOKE "Disable P/Invoke support")
option (DISABLE_DEBUG "Disable runtime debugging support")
option (DISABLE_REFLECTION_EMIT "Disable reflection emit support")
option (DISABLE_REFLECTION_EMIT_SAVE "Disable assembly saving support in reflection emit")
option (DISABLE_LARGE_CODE "Disable support for huge assemblies")
option (DISABLE_LOGGING "Disable support debug logging")
option (DISABLE_COM "Disable COM support")
Expand Down
1 change: 0 additions & 1 deletion src/mono/mono/metadata/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ set(metadata_common_sources
dynamic-image.c
sre.c
sre-encode.c
sre-save.c
custom-attrs.c
fdhandle.h
fdhandle.c
Expand Down
4 changes: 0 additions & 4 deletions src/mono/mono/metadata/object-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,6 @@ mono_internal_thread_handle_ptr (MonoInternalThreadHandle h)
return MONO_HANDLE_SUPPRESS (MONO_HANDLE_RAW (h));
}

gboolean mono_image_create_pefile (MonoReflectionModuleBuilder *module, gpointer file, MonoError *error);
guint32 mono_image_insert_string (MonoReflectionModuleBuilderHandle module, MonoStringHandle str, MonoError *error);
guint32 mono_image_create_token (MonoDynamicImage *assembly, MonoObjectHandle obj, gboolean create_methodspec, gboolean register_token, MonoError *error);
void mono_dynamic_image_free (MonoDynamicImage *image);
Expand Down Expand Up @@ -1734,9 +1733,6 @@ mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token, gboolean
gboolean
mono_reflection_call_is_assignable_to (MonoClass *klass, MonoClass *oklass, MonoError *error);

gboolean
mono_image_build_metadata (MonoReflectionModuleBuilder *module, MonoError *error);

gboolean
mono_get_constant_value_from_blob (MonoDomain* domain, MonoTypeEnum type, const char *blob, void *value, MonoStringHandleOut string_handle, MonoError *error);

Expand Down
175 changes: 0 additions & 175 deletions src/mono/mono/metadata/sre-encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,181 +1064,6 @@ type_get_fully_qualified_name (MonoType *type)
return mono_type_get_name_full (type, MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED);
}

#ifndef DISABLE_REFLECTION_EMIT_SAVE
guint32
mono_dynimage_save_encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;

error_init (error);

char *str;
SigBuffer buf;
guint32 idx, len;

sigbuffer_init (&buf, 32);

sigbuffer_add_value (&buf, minfo->type);

switch (minfo->type) {
case MONO_NATIVE_BYVALTSTR:
case MONO_NATIVE_BYVALARRAY:
sigbuffer_add_value (&buf, minfo->count);
break;
case MONO_NATIVE_LPARRAY:
if (minfo->eltype || minfo->has_size) {
sigbuffer_add_value (&buf, minfo->eltype);
if (minfo->has_size) {
sigbuffer_add_value (&buf, minfo->param_num != -1? minfo->param_num: 0);
sigbuffer_add_value (&buf, minfo->count != -1? minfo->count: 0);

/* LAMESPEC: ElemMult is undocumented */
sigbuffer_add_value (&buf, minfo->param_num != -1? 1: 0);
}
}
break;
case MONO_NATIVE_SAFEARRAY:
if (minfo->eltype)
sigbuffer_add_value (&buf, minfo->eltype);
break;
case MONO_NATIVE_CUSTOM:
if (minfo->guid) {
str = mono_string_to_utf8_checked_internal (minfo->guid, error);
if (!is_ok (error)) {
sigbuffer_free (&buf);
return 0;
}
len = strlen (str);
sigbuffer_add_value (&buf, len);
sigbuffer_add_mem (&buf, str, len);
g_free (str);
} else {
sigbuffer_add_value (&buf, 0);
}
/* native type name */
sigbuffer_add_value (&buf, 0);
/* custom marshaler type name */
if (minfo->marshaltype || minfo->marshaltyperef) {
if (minfo->marshaltyperef) {
MonoType *marshaltype = mono_reflection_type_get_handle ((MonoReflectionType*)minfo->marshaltyperef, error);
if (!is_ok (error)) {
sigbuffer_free (&buf);
return 0;
}
str = type_get_fully_qualified_name (marshaltype);
} else {
str = mono_string_to_utf8_checked_internal (minfo->marshaltype, error);
if (!is_ok (error)) {
sigbuffer_free (&buf);
return 0;
}
}
len = strlen (str);
sigbuffer_add_value (&buf, len);
sigbuffer_add_mem (&buf, str, len);
g_free (str);
} else {
/* FIXME: Actually a bug, since this field is required. Punting for now ... */
sigbuffer_add_value (&buf, 0);
}
if (minfo->mcookie) {
str = mono_string_to_utf8_checked_internal (minfo->mcookie, error);
if (!is_ok (error)) {
sigbuffer_free (&buf);
return 0;
}
len = strlen (str);
sigbuffer_add_value (&buf, len);
sigbuffer_add_mem (&buf, str, len);
g_free (str);
} else {
sigbuffer_add_value (&buf, 0);
}
break;
default:
break;
}
idx = sigbuffer_add_to_blob_cached (assembly, &buf);
sigbuffer_free (&buf);
return idx;
}

guint32
mono_dynimage_save_encode_property_signature (MonoDynamicImage *assembly, MonoReflectionPropertyBuilder *fb, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;

error_init (error);

SigBuffer buf;
guint32 nparams = 0;
MonoReflectionMethodBuilder *mb = fb->get_method;
MonoReflectionMethodBuilder *smb = fb->set_method;
guint32 idx, i;

if (mb && mb->parameters)
nparams = mono_array_length_internal (mb->parameters);
if (!mb && smb && smb->parameters)
nparams = mono_array_length_internal (smb->parameters) - 1;
sigbuffer_init (&buf, 32);
if (fb->call_conv & 0x20)
sigbuffer_add_byte (&buf, 0x28);
else
sigbuffer_add_byte (&buf, 0x08);
sigbuffer_add_value (&buf, nparams);
if (mb) {
encode_reflection_type_raw (assembly, (MonoReflectionType*)mb->rtype, &buf, error);
if (!is_ok (error))
goto fail;
for (i = 0; i < nparams; ++i) {
MonoReflectionType *pt = mono_array_get_internal (mb->parameters, MonoReflectionType*, i);
encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto fail;
}
} else if (smb && smb->parameters) {
/* the property type is the last param */
encode_reflection_type_raw (assembly, mono_array_get_internal (smb->parameters, MonoReflectionType*, nparams), &buf, error);
if (!is_ok (error))
goto fail;

for (i = 0; i < nparams; ++i) {
MonoReflectionType *pt = mono_array_get_internal (smb->parameters, MonoReflectionType*, i);
encode_reflection_type_raw (assembly, pt, &buf, error);
if (!is_ok (error))
goto fail;
}
} else {
encode_reflection_type_raw (assembly, (MonoReflectionType*)fb->type, &buf, error);
if (!is_ok (error))
goto fail;
}

idx = sigbuffer_add_to_blob_cached (assembly, &buf);
sigbuffer_free (&buf);
return idx;
fail:
sigbuffer_free (&buf);
return 0;
}


#else /*DISABLE_REFLECTION_EMIT_SAVE*/
guint32
mono_dynimage_save_encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo, MonoError *error)
{
g_assert_not_reached ();
return 0;
}

guint32
mono_dynimage_save_encode_property_signature (MonoDynamicImage *assembly, MonoReflectionPropertyBuilder *fb, MonoError *error)
{
g_assert_not_reached ();
return 0;
}
#endif /*DISABLE_REFLECTION_EMIT_SAVE*/

#ifndef DISABLE_REFLECTION_EMIT
MonoArrayHandle
ves_icall_SignatureHelper_get_signature_local (MonoReflectionSigHelperHandle sig, MonoError *error)
Expand Down
8 changes: 0 additions & 8 deletions src/mono/mono/metadata/sre-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,6 @@ guint32
mono_dynimage_encode_reflection_sighelper (MonoDynamicImage *assembly, MonoReflectionSigHelperHandle helper,
MonoError *error);

/* sre-encode, without DISABLE_REFLECTION_EMIT_SAVE (o.w. g_assert_not_reached ()) */

guint32
mono_dynimage_save_encode_marshal_blob (MonoDynamicImage *assembly, MonoReflectionMarshal *minfo, MonoError *error);

guint32
mono_dynimage_save_encode_property_signature (MonoDynamicImage *assembly, MonoReflectionPropertyBuilder *fb, MonoError *error);

guint32
mono_image_get_methodref_token (MonoDynamicImage *assembly, MonoMethod *method, gboolean create_typespec);

Expand Down
Loading