Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGenerate some PropertyDeclaration methods by hand 🐉🐲 #19956
Conversation
highfive
commented
Feb 5, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Feb 5, 2018
| /// Servo's representation for a property declaration. | ||
| #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] | ||
| #[derive(Clone, PartialEq)] | ||
| #[derive(PartialEq)] | ||
| #[repr(u8)] |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
I made the enum be https://treeherder.mozilla.org/#/jobs?repo=try&revision=680ae344ebda08a71b94be64049039d2328abd33 |
516acf6
to
eec63ec
It looks good but I'm not sure I should trust those results. Also, I've yet to make a geckotry with the latest commits I added. https://treeherder.mozilla.org/#/jobs?repo=try&revision=d0b009ecd44b0a7327c507b37a9b188e2a5b7e7b |
|
Silly me had not put
|
|
Everything is orange. Will investigate tomorrow. Probably some dumb error somewhere. |
d4f22cb
to
27fa1a7
|
Latest results with bloaty, and the missing
Geckotry seems green: https://treeherder.mozilla.org/#/jobs?repo=try&revision=2cb22ae5e6be97fcc968dc965827234d54f26b47&selectedJob=160528329 |
|
r=me, with the comments and a different name for |
| @@ -903,6 +903,7 @@ | |||
| <%call expr="longhand(name, | |||
| predefined_type=length_type, | |||
| logical=logical, | |||
| is_size_type=True, | |||
This comment has been minimized.
This comment has been minimized.
emilio
Feb 6, 2018
Member
Let's rename this to something that screams out more, like is_gecko_size_type_hack or something.
| %> | ||
| /// ${property.name} | ||
| ${property.camel_case}(${ty}), | ||
| variants.append({ |
This comment has been minimized.
This comment has been minimized.
| }; | ||
| PropertyDeclarationId::Longhand(longhand_id) | ||
| PropertyDeclarationId::Longhand( | ||
| unsafe { *(self as *const _ as *const LonghandId) }, |
This comment has been minimized.
This comment has been minimized.
emilio
Feb 6, 2018
Member
Can we debug-assert this somehow at least, to ensure nobody messes up? I guess if they mess up it'd be completely orange but...
Also, please add a comment about why this is ok here so people don't scream :).
| match self.value.from_shorthand { | ||
| // Normally, we shouldn't be printing variables here if they came from | ||
| // shorthands. But we should allow properties that came from shorthand | ||
| // aliases. That also matches with the Gecko behavior. |
This comment has been minimized.
This comment has been minimized.
emilio
Feb 6, 2018
Member
Can you mention here that this is just a hack for -moz-transform, which is really a shorthand for who knows what reason?
Also we should try to unship that, so feel free to also add a FIXME(emilio) over there so I eventually do it.
| ${" | ".join("{}(ref this)".format(v) for v in variants)} => { | ||
| let other_repr = | ||
| &*(other as *const _ as *const PropertyDeclarationVariantRepr<${ty}>); | ||
| *this == other_repr.value |
This comment has been minimized.
This comment has been minimized.
| @@ -267,7 +268,6 @@ pub mod animated_properties { | |||
| %> | |||
|
|
|||
| /// Servo's representation for a property declaration. | |||
| #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] | |||
| #[repr(u16)] | |||
| pub enum PropertyDeclaration { | |||
This comment has been minimized.
This comment has been minimized.
emilio
Feb 6, 2018
Member
Can you add a general overview of why don't we derive stuff here and similar?
|
If @SimonSapin sanity-checked this too it'd be nice, since he had concerns about doing the same kind of optimization in https://bugzilla.mozilla.org/show_bug.cgi?id=1428285#c2, it seems. |
|
I added a comment in the commit message. @bors-servo r=emilio,SimonSapin |
|
|
Generate some PropertyDeclaration methods by hand🐉 🐲 <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19956) <!-- Reviewable:end -->
|
|
This relies on the fact that `#[repr(u16)]` on enums ensure the discriminant will be the very first field of the enum value. This has always been the case, but it has been formally defined only since rust-lang/rfcs#2195. https://bugzilla.mozilla.org/show_bug.cgi?id=1428285
We first check that the discriminants are equal, then we pattern match only on `*self` and use `PropertyDeclarationVariantRepr` to look into `other` directly.
We merge arms with identical field types.
|
@bors-servo r=emilio |
|
|
Generate some PropertyDeclaration methods by hand🐉 🐲 We rely on rust-lang/rfcs#2195 to make some enums share the same discriminants by definition. This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1428285. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19956) <!-- Reviewable:end -->
|
|
ionutgoldan
commented
Feb 13, 2018
|
These changes landed some fine performance improvements! Thank you! == Change summary for alert #11504 (as of Tue, 06 Feb 2018 12:06:36 GMT) == Improvements: 5% Stylo Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench osx-10-10 opt 549,031.92 -> 519,840.33 For up to date results, see: https://treeherder.mozilla.org/perf.html#/alerts?id=11504 |
nox commentedFeb 5, 2018
•
edited
We rely on rust-lang/rfcs#2195 to make some enums share the same discriminants by definition.
This fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1428285.
This change is