Skip to content

Commit

Permalink
[metadata] Use MONO_PROFILER_API on MonoClass getters in checked buil…
Browse files Browse the repository at this point in the history
…ds (#42819)

In normal builds, the getters are `static inline` functions, so the profiler doesn't reference the symbols - it just accesses the fields by offset.

In checked builds with `--enable-checked-build=private_types`, the getters are not inlined, so the profiler shared libraries need the symbols to be visible.

Co-authored-by: lambdageek <lambdageek@users.noreply.github.com>
  • Loading branch information
monojenkins and lambdageek authored Oct 1, 2020
1 parent 5e5e923 commit eb91a96
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/mono/mono/metadata/class-abi-details.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
#include <mono/metadata/abi-details.h>

#define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) /*nothing*/
/*
* In-tree profilers are allowed to use the offset functions. So if we're
* compiling with --enable-checked-build=private_types, mark the symbols with
* MONO_PROFILER_API
*/
#ifdef MONO_CLASS_DEF_PRIVATE
#define MONO_CLASS_OFFSET(funcname, argtype, fieldname) intptr_t funcname (void);
#define MONO_CLASS_OFFSET(funcname, argtype, fieldname) MONO_PROFILER_API intptr_t funcname (void);
#else
#define MONO_CLASS_OFFSET(funcname, argtype, fieldname) static inline intptr_t funcname (void) { return MONO_STRUCT_OFFSET (argtype, fieldname); }
#endif
Expand Down
6 changes: 5 additions & 1 deletion src/mono/mono/metadata/class-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,13 @@ union _MonoClassSizes {

/* If MonoClass definition is hidden, just declare the getters.
* Otherwise, define them as static inline functions.
*
* In-tree profilers are allowed to use the getters. So if we're compiling
* with --enable-checked-build=private_types, mark the symbols with
* MONO_PROFILER_API
*/
#ifdef MONO_CLASS_DEF_PRIVATE
#define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) rettype funcname (argtype *klass);
#define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) MONO_PROFILER_API rettype funcname (argtype *klass);
#else
#define MONO_CLASS_GETTER(funcname, rettype, optref, argtype, fieldname) static inline rettype funcname (argtype *klass) { return optref klass-> fieldname ; }
#endif
Expand Down

0 comments on commit eb91a96

Please sign in to comment.