[email protected] | ddb9b33 | 2011-12-02 07:31:09 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This file is meant for analyzing the code generated by the CHECK |
| 6 | // macros in a small executable file that's easy to disassemble. |
| 7 | |
scottmg | 3c957a5 | 2016-12-10 20:57:59 | [diff] [blame^] | 8 | #include "base/compiler_specific.h" |
[email protected] | ddb9b33 | 2011-12-02 07:31:09 | [diff] [blame] | 9 | #include "base/logging.h" |
| 10 | |
| 11 | // An official build shouldn't generate code to print out messages for |
| 12 | // the CHECK* macros, nor should it have the strings in the |
scottmg | 3c957a5 | 2016-12-10 20:57:59 | [diff] [blame^] | 13 | // executable. It is also important that the CHECK() function collapse to the |
| 14 | // same implementation as RELEASE_ASSERT(), in particular on Windows x86. |
| 15 | // Historically, the stream eating caused additional unnecessary instructions. |
| 16 | // See https://crbug.com/672699. |
| 17 | |
| 18 | #define BLINK_RELEASE_ASSERT_EQUIVALENT(assertion) \ |
| 19 | (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH()) : (void)0) |
[email protected] | ddb9b33 | 2011-12-02 07:31:09 | [diff] [blame] | 20 | |
| 21 | void DoCheck(bool b) { |
| 22 | CHECK(b) << "DoCheck " << b; |
| 23 | } |
| 24 | |
scottmg | 3c957a5 | 2016-12-10 20:57:59 | [diff] [blame^] | 25 | void DoBlinkReleaseAssert(bool b) { |
| 26 | BLINK_RELEASE_ASSERT_EQUIVALENT(b); |
| 27 | } |
| 28 | |
[email protected] | ddb9b33 | 2011-12-02 07:31:09 | [diff] [blame] | 29 | void DoCheckEq(int x, int y) { |
| 30 | CHECK_EQ(x, y); |
| 31 | } |
| 32 | |
| 33 | int main(int argc, const char* argv[]) { |
| 34 | DoCheck(argc > 1); |
| 35 | DoCheckEq(argc, 1); |
scottmg | 3c957a5 | 2016-12-10 20:57:59 | [diff] [blame^] | 36 | DoBlinkReleaseAssert(argc > 1); |
[email protected] | ddb9b33 | 2011-12-02 07:31:09 | [diff] [blame] | 37 | } |