Closed Bug 1370711 Opened 8 years ago Closed 8 years ago

stylo: Force the NonZero optimization for servo_arc and StrongRuleNode

Categories

(Core :: CSS Parsing and Computation, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: bholley, Assigned: bholley)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

Fixing this brings the size of ElementData from 88 bytes to 56 bytes. Credit to nox for prodding me to do this.
MozReview-Commit-ID: Aj0rryEnJpl
Attachment #8875044 - Flags: review?(manishearth)
The reasoning for this is explained in a comment in the next patch. MozReview-Commit-ID: FQgDY77mg3B
Attachment #8875045 - Flags: review?(manishearth)
MozReview-Commit-ID: AAmeyjfyXeU
Attachment #8875046 - Flags: review?(manishearth)
MozReview-Commit-ID: Da4Ds7SIcCD
Attachment #8875047 - Flags: review?(manishearth)
Blocks: 1370719
Attachment #8875045 - Flags: review?(manishearth) → review+
Attachment #8875047 - Flags: review?(manishearth) → review+
Attachment #8875044 - Flags: review?(manishearth) → review+
Comment on attachment 8875046 [details] [diff] [review] Part 3 - Introduce NonZeroPtrMut and use it in servo_arc. v1 Review of attachment 8875046 [details] [diff] [review]: ----------------------------------------------------------------- ::: servo/components/servo_arc/lib.rs @@ +79,5 @@ > +/// be thin or fat (which depends on whether or not T is sized). Given > +/// that this is all a temporary hack, this restriction is fine for now. > +/// > +/// [1] https://github.com/rust-lang/rust/issues/27730 > +pub struct NonZeroPtrMut<T: ?Sized + 'static>(&'static mut T); The `mut` shouldn't be necessary. If this is an Arc it can't be mutated anyway, except for the internal atomic, which rust's aliasing analysis understands as always-mutable. @@ +97,5 @@ > + NonZeroPtrMut::new(self.ptr()) > + } > +} > + > +impl<T: ?Sized + 'static> ::std::fmt::Debug for NonZeroPtrMut<T> { This should be an impl of http://doc.servo.org/core/fmt/trait.Pointer.html (`{:p}`), and the Debug impl should pass-through or something. Probably.
Attachment #8875046 - Flags: review?(manishearth) → review+
(In reply to Manish Goregaokar [:manishearth] from comment #5) > Comment on attachment 8875046 [details] [diff] [review] > Part 3 - Introduce NonZeroPtrMut and use it in servo_arc. v1 > > Review of attachment 8875046 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: servo/components/servo_arc/lib.rs > @@ +79,5 @@ > > +/// be thin or fat (which depends on whether or not T is sized). Given > > +/// that this is all a temporary hack, this restriction is fine for now. > > +/// > > +/// [1] https://github.com/rust-lang/rust/issues/27730 > > +pub struct NonZeroPtrMut<T: ?Sized + 'static>(&'static mut T); > > The `mut` shouldn't be necessary. If this is an Arc it can't be mutated > anyway, except for the internal atomic Well, modulo make_mut, and types with internal mutability like AtomicRefCell. >, which rust's aliasing analysis > understands as always-mutable. Yeah, but the pointers were *mut before. I'd rather just match the old code as closely as possible, since I don't think it hurts anything. > > @@ +97,5 @@ > > + NonZeroPtrMut::new(self.ptr()) > > + } > > +} > > + > > +impl<T: ?Sized + 'static> ::std::fmt::Debug for NonZeroPtrMut<T> { > > This should be an impl of http://doc.servo.org/core/fmt/trait.Pointer.html > (`{:p}`), and the Debug impl should pass-through or something. Probably. Ok.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: