Please replace the following macros in your code, except wtf/Vector.h and wtf/HashTable.h.ASSERT -> DCHECK or DCHECK_EQ/NE/LE/LT/GE/GTRELEASE_ASSERT -> CHECK or CHECK_EQ/NE/LE/LT/GE/GTENABLE(ASSERT) -> DCHECK_IS_ON()ASSERT_NO_REACHED() -> NOTREACHED()ASSERT_UNUSED -> DCHECK* and ALLOW_UNUSED_LOCAL() if necessary.ASSERT_WITH_SECURITY_IMPLICATION -> SECURITY_DCHECKAlso, please remove WTF_LOG usage, use VLOG() or DVLOG instead.You can associate cleanup CLs for them to crbug.com/596760.----------------------------------------------------------------------------------------Changes we already finished:
- RELEASE_ASSERT_WITH_SECURITY_IMPLICATION was already replaced with SECURITY_CHECK.
- RELEASE_ASSERT_NOT_REACHED was renamed to RELEASE_NOTREACHED.
- ASSERT_ARG was removed. Please use DCHECK.
- BACKTRACE() was removed. Please use WTFReportBacktrace() or base::debug::StackTrace.
StackTrace has a downside; crbug.com/598886- FATAL() was removed. Please use DLOG(FATAL).
- WTF_LOG_ERROR() was removed. Please use DLOG(ERROR).
- ASSERT_WITH_MESSAGE and RELEASE_ASSERT_WITH_MESSAGE were removed. We can specify messages to DCHECK() and CHECK().
- platform/NotImplemented.* were removed in order to remove WTFLogVerbose() defined in Assertions.h. Please use NOTIMPLEMENTED().
FAQ:* Why don't we update wtf/Vector.h and wtf/HashTable.h?Chromecast team uses Release + DCHECK_ALWAYS_ON + ENABLE_ASSERT=0 configuration daily because of device memory restriction. Enabling ASSERTs in Blink increases the binary size significantly, and the major part of the increase comes from wtf/Vector.h and wtf/HashTable.h. So we'd like to keep a way to disable assertions in these files.
Thank you for helping the replacement task.The number of instances as of March 31 -> November 21:ASSERT() : 2,191 -> 1,195RELEASE_ASSERT() : 122 -> 88ENABLE(ASSERT) : 301 -> 185ASSERT_NOT_REACHED() : 584 -> 320ASSERT_UNUSED() : 115 -> 0ASSERT_WITH_SECURITY_IMPLICATION() : 154 -> 0As we noticed in the previous thread, RELEASE_ASSERT() -> CHECK() replacement would have performance regression on Windows. However I guess the replacement in directories except wtf/ won't have visible performance impact, and we should try the replacement.
Yeah I don't think we can say performance doesn't matter outside wtf/ for CHECK. It needs to be fast everywhere or we should consider switching back to RELEASE_ASSERT.
// DCHECK et al. make sure to reference |condition| regardless of // whether DCHECKs are enabled; this is so that we don't get unused // variable warnings if the only use of a variable is in a DCHECK. // This behavior is different from DLOG_IF et al.This ends up causing issues, because when DCHECK/ASSERT is not enabled we don't compile or link these debugging functions in, but we need them at the call site even if DCHECK is not enabled. What is the correct way to go here? Should we try to remove all debug-only code? If we want to DCHECK on debug-only code do we need to wrap it in a DCHECK_IS_ON()?Also +1 on what others have said about not moving to CHECK everywhere until it is fast.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
I'd like a little advice. There's threading code living under #if enabled(ASSERT) here. We ASSERT on these functions in various places.I've tried migrating these to use DCHECK but DCHECK has subtly different semantics than ASSERT. Namely:// DCHECK et al. make sure to reference |condition| regardless of // whether DCHECKs are enabled; this is so that we don't get unused // variable warnings if the only use of a variable is in a DCHECK. // This behavior is different from DLOG_IF et al.This ends up causing issues, because when DCHECK/ASSERT is not enabled we don't compile or link these debugging functions in, but we need them at the call site even if DCHECK is not enabled. What is the correct way to go here? Should we try to remove all debug-only code? If we want to DCHECK on debug-only code do we need to wrap it in a DCHECK_IS_ON()?
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
On Nov 21, 2016 7:56 PM, "Charles Harrison" <cshar...@chromium.org> wrote:
>
> I'd like a little advice. There's threading code living under #if enabled(ASSERT) here. We ASSERT on these functions in various places.
>
> I've tried migrating these to use DCHECK but DCHECK has subtly different semantics than ASSERT. Namely:
>
> // DCHECK et al. make sure to reference |condition| regardless of // whether DCHECKs are enabled; this is so that we don't get unused // variable warnings if the only use of a variable is in a DCHECK. // This behavior is different from DLOG_IF et al.
>
> This ends up causing issues, because when DCHECK/ASSERT is not enabled we don't compile or link these debugging functions in, but we need them at the call site even if DCHECK is not enabled. What is the correct way to go here? Should we try to remove all debug-only code? If we want to DCHECK on debug-only code do we need to wrap it in a DCHECK_IS_ON()?
You need to use the DCHECK_IS_ON() guard around it. Yeah it's ugly :/
>> To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
>
>
On Tue, Nov 22, 2016 at 12:37 PM, TAMURA, Kent <tk...@chromium.org> wrote:Thank you for helping the replacement task.The number of instances as of March 31 -> November 21:ASSERT() : 2,191 -> 1,195RELEASE_ASSERT() : 122 -> 88ENABLE(ASSERT) : 301 -> 185ASSERT_NOT_REACHED() : 584 -> 320ASSERT_UNUSED() : 115 -> 0ASSERT_WITH_SECURITY_IMPLICATION() : 154 -> 0As we noticed in the previous thread, RELEASE_ASSERT() -> CHECK() replacement would have performance regression on Windows. However I guess the replacement in directories except wtf/ won't have visible performance impact, and we should try the replacement.I'm a bit concerned about this. For example, bindings/ and platform/heap/ still have RELEASE_ASSERT()s on performance-sensitive places.Do we have any timeline for fixing the performance issue on Windows?
On Nov 23, 2016 7:12 PM, <dan...@chromium.org> wrote:
>
> FWIW I filed https://bugs.chromium.org/p/chromium/issues/detail?id=668300 in which I suggest maybe the fact that we see this huge perf difference from a no-opish change to CHECK signifies we have RELEASE_ASSERTs in very hot places and we should fix that instead. Something to look at.
Yes, we have them inside things like Vector::operator[] on purpose. CHECK just needs to be fast. If RELEASE_ASSERT is faster we should keep it.
#384213 : kotenkov@ replaces all occurrences of RELEASE_ASSERT in wtf with CHECK. (crrev.com/1840163002)
#384889 : tkent@ reverts #384213 (crrev.com/1854033002) because of android perf regresson (crbug.com/599867)
#394035 : thakis@ makes CHECK use __builtin_trap to fix the regression above (crrev.com/1982123002)
#395624 : kotenkov@ re-replaces all occurrences of RELEASE_ASSERT in wtf with CHECK. (crrev.com/1992873004)
#396441 : kotenkov@ re-reverts (crrev.com/2016223002) because of windows perf regression (crbug.com/614852)
#398084 : primiano@ reverts thakis@'s #394035 beacause of crash related reasons (crrev.com/2046593002)
#404249 : primiano@ relands thakis@'s #394035, crash stuff fixed (crrev.com/2125923002)
#437763 : scottmg@ lands a perf fix for CHECK on windows (crrev.com/2559323007)
#437764 : reverted #437763 as it broke some bots (crrev.com/2569583002) #437777 : scottmg@ re-lands the fix. It sticks (crrev.com/2559323007)
On a related note, is there something stopping us patching wtf/Assertion.h to define things in terms of base/logging.h primitives now, e.g. ASSERT->DCHECK, RELEASE_ASSERT->CHECK and so-on?Or are there specific properties of the WTF reporting functions that we need to preserve for now?
Kent, Elliott: Thanks for the updates. I'll draft a patch to start aliasing those then.Elliott: How would you feel about ASSERT temporarily being #ifdef'd between no-op and alias-to-DCHECK to achieve that result? I'd prefer not to try to draft an alternative DCHECK until we've cleaned up some of the accrued debt in base/logging.h first. :P
On Wed, Jan 11, 2017 at 1:35 PM, Wez <w...@chromium.org> wrote:On a related note, is there something stopping us patching wtf/Assertion.h to define things in terms of base/logging.h primitives now, e.g. ASSERT->DCHECK, RELEASE_ASSERT->CHECK and so-on?Or are there specific properties of the WTF reporting functions that we need to preserve for now?We should try aliasing RELEASE_ASSERT and CHECK. ASSERT is actually behaviorally different, it totally omits the code in a release build. DCHECK still has the code and depends on the compiler to omit the code. I find this results in a some pretty gross stuff like:#if DCHECK_IS_ON()DCHECK(HeapObjectHeader::fromPayload(t)->checkHeader());#endifI think we should add a new DCHECK form that omits the code entirely and then we can alias for it.
On Wed, Jan 11, 2017 at 1:40 PM, Elliott Sprehn <esp...@chromium.org> wrote:On Wed, Jan 11, 2017 at 1:35 PM, Wez <w...@chromium.org> wrote:On a related note, is there something stopping us patching wtf/Assertion.h to define things in terms of base/logging.h primitives now, e.g. ASSERT->DCHECK, RELEASE_ASSERT->CHECK and so-on?Or are there specific properties of the WTF reporting functions that we need to preserve for now?We should try aliasing RELEASE_ASSERT and CHECK. ASSERT is actually behaviorally different, it totally omits the code in a release build. DCHECK still has the code and depends on the compiler to omit the code. I find this results in a some pretty gross stuff like:#if DCHECK_IS_ON()DCHECK(HeapObjectHeader::fromPayload(t)->checkHeader());#endifI think we should add a new DCHECK form that omits the code entirely and then we can alias for it.I notice this behavior was only recently addedto work around another type of annoyance when using DCHECKs (unused variable warnings when disabled).
Either way requires some ugly ifdefs in some cases.
We should just standardize on the way that generally results in the fewest ifdefs. I don't personally care which way this is.
Brett
Thank you for helping the replacement task.The number of instances as of March 31 -> November 21:
ASSERT() : 2,191 -> 1,195RELEASE_ASSERT() : 122 -> 88ENABLE(ASSERT) : 301 -> 185ASSERT_NOT_REACHED() : 584 -> 320ASSERT_UNUSED() : 115 -> 0ASSERT_WITH_SECURITY_IMPLICATION() : 154 -> 0As we noticed in the previous thread, RELEASE_ASSERT() -> CHECK() replacement would have performance regression on Windows. However I guess the replacement in directories except wtf/ won't have visible performance impact, and we should try the replacement.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAGH7WqHjFiCNvA3%3DcXn--G4R40X7yfPO1QcLzA%3DJfcuiOrKxTQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAP_mGKqa_t7VMuc0VfOhVzDMeq%2BhaRLnoJQDNYKtkdhmBnaAsw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAP_mGKqa_t7VMuc0VfOhVzDMeq%2BhaRLnoJQDNYKtkdhmBnaAsw%40mail.gmail.com.
One alternative is DLOG_IF(FATAL, ...).
On Tue, May 23, 2017 at 4:28 PM, Wez <w...@google.com> wrote:Can you clarify what it is that you're asking for, Victor? Are you talking about the fact that DCHECK references the |condition| even in Release builds?
Yes. Thank you very much for helping me clarify my question!Specifically, I have class fields that are only used in DCHECKs. To avoid wasting memory, these fields are only declared in DCHECK-enabled builds. Concretely, the declarations are guarded by #if DCHECK_IS_ON(). While I can definitely tolerate an #if guard per field to save memory, I'm a bit sad that the guards extend to every DCHECK I use.I think that the current DCHECK behavior is useful, as the macro can potentially turn the assertion into an optimizer hint. At the same time, I wish there was a more lightweight alternative to #if DCHECK_IS_ON()-guarded DCHECKs. Perhaps XDCHECK? XDVictor
(re-adding blink-dev@)Thanks for the clarification, Victor. So yes it sounds like the concern is that you are ending up with code that looks like:#if DCHECK_IS_ON();// Declare some stuff.int foo;#endif...#if DCHECK_IS_ON()DCHECK(foo);#endif
because of the fact that DCHECK() always references the |condition|, even in non-Debug builds.As Daniel already responded, I think the construct you want is DLOG_IF(FATAL, ), which is equivalent to DCHECK, but with the difference that |condition| is not referenced.On 24 May 2017 at 11:46, Victor Costan <pwn...@chromium.org> wrote:On Tue, May 23, 2017 at 4:28 PM, Wez <w...@google.com> wrote:Can you clarify what it is that you're asking for, Victor? Are you talking about the fact that DCHECK references the |condition| even in Release builds?Yes. Thank you very much for helping me clarify my question!Specifically, I have class fields that are only used in DCHECKs. To avoid wasting memory, these fields are only declared in DCHECK-enabled builds. Concretely, the declarations are guarded by #if DCHECK_IS_ON(). While I can definitely tolerate an #if guard per field to save memory, I'm a bit sad that the guards extend to every DCHECK I use.I think that the current DCHECK behavior is useful, as the macro can potentially turn the assertion into an optimizer hint. At the same time, I wish there was a more lightweight alternative to #if DCHECK_IS_ON()-guarded DCHECKs. Perhaps XDCHECK? XDVictorOn 23 May 2017 at 16:20, Victor Costan <pwn...@chromium.org> wrote:Was there any conclusion to the idea / effort of coming up with an alternative DCHECK that doesn't require #if DCHECK_IS_ON()?I've written some of those #ifdefs in IndexedDB code, and I'd be quite happy to make them go away.Thank you very much,Victor
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CALekkJeEzqkaSEB-sBqoNs1M8SLEPd5XsVsA5fKae1NO1TUBFA%40mail.gmail.com.