bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

Annotate style struct getters as always returning a non-null pointer

RESOLVED FIXED in Firefox 55

Status

()

Core
CSS Parsing and Computation
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: jfkthame, Assigned: jfkthame)

Tracking

unspecified
mozilla55
Points:
---

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(2 attachments)

(Assignee)

Description

a year ago
The nsStyleXXX* getters in nsStyleContext and nsIFrame will never return a null pointer (see comment at the declaration of StyleData() in nsStyleContext.h). If we annotate these methods with the returns_nonnull attribute (supported by gcc/clang), this may enable the compiler to optimize better around call sites.
(Assignee)

Comment 1

a year ago
Created attachment 8869013 [details] [diff] [review]
patch 1 - Add a MOZ_NONNULL_RETURN annotation to mfbt/Attributes.h
Attachment #8869013 - Flags: review?(nfroyd)
(Assignee)

Updated

a year ago
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
(Assignee)

Comment 2

a year ago
Created attachment 8869015 [details] [diff] [review]
patch 2 - Annotate style-struct getters with MOZ_NONNULL_RETURN for better optimization

This appears to affect code-gen in a few places in my build; I haven't analyzed them individually but presumably the optimizer knows what it's doing....
Attachment #8869015 - Flags: review?(mats)
Comment on attachment 8869013 [details] [diff] [review]
patch 1 - Add a MOZ_NONNULL_RETURN annotation to mfbt/Attributes.h

Review of attachment 8869013 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks!  What does this enable for your particular use case?  Better codegen for placement new?
Attachment #8869013 - Flags: review?(nfroyd) → review+
Attachment #8869015 - Flags: review?(mats) → review+
(Assignee)

Comment 5

a year ago
(In reply to David Baron :dbaron: ⌚️UTC-7 from comment #4)
> I think this came from bug 1365356 comment 7 and bug 1365356 comment 8.

Indeed. It looks like in some cases, it's enabling the compiler to optimize away calls to StyleDisplayWithOptionalParam(), by recognizing that the pointer being passed must be non-null and therefore the method collapses to simply returning its parameter.
(Assignee)

Comment 6

a year ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/3d3190803408c7605fbb52f8215a757fffedcad5
Bug 1365928 - patch 1 - Add a MOZ_NONNULL_RETURN annotation to mfbt/Attributes.h. r=froydnj

https://hg.mozilla.org/integration/mozilla-inbound/rev/75cd3397298ad5c0f02129a87f465059018a9f63
Bug 1365928 - patch 2 - Annotate style-struct getters with MOZ_NONNULL_RETURN for better optimization. r=mats

Comment 7

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/3d3190803408
https://hg.mozilla.org/mozilla-central/rev/75cd3397298a
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.