Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(608)

Side by Side Diff: base/logging.h

Issue 2710703003: Shorten IMMEDIATE_CRASH() code size on win clang (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LOGGING_H_ 5 #ifndef BASE_LOGGING_H_
6 #define BASE_LOGGING_H_ 6 #define BASE_LOGGING_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cassert> 10 #include <cassert>
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 TRAP_SEQUENCE(); \ 549 TRAP_SEQUENCE(); \
550 __builtin_unreachable(); \ 550 __builtin_unreachable(); \
551 }) 551 })
552 552
553 #elif defined(COMPILER_MSVC) 553 #elif defined(COMPILER_MSVC)
554 554
555 // Clang is cleverer about coalescing int3s, so we need to add a unique-ish 555 // Clang is cleverer about coalescing int3s, so we need to add a unique-ish
556 // instruction following the __debugbreak() to have it emit distinct locations 556 // instruction following the __debugbreak() to have it emit distinct locations
557 // for CHECKs rather than collapsing them all together. It would be nice to use 557 // for CHECKs rather than collapsing them all together. It would be nice to use
558 // a short intrinsic to do this (and perhaps have only one implementation for 558 // a short intrinsic to do this (and perhaps have only one implementation for
559 // both clang and MSVC), however clang-cl currently does not support intrinsics 559 // both clang and MSVC), however clang-cl currently does not support intrinsics.
560 // here. Adding the nullptr store to the MSVC path adds unnecessary bloat. 560 // On the flip side, MSVC x64 doesn't support inline asm. So, we have to have
561 // two implementations. Normally clang-cl's version will be 5 bytes (1 for
562 // `int3`, 2 for `ud2`, 2 for `push byte imm`, however, TODO(scottmg):
563 // https://crbug.com/694670 clang-cl doesn't currently support %'ing
564 // __COUNTER__, so eventually it will emit the dword form of push.
561 // TODO(scottmg): Reinvestigate a short sequence that will work on both 565 // TODO(scottmg): Reinvestigate a short sequence that will work on both
562 // compilers once clang supports more intrinsics. See https://crbug.com/693713. 566 // compilers once clang supports more intrinsics. See https://crbug.com/693713.
563 #if defined(__clang__) 567 #if defined(__clang__)
564 #define IMMEDIATE_CRASH() \ 568 #define IMMEDIATE_CRASH() ({__asm int 3 __asm ud2 __asm push __COUNTER__})
565 (__debugbreak(), (void)(*reinterpret_cast<volatile unsigned char*>(0) = \
566 static_cast<unsigned char>(__COUNTER__)))
567 #else 569 #else
568 #define IMMEDIATE_CRASH() __debugbreak() 570 #define IMMEDIATE_CRASH() __debugbreak()
569 #endif // __clang__ 571 #endif // __clang__
570 572
571 #else 573 #else
572 #error Port 574 #error Port
573 #endif 575 #endif
574 576
575 // CHECK dies with a fatal error if condition is not true. It is *not* 577 // CHECK dies with a fatal error if condition is not true. It is *not*
576 // controlled by NDEBUG, so the check will be executed regardless of 578 // controlled by NDEBUG, so the check will be executed regardless of
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 #elif NOTIMPLEMENTED_POLICY == 5 1126 #elif NOTIMPLEMENTED_POLICY == 5
1125 #define NOTIMPLEMENTED() do {\ 1127 #define NOTIMPLEMENTED() do {\
1126 static bool logged_once = false;\ 1128 static bool logged_once = false;\
1127 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1129 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1128 logged_once = true;\ 1130 logged_once = true;\
1129 } while(0);\ 1131 } while(0);\
1130 EAT_STREAM_PARAMETERS 1132 EAT_STREAM_PARAMETERS
1131 #endif 1133 #endif
1132 1134
1133 #endif // BASE_LOGGING_H_ 1135 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698