Closed
Bug 1265892
Opened 8 years ago
Closed 8 years ago
Change Vector to use Impl::new_ consistently.
Categories
(Core :: MFBT, enhancement)
Core
MFBT
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: sunfish, Assigned: sunfish)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
VectorImpl::new_ is an abstraction that allows Vector to avoid the C++ placement new nullptr check when constructing POD types. Currently it's used for Vector's append member function; this patch enables it emplaceBack and infallibleEmplaceBack as well, making them slightly faster under applicable conditions. While here, it also updates Vector::new_ to use variadic templates to eliminate extra new_ overloads, and adds MOZ_NONNULL to help compilers that recognize that.
Attachment #8743008 -
Flags: review?(jwalden+bmo)
Comment 1•8 years ago
|
||
Hmm. Rather than double down on having these arguments as pointers, requiring compiler support to recognize the opportunity to eliminate the dereference, let's make them references. And, why do we even have duplicates of some of these methods? Some of them are 100% identical, so let's put them in a base class. And others are identical once you recognize what POD implies. This is a bigger patch, but it's also 61 insertions(+), 118 deletions(-), which seems even better.
Attachment #8743664 -
Flags: review?(sunfish)
Updated•8 years ago
|
Attachment #8743008 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 2•8 years ago
|
||
Comment on attachment 8743664 [details] [diff] [review] Change Vector to use Impl::new_ consistently, and extract a few VectorImpl methods into a base class shared between the POD/non-POD VectorImpls Review of attachment 8743664 [details] [diff] [review]: ----------------------------------------------------------------- ::: mfbt/Vector.h @@ +57,5 @@ > + */ > + template<typename... Args> > + static inline void new_(T& aDst, Args&&... aArgs) > + { > + // |aDst| is a reference so the compiler can eliminate a null-check. Unfortunately, at least GCC 5.3.1 does not eliminate the null check in code written this way. As a practical matter, I'd prefer the original patch here.
Assignee | ||
Updated•8 years ago
|
Attachment #8743008 -
Flags: review?(jwalden+bmo)
Comment 3•8 years ago
|
||
Comment on attachment 8743008 [details] [diff] [review] vector-new.patch Review of attachment 8743008 [details] [diff] [review]: ----------------------------------------------------------------- That's pretty egregious that gcc doesn't tag pointer values derived from the address of a reference as non-null. :-(
Attachment #8743008 -
Flags: review?(jwalden+bmo) → review+
Comment 5•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8926ca859714
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Updated•8 years ago
|
Target Milestone: mozilla48 → mozilla49
Assignee | ||
Updated•8 years ago
|
Attachment #8743664 -
Flags: review?(sunfish)
You need to log in
before you can comment on or make changes to this bug.
Description
•