summaryrefslogtreecommitdiffstats
path: root/base/logging.h
diff options
context:
space:
mode:
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 01:43:27 +0000
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-05 01:43:27 +0000
commit3ee50d193a9d6e80e7d39f260f9e3c12641c95a9 (patch)
tree7b47c4a921890f5a634974c572b06bb84785b935 /base/logging.h
parent880331f97dcc3f3ade1f0d05c2c95519e0566c05 (diff)
downloadchromium_src-3ee50d193a9d6e80e7d39f260f9e3c12641c95a9.zip
chromium_src-3ee50d193a9d6e80e7d39f260f9e3c12641c95a9.tar.gz
chromium_src-3ee50d193a9d6e80e7d39f260f9e3c12641c95a9.tar.bz2
Avoid function call for disabled DCHECK in non-official release build
Previously each disabled DCHECK in non-official release build needs to call a function. This change avoids the cost of the function call. Now on x86, assembly code of a DCHECK is like the following: mov g_dcheck_state,%rax cmpl $0x1,(%rax) je dcheck_enabled # normal code ... dcheck_enabled: ... BUG=none Review URL: https://codereview.chromium.org/186963004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r--base/logging.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/base/logging.h b/base/logging.h
index 0140780..2c538d2 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -171,7 +171,7 @@ enum LoggingDestination {
// Indicates that the log file should be locked when being written to.
// Unless there is only one single-threaded process that is logging to
// the log file, the file should be locked during writes to make each
-// log outut atomic. Other writers will block.
+// log output atomic. Other writers will block.
//
// All processes writing to the log file must have their locking set for it to
// work properly. Defaults to LOCK_LOG_FILE.
@@ -674,7 +674,7 @@ enum { DEBUG_MODE = ENABLE_DLOG };
#if defined(NDEBUG)
-BASE_EXPORT DcheckState get_dcheck_state();
+BASE_EXPORT extern DcheckState g_dcheck_state;
BASE_EXPORT void set_dcheck_state(DcheckState state);
#if defined(DCHECK_ALWAYS_ON)
@@ -691,10 +691,11 @@ const LogSeverity LOG_DCHECK = LOG_FATAL;
COMPACT_GOOGLE_LOG_EX_ERROR_REPORT(ClassName , ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_ERROR_REPORT
const LogSeverity LOG_DCHECK = LOG_ERROR_REPORT;
-#define DCHECK_IS_ON() \
- ((::logging::get_dcheck_state() == \
- ::logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) && \
- LOG_IS_ON(DCHECK))
+
+#define DCHECK_IS_ON() \
+ UNLIKELY(::logging::g_dcheck_state == \
+ ::logging::ENABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS) && \
+ LOG_IS_ON(DCHECK)
#endif // defined(DCHECK_ALWAYS_ON)