diff --git a/mfbt/Attributes.h b/mfbt/Attributes.h index 5744918ae283..1980619ab3bf 100644 --- a/mfbt/Attributes.h +++ b/mfbt/Attributes.h @@ -92,6 +92,15 @@ # define MOZ_NEVER_INLINE /* no support */ #endif +/* + * MOZ_NEVER_INLINE_DEBUG is a macro which expands to MOZ_NEVER_INLINE + * in debug builds, and nothing in opt builds. + */ +#if defined(DEBUG) +# define MOZ_NEVER_INLINE_DEBUG MOZ_NEVER_INLINE +#else +# define MOZ_NEVER_INLINE_DEBUG /* don't inline in opt builds */ +#endif /* * MOZ_NORETURN, specified at the start of a function declaration, indicates * that the given function does not return. (The function definition does not diff --git a/xpcom/base/Logging.h b/xpcom/base/Logging.h index a873d7153447..ed30f099b761 100644 --- a/xpcom/base/Logging.h +++ b/xpcom/base/Logging.h @@ -168,7 +168,7 @@ class LazyLogModule final { explicit constexpr LazyLogModule(const char* aLogName) : mLogName(aLogName), mLog(nullptr) {} - operator LogModule*() { + MOZ_NEVER_INLINE_DEBUG operator LogModule*() { // NB: The use of an atomic makes the reading and assignment of mLog // thread-safe. There is a small chance that mLog will be set more // than once, but that's okay as it will be set to the same LogModule