From 23842a8148a44b4b2613bf1a98f51057ebb55599 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Sat, 21 Sep 2019 02:09:41 -0700 Subject: [PATCH] Partially inline mono_method_signature_checked/internal. (mono/mono#16927) * Inline common fast paths of mono_method_signature_checked and mono_method_signature_internal. * PR: Restore profilers to use mainstream functions. Commit migrated from https://github.com/mono/mono/commit/b20c690e3e96c16a7a5c4ab580060db4ccf28d86 --- src/mono/mono/metadata/class-internals.h | 29 +++++++++++++++++++++++++++-- src/mono/mono/metadata/loader.c | 10 ++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/metadata/class-internals.h b/src/mono/mono/metadata/class-internals.h index 1354655..a07a13f 100644 --- a/src/mono/mono/metadata/class-internals.h +++ b/src/mono/mono/metadata/class-internals.h @@ -14,6 +14,7 @@ #include "mono/utils/mono-compiler.h" #include "mono/utils/mono-error.h" #include "mono/sgen/gc-internal-agnostic.h" +#include "mono/utils/mono-error-internals.h" #define MONO_CLASS_IS_ARRAY(c) (m_class_get_rank (c)) @@ -847,10 +848,34 @@ MONO_PROFILER_API MonoGenericContext* mono_class_get_context (MonoClass *klass); MONO_PROFILER_API MonoMethodSignature* -mono_method_signature_checked (MonoMethod *m, MonoError *err); +mono_method_signature_checked_slow (MonoMethod *m, MonoError *err); MONO_PROFILER_API MonoMethodSignature* -mono_method_signature_internal (MonoMethod *m); +mono_method_signature_internal_slow (MonoMethod *m); + +/** + * mono_method_signature_checked: + * + * Return the signature of the method M. On failure, returns NULL, and ERR is set. + */ +static inline MonoMethodSignature* +mono_method_signature_checked (MonoMethod *m, MonoError *error) +{ + error_init (error); + MonoMethodSignature* sig = m->signature; + return sig ? sig : mono_method_signature_checked_slow (m, error); +} + +/** + * mono_method_signature_internal: + * \returns the signature of the method \p m. On failure, returns NULL. + */ +static inline MonoMethodSignature* +mono_method_signature_internal (MonoMethod *m) +{ + MonoMethodSignature* sig = m->signature; + return sig ? sig : mono_method_signature_internal_slow (m); +} MonoGenericContext* mono_method_get_context_general (MonoMethod *method, gboolean uninflated); diff --git a/src/mono/mono/metadata/loader.c b/src/mono/mono/metadata/loader.c index 7fa7fe6..095cb36 100644 --- a/src/mono/mono/metadata/loader.c +++ b/src/mono/mono/metadata/loader.c @@ -2670,12 +2670,13 @@ mono_loader_unlock_if_inited (void) } /** - * mono_method_signature_checked: + * mono_method_signature_checked_slow: * * Return the signature of the method M. On failure, returns NULL, and ERR is set. + * Call mono_method_signature_checked instead. */ MonoMethodSignature* -mono_method_signature_checked (MonoMethod *m, MonoError *error) +mono_method_signature_checked_slow (MonoMethod *m, MonoError *error) { int idx; MonoImage* img; @@ -2829,11 +2830,12 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error) } /** - * mono_method_signature_internal: + * mono_method_signature_internal_slow: * \returns the signature of the method \p m. On failure, returns NULL. + * Call mono_method_signature_internal instead. */ MonoMethodSignature* -mono_method_signature_internal (MonoMethod *m) +mono_method_signature_internal_slow (MonoMethod *m) { ERROR_DECL (error); MonoMethodSignature *sig = mono_method_signature_checked (m, error); -- 2.7.4