Bug 1563046: Move operator LogModule* out of line in debug builds. r=froydnj
authorKyle Huey <khuey@kylehuey.com>
Tue, 02 Jul 2019 23:58:18 +0000
changeset 540757 9fd54a07823002bc12c3fe361dc87041c39ed828
parent 540756 52ae606e4cfa4334c1ea549298f37efe10bdb414
child 540758 d9c61c4e5b1dde53a85002aa0ca74afebf608c80
push id11529
push userarchaeopteryx@coole-files.de
push dateThu, 04 Jul 2019 15:22:33 +0000
treeherdermozilla-beta@ebb510a784b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1563046
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1563046: Move operator LogModule* out of line in debug builds. r=froydnj Differential Revision: https://phabricator.services.mozilla.com/D36675
mfbt/Attributes.h
xpcom/base/Logging.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -88,16 +88,25 @@
  */
 #if defined(MOZ_HAVE_NEVER_INLINE)
 #  define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE
 #else
 #  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
  * need to be annotated.)
  *
  *   MOZ_NORETURN void abort(const char* msg);
  *
  * This modifier permits the compiler to optimize code assuming a call to such a
  * function will never return.  It also enables the compiler to avoid spurious
--- a/xpcom/base/Logging.h
+++ b/xpcom/base/Logging.h
@@ -163,17 +163,17 @@ class LogModule {
  *     MOZ_LOG(sLayoutLog, LogLevel::Verbose, ("Entering foo"));
  *   }
  */
 class LazyLogModule final {
  public:
   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
     //     instance each time. Also note LogModule::Get is thread-safe.
     LogModule* tmp = mLog;
     if (MOZ_UNLIKELY(!tmp)) {
       tmp = LogModule::Get(mLogName);
       mLog = tmp;