Closed
Bug 1253094
Opened 9 years ago
Closed 9 years ago
Make DebugOnly a MOZ_STACK_CLASS
Categories
(Core :: MFBT, defect)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | fixed |
People
(Reporter: jwatt, Assigned: jwatt)
References
Details
Attachments
(11 files)
(deleted),
text/x-review-board-request
|
baku
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
bas.schouten
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
billm
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
billm
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
MatsPalmgren_bugz
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
mayhemer
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
mak
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
bzbarsky
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
froydnj
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
n.nethercote
:
review+
|
Details |
(deleted),
text/x-review-board-request
|
Waldo
:
review+
|
Details |
As noted if bug 1248843 comment 2 there are two problems with DebugOnly:
* DebugOnly increases the size of objects even in release builds, which some
people don't realize and then (possibly unknowingly) get bitten by.
* |DebugOnly<T> = ...;| evaluates |...| in all builds, which some people don't
think through.
This bug is aimed at addressing the former issue.
Assignee | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37723/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37723/
Attachment #8725975 -
Flags: review?(amarchesini)
Assignee | ||
Comment 2•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37725/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37725/
Attachment #8725976 -
Flags: review?(bas)
Assignee | ||
Comment 3•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37727/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37727/
Attachment #8725977 -
Flags: review?(wmccloskey)
Assignee | ||
Comment 4•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37729/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37729/
Attachment #8725978 -
Flags: review?(wmccloskey)
Assignee | ||
Comment 5•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37731/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37731/
Attachment #8725979 -
Flags: review?(mats)
Assignee | ||
Comment 6•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37733/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37733/
Attachment #8725980 -
Flags: review?(honzab.moz)
Assignee | ||
Comment 7•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37735/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37735/
Attachment #8725981 -
Flags: review?(mak77)
Assignee | ||
Comment 8•9 years ago
|
||
Comment on attachment 8725975 [details]
MozReview Request: Bug 1253094, part 1 - Stop using DebugOnly for class/struct members in dom/. r=baku
Review commit: https://reviewboard.mozilla.org/r/37723/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37723/
Assignee | ||
Comment 9•9 years ago
|
||
Comment on attachment 8725976 [details]
MozReview Request: Bug 1253094, part 2 - Stop using DebugOnly for class/struct members in gfx/. r=Bas
Review commit: https://reviewboard.mozilla.org/r/37725/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37725/
Assignee | ||
Comment 10•9 years ago
|
||
Comment on attachment 8725977 [details]
MozReview Request: Bug 1253094, part 3 - Stop using DebugOnly for class/struct members in ipc/. r=billm
Review commit: https://reviewboard.mozilla.org/r/37727/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37727/
Assignee | ||
Comment 11•9 years ago
|
||
Comment on attachment 8725978 [details]
MozReview Request: Bug 1253094, part 4 - Stop using DebugOnly for class/struct members in js/. r=billm
Review commit: https://reviewboard.mozilla.org/r/37729/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37729/
Assignee | ||
Comment 12•9 years ago
|
||
Comment on attachment 8725979 [details]
MozReview Request: Bug 1253094, part 5 - Stop using DebugOnly for class/struct members in layout/. r=mats
Review commit: https://reviewboard.mozilla.org/r/37731/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37731/
Assignee | ||
Comment 13•9 years ago
|
||
Comment on attachment 8725980 [details]
MozReview Request: Bug 1253094, part 6 - Stop using DebugOnly for class/struct members in netwerk/. r=mayhemer
Review commit: https://reviewboard.mozilla.org/r/37733/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37733/
Assignee | ||
Comment 14•9 years ago
|
||
Comment on attachment 8725981 [details]
MozReview Request: Bug 1253094, part 7 - Stop using DebugOnly for class/struct members in storage/. r=mak
Review commit: https://reviewboard.mozilla.org/r/37735/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37735/
Assignee | ||
Comment 15•9 years ago
|
||
Comment on attachment 8725975 [details]
MozReview Request: Bug 1253094, part 1 - Stop using DebugOnly for class/struct members in dom/. r=baku
Review commit: https://reviewboard.mozilla.org/r/37723/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37723/
Assignee | ||
Comment 16•9 years ago
|
||
Comment on attachment 8725976 [details]
MozReview Request: Bug 1253094, part 2 - Stop using DebugOnly for class/struct members in gfx/. r=Bas
Review commit: https://reviewboard.mozilla.org/r/37725/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37725/
Assignee | ||
Comment 17•9 years ago
|
||
Comment on attachment 8725977 [details]
MozReview Request: Bug 1253094, part 3 - Stop using DebugOnly for class/struct members in ipc/. r=billm
Review commit: https://reviewboard.mozilla.org/r/37727/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37727/
Assignee | ||
Comment 18•9 years ago
|
||
Comment on attachment 8725978 [details]
MozReview Request: Bug 1253094, part 4 - Stop using DebugOnly for class/struct members in js/. r=billm
Review commit: https://reviewboard.mozilla.org/r/37729/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37729/
Assignee | ||
Comment 19•9 years ago
|
||
Comment on attachment 8725979 [details]
MozReview Request: Bug 1253094, part 5 - Stop using DebugOnly for class/struct members in layout/. r=mats
Review commit: https://reviewboard.mozilla.org/r/37731/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37731/
Assignee | ||
Comment 20•9 years ago
|
||
Comment on attachment 8725980 [details]
MozReview Request: Bug 1253094, part 6 - Stop using DebugOnly for class/struct members in netwerk/. r=mayhemer
Review commit: https://reviewboard.mozilla.org/r/37733/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37733/
Assignee | ||
Comment 21•9 years ago
|
||
Comment on attachment 8725981 [details]
MozReview Request: Bug 1253094, part 7 - Stop using DebugOnly for class/struct members in storage/. r=mak
Review commit: https://reviewboard.mozilla.org/r/37735/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37735/
Assignee | ||
Comment 22•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37737/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37737/
Attachment #8725998 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 23•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37739/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37739/
Attachment #8725999 -
Flags: review?(nfroyd)
Assignee | ||
Comment 24•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37741/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37741/
Attachment #8726000 -
Flags: review?(n.nethercote)
Assignee | ||
Comment 25•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/37743/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/37743/
Attachment #8726001 -
Flags: review?(jwalden+bmo)
Comment 26•9 years ago
|
||
Comment on attachment 8725998 [details]
MozReview Request: Bug 1253094, part 8 - Stop using DebugOnly for class/struct members in uriloader/. r=smaug
https://reviewboard.mozilla.org/r/37737/#review34279
r=me
Attachment #8725998 -
Flags: review?(bzbarsky) → review+
Updated•9 years ago
|
Attachment #8725979 -
Flags: review?(mats) → review+
Comment 27•9 years ago
|
||
Comment on attachment 8725979 [details]
MozReview Request: Bug 1253094, part 5 - Stop using DebugOnly for class/struct members in layout/. r=mats
https://reviewboard.mozilla.org/r/37731/#review34281
Comment 28•9 years ago
|
||
Comment on attachment 8725999 [details]
MozReview Request: Bug 1253094, part 9 - Stop using DebugOnly for class/struct members in xpcom/. r=froydnj
https://reviewboard.mozilla.org/r/37739/#review34289
Attachment #8725999 -
Flags: review?(nfroyd) → review+
Updated•9 years ago
|
Attachment #8726000 -
Flags: review?(n.nethercote) → review+
Comment 29•9 years ago
|
||
Comment on attachment 8726000 [details]
MozReview Request: Bug 1253094, part 10 - Stop using DebugOnly for class/struct members in memory/. r=njn
https://reviewboard.mozilla.org/r/37741/#review34331
Updated•9 years ago
|
Attachment #8725975 -
Flags: review?(amarchesini) → review+
Comment 30•9 years ago
|
||
Comment on attachment 8725975 [details]
MozReview Request: Bug 1253094, part 1 - Stop using DebugOnly for class/struct members in dom/. r=baku
https://reviewboard.mozilla.org/r/37723/#review34347
Comment 31•9 years ago
|
||
Comment on attachment 8725981 [details]
MozReview Request: Bug 1253094, part 7 - Stop using DebugOnly for class/struct members in storage/. r=mak
https://reviewboard.mozilla.org/r/37735/#review34359
I think we will actually expose this field in any build shortly, but for now it's fine to ifdef it.
Attachment #8725981 -
Flags: review?(mak77) → review+
Comment 32•9 years ago
|
||
Comment on attachment 8725980 [details]
MozReview Request: Bug 1253094, part 6 - Stop using DebugOnly for class/struct members in netwerk/. r=mayhemer
https://reviewboard.mozilla.org/r/37733/#review34403
Attachment #8725980 -
Flags: review?(honzab.moz) → review+
Comment on attachment 8725978 [details]
MozReview Request: Bug 1253094, part 4 - Stop using DebugOnly for class/struct members in js/. r=billm
https://reviewboard.mozilla.org/r/37729/#review34519
Attachment #8725978 -
Flags: review?(wmccloskey) → review+
Attachment #8725977 -
Flags: review?(wmccloskey) → review+
Comment on attachment 8725977 [details]
MozReview Request: Bug 1253094, part 3 - Stop using DebugOnly for class/struct members in ipc/. r=billm
https://reviewboard.mozilla.org/r/37727/#review34521
Updated•9 years ago
|
Attachment #8726001 -
Flags: review?(jwalden+bmo) → review+
Comment 35•9 years ago
|
||
Comment on attachment 8726001 [details]
MozReview Request: Bug 1253094, part 11 - Make DebugOnly a MOZ_STACK_ONLY class. r=Waldo
https://reviewboard.mozilla.org/r/37743/#review34573
Comment 36•9 years ago
|
||
I'd like to understand this better...
(In reply to Jonathan Watt [:jwatt] from comment #0)
> As noted if bug 1248843 comment 2 there are two problems with DebugOnly:
>
> * DebugOnly increases the size of objects even in release builds, which some
> people don't realize and then (possibly unknowingly) get bitten by.
Why? And if this is true, can't we just fix it?
> * |DebugOnly<T> = ...;| evaluates |...| in all builds, which some people
> don't
> think through.
This is exactly why I like it... for checking results of functions that need to be executed in release builds but only checked in debug.
Maybe this was discussed in some thread already, just curious.
Updated•9 years ago
|
Flags: needinfo?(jwatt)
Comment 37•9 years ago
|
||
(In reply to Bas Schouten (:bas.schouten) from comment #36)
> I'd like to understand this better...
Given it was my comment originally, maybe I should take this. :-)
> > * DebugOnly increases the size of objects even in release builds, which some
> > people don't realize and then (possibly unknowingly) get bitten by.
>
> Why? And if this is true, can't we just fix it?
The size of any class/struct must be at least 1 to ensure that the addresses of distinct objects of the same type are never the same. (C++ has special verbiage going out of the way to [attempt to] compress an empty class into zero space when it's a base class.) This generally requires that DebugOnly occupy a byte in opt builds. Standard ABIs *could* do special work to compress (some) empty class members into nothingness, but they do not.
There are compiler-specific, ABI-altering ways to maybe evade this, like __attribute__((packed)). But they're specified on the *enclosing* class, not on DebugOnly. To the best of my knowledge, there's no attribute we could place on DebugOnly itself to permit optimizing it away entirely, that wouldn't require the user do something special. (And then why not just #ifdef DEBUG for absolute clarity?)
> > * |DebugOnly<T> = ...;| evaluates |...| in all builds, which some people
> > don't think through.
>
> This is exactly why I like it... for checking results of functions that need
> to be executed in release builds but only checked in debug.
Sure, if you think it through that way. The problem is there are people who don't think through that these
DebugOnly<T> t1 = ...;
t2 = ...;
will *always* evaluate the ... when |t1| and |t2| are DebugOnly. They see that they're assigning to a DebugOnly, and they incorrectly jump to thinking that means the right-hand-side isn't evaluated in opt builds. That's nonsense: DebugOnly doesn't affect normal C++ evaluation semantics. But if you're thinking sloppily, it's not a surprising leap to make.
In contrast, it seems much more likely developers understand the preprocessing concept enough to realize that
#ifdef DEBUG
T t1 = ...;
t2 = ...;
t3 =
#endif
...;
*only* evaluates the first two ... in debug builds and *always* evaluates the third ... regardless of debug/non-debug status.
Flags: needinfo?(jwatt)
Assignee | ||
Comment 38•9 years ago
|
||
(In reply to Jeff Walden [:Waldo] (remove +bmo to email) from comment #37)
> > > * |DebugOnly<T> = ...;| evaluates |...| in all builds, which some people
> > > don't think through.
> >
> > This is exactly why I like it... for checking results of functions that need
> > to be executed in release builds but only checked in debug.
>
> Sure, if you think it through that way. The problem is there are people who
> don't think through that these
Anyway, for the purposes of the review here please don't get distracted by that point. :) This bug only takes action against the former (size) issue.
I'd also personally still lean in favor of keeping DebugOnly for use on the stack, which is one reason this bug only focuses on the heap allocated cases. I just mentioned it for completeness. Anyway, let's lobby for that in any bug filed to kill off DebugOnly...if someone actually wants to spend time writing those patches.
Updated•9 years ago
|
Attachment #8725976 -
Flags: review?(bas) → review+
Comment 39•9 years ago
|
||
Comment on attachment 8725976 [details]
MozReview Request: Bug 1253094, part 2 - Stop using DebugOnly for class/struct members in gfx/. r=Bas
https://reviewboard.mozilla.org/r/37725/#review34993
Comment 40•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/5dcd795e8823
https://hg.mozilla.org/integration/mozilla-inbound/rev/1bfaa66eb327
https://hg.mozilla.org/integration/mozilla-inbound/rev/6d0c889a1c0e
https://hg.mozilla.org/integration/mozilla-inbound/rev/cde0572b59f2
https://hg.mozilla.org/integration/mozilla-inbound/rev/4d29ea20c231
https://hg.mozilla.org/integration/mozilla-inbound/rev/3365467dab5b
https://hg.mozilla.org/integration/mozilla-inbound/rev/216e73b3ea18
https://hg.mozilla.org/integration/mozilla-inbound/rev/b1ff360d4abf
https://hg.mozilla.org/integration/mozilla-inbound/rev/3dd442fbf419
https://hg.mozilla.org/integration/mozilla-inbound/rev/2e601ce0f78e
Comment 41•9 years ago
|
||
Comment 42•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/5dcd795e8823
https://hg.mozilla.org/mozilla-central/rev/1bfaa66eb327
https://hg.mozilla.org/mozilla-central/rev/6d0c889a1c0e
https://hg.mozilla.org/mozilla-central/rev/cde0572b59f2
https://hg.mozilla.org/mozilla-central/rev/4d29ea20c231
https://hg.mozilla.org/mozilla-central/rev/3365467dab5b
https://hg.mozilla.org/mozilla-central/rev/216e73b3ea18
https://hg.mozilla.org/mozilla-central/rev/b1ff360d4abf
https://hg.mozilla.org/mozilla-central/rev/3dd442fbf419
https://hg.mozilla.org/mozilla-central/rev/2e601ce0f78e
https://hg.mozilla.org/mozilla-central/rev/58475d84315a
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
You need to log in
before you can comment on or make changes to this bug.
Description
•