From adcf914a928844c973207a40e09348699ba670f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Thu, 9 Mar 2023 03:36:25 -0500 Subject: [PATCH] [metadata] make mono_method_get_param_names external only (#83183) --- src/mono/mono/component/debugger-agent.c | 2 +- src/mono/mono/metadata/class-internals.h | 3 +++ src/mono/mono/metadata/loader.c | 11 +++++++++++ src/mono/mono/metadata/reflection.c | 2 +- src/mono/mono/mini/debug-mini.c | 2 +- src/mono/mono/mini/dwarfwriter.c | 2 +- src/mono/mono/mini/mini-llvm.c | 4 ++-- .../public/mono/metadata/details/loader-functions.h | 2 +- 8 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 4d931284f02af..3df16f14f3d4a 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -8850,7 +8850,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g /* Emit parameter names */ names = g_new (char *, sig->param_count); - mono_method_get_param_names (method, (const char **) names); + mono_method_get_param_names_internal (method, (const char **) names); for (guint16 i = 0; i < sig->param_count; ++i) buffer_add_string (buf, names [i]); g_free (names); diff --git a/src/mono/mono/metadata/class-internals.h b/src/mono/mono/metadata/class-internals.h index e5cfb3916b6b5..1721e5f00195d 100644 --- a/src/mono/mono/metadata/class-internals.h +++ b/src/mono/mono/metadata/class-internals.h @@ -1433,6 +1433,9 @@ mono_method_has_no_body (MonoMethod *method); MONO_COMPONENT_API MonoMethodHeader* mono_method_get_header_internal (MonoMethod *method, MonoError *error); +MONO_COMPONENT_API void +mono_method_get_param_names_internal (MonoMethod *method, const char **names); + MonoType* mono_class_find_enum_basetype (MonoClass *klass, MonoError *error); diff --git a/src/mono/mono/metadata/loader.c b/src/mono/mono/metadata/loader.c index 3cd6bfb49af12..123753bf4c816 100644 --- a/src/mono/mono/metadata/loader.c +++ b/src/mono/mono/metadata/loader.c @@ -1411,6 +1411,17 @@ mono_free_method (MonoMethod *method) */ void mono_method_get_param_names (MonoMethod *method, const char **names) +{ + MONO_ENTER_GC_UNSAFE; + mono_method_get_param_names_internal (method, names); + MONO_EXIT_GC_UNSAFE; +} + +/** + * mono_method_get_param_names_internal: + */ +void +mono_method_get_param_names_internal (MonoMethod *method, const char **names) { int i, lastp; MonoClass *klass; diff --git a/src/mono/mono/metadata/reflection.c b/src/mono/mono/metadata/reflection.c index 07e5e39e244be..37898f954ff34 100644 --- a/src/mono/mono/metadata/reflection.c +++ b/src/mono/mono/metadata/reflection.c @@ -1087,7 +1087,7 @@ param_objects_construct (MonoClass *refclass, MonoMethodSignature **addr_of_sig, MonoReflectionMethodHandle member = mono_method_get_object_handle (method, refclass, error); goto_if_nok (error, leave); names = g_new (char *, sig->param_count); - mono_method_get_param_names (method, (const char **) names); + mono_method_get_param_names_internal (method, (const char **) names); mspecs = g_new (MonoMarshalSpec*, sig->param_count + 1); mono_method_get_marshal_info (method, mspecs); diff --git a/src/mono/mono/mini/debug-mini.c b/src/mono/mono/mini/debug-mini.c index 35026132703f3..f307d08bf7f51 100644 --- a/src/mono/mono/mini/debug-mini.c +++ b/src/mono/mono/mini/debug-mini.c @@ -673,7 +673,7 @@ mono_debug_print_vars (gpointer ip, gboolean only_arguments) if (only_arguments) { char **names; names = g_new (char *, jit->num_params); - mono_method_get_param_names (jinfo_get_method (ji), (const char **) names); + mono_method_get_param_names_internal (jinfo_get_method (ji), (const char **) names); if (jit->this_var) print_var_info (jit->this_var, 0, "this", "Arg"); for (guint32 i = 0; i < jit->num_params; ++i) { diff --git a/src/mono/mono/mini/dwarfwriter.c b/src/mono/mono/mini/dwarfwriter.c index bd6d2c35531fa..69f52fc70ceda 100644 --- a/src/mono/mono/mini/dwarfwriter.c +++ b/src/mono/mono/mini/dwarfwriter.c @@ -1805,7 +1805,7 @@ mono_dwarf_writer_emit_method (MonoDwarfWriter *w, MonoCompile *cfg, MonoMethod /* Subprogram */ names = g_new0 (char *, sig->param_count); - mono_method_get_param_names (method, (const char **) names); + mono_method_get_param_names_internal (method, (const char **) names); emit_uleb128 (w, ABBREV_SUBPROGRAM); /* DW_AT_name */ diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 9e1e3d61b0057..b811b276d673f 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -3900,7 +3900,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder) } names = g_new (char *, sig->param_count); - mono_method_get_param_names (cfg->method, (const char **) names); + mono_method_get_param_names_internal (cfg->method, (const char **) names); for (int i = 0; i < sig->param_count; ++i) { LLVMArgInfo *ainfo = &linfo->args [i + sig->hasthis]; @@ -12209,7 +12209,7 @@ emit_method_inner (EmitContext *ctx) LLVMSetValueName (LLVMGetParam (method, linfo->dummy_arg_pindex), "dummy_arg"); names = g_new (char *, sig->param_count); - mono_method_get_param_names (cfg->method, (const char **) names); + mono_method_get_param_names_internal (cfg->method, (const char **) names); /* Set parameter names/attributes */ for (int i = 0; i < sig->param_count; ++i) { diff --git a/src/native/public/mono/metadata/details/loader-functions.h b/src/native/public/mono/metadata/details/loader-functions.h index 67bd908adb911..11d86e785ba9f 100644 --- a/src/native/public/mono/metadata/details/loader-functions.h +++ b/src/native/public/mono/metadata/details/loader-functions.h @@ -44,7 +44,7 @@ MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY void, mono_dllmap_insert, (MonoImage *as MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY void*, mono_lookup_pinvoke_call, (MonoMethod *method, const char **exc_class, const char **exc_arg)) -MONO_API_FUNCTION(void, mono_method_get_param_names, (MonoMethod *method, const char **names)) +MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY void, mono_method_get_param_names, (MonoMethod *method, const char **names)) MONO_API_FUNCTION(uint32_t, mono_method_get_param_token, (MonoMethod *method, int idx))