Chrome OS: Reduce NOTREACHED() overhead for release builds.
For Chrome OS release builds, implement a dedicated LogErrorNotReached() function to reduce
the number of function calls per NOTREACHED() call site from 5+ to 1 and drop custom messages that are appended to NOTREACHED(). (Release builds on other platforms drop NOTREACHED() altogether, so no changes there.)
This change reduces the size of my chromeos=1 executable by 1.7 MB (ca. 1%).
BUG=484283
Review URL: https://codereview.chromium.org/1124673004
Cr-Commit-Position: refs/heads/master@{#331249}
CrOS-Libchrome-Original-Commit: ff3f34ae4fefa2d0ecce5ba338b1afb9505c72d4
diff --git a/base/logging.h b/base/logging.h
index cc0a5aa..ea096d1 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -700,8 +700,12 @@
#define DCHECK_IMPLIES(val1, val2) DCHECK(!(val1) || (val2))
#if !DCHECK_IS_ON() && defined(OS_CHROMEOS)
-#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \
- __FUNCTION__ << ". "
+// Implement logging of NOTREACHED() as a dedicated function to get function
+// call overhead down to a minimum.
+void LogErrorNotReached(const char* file, int line);
+#define NOTREACHED() \
+ true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \
+ : EAT_STREAM_PARAMETERS
#else
#define NOTREACHED() DCHECK(false)
#endif