Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the cascade #9929

Merged
merged 3 commits into from Mar 19, 2016
Merged

Refactor the cascade #9929

merged 3 commits into from Mar 19, 2016

Conversation

@SimonSapin
Copy link
Member

SimonSapin commented Mar 8, 2016

Converting the specified value of some properties into a computed value depends on the value of other properties. For example, the em unit of any length depends on the font-size property.

Previously, we would do a first pass over applicable declarations to build up a values::computed::Context struct with a number of fields for each such piece of data from other properties.

This simplies the struct by instead having it contain the set of computed values (for a given element) that is being populated and classify properties into "early" and "other", such that the only dependencies can be from "other" to "early". We iterate applicable_declarations twice, first cascading "early" properties then "other". Unfortunately, it’s not easy to check that this classification is correct.

Review on Reviewable

@highfive
Copy link

highfive commented Mar 8, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/values.rs, components/style/properties.mako.rs, components/style/viewport.rs
@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 8, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Mar 8, 2016

Trying commit 75382bb with merge 586f463...

bors-servo added a commit that referenced this pull request Mar 8, 2016
Try

I’ll edit this PR with more stuff later, but for now I want some try results.
@SimonSapin SimonSapin assigned SimonSapin and unassigned jdm Mar 8, 2016
@bors-servo
Copy link
Contributor

bors-servo commented Mar 8, 2016

💔 Test failed - linux-rel

@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 8, 2016

@bholley Alright, the last commit has the refactoring discussed today or IRC, but I’m really not confident that it’s correct or that our current test suite covers edge cases where is might not be correct.

Still, let’s see what happens with:

@bors-servo try

@bors-servo
Copy link
Contributor

bors-servo commented Mar 8, 2016

Trying commit f23ed92 with merge 24115a9...

bors-servo added a commit that referenced this pull request Mar 8, 2016
Try

I’ll edit this PR with more stuff later, but for now I want some try results.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9929)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 9, 2016

💔 Test failed - mac-rel-wpt

@SimonSapin SimonSapin changed the title Try Refactor the cascade Mar 10, 2016
// Like calling to_computed_value, which wouldn't type check.
if style.border.border_${side}_style.none_or_hidden() &&
style.border.border_${side}_width != Au(0) {
Arc::make_mut(&mut style.border).border_${side}_width = Au(0);

This comment has been minimized.

Copy link
@pcwalton

pcwalton Mar 10, 2016

Contributor

Pushing the Arc::make_mut() into the if condition like you did here may improve cascading performance significantly, FWIW. Thanks!

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Mar 10, 2016

Author Member

Yes, that was the idea.

@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 10, 2016

r? @pcwalton

There’s at least one bug causing these two failures, but I don’t understand why these tests produce the results they do with this PR :(

  ▶ FAIL [expected PASS] /_mozilla/css/inline_absolute_hypothetical_clip_a.html
  ▶ FAIL [expected PASS] /_mozilla/css/inline_hypothetical_box_a.html
@highfive highfive assigned pcwalton and unassigned SimonSapin Mar 10, 2016
@pcwalton
Copy link
Contributor

pcwalton commented Mar 11, 2016

@bors-servo: r+

Nice idea and any simplification here is helpful, since this is performance-critical code and the i-cache burden is significant.

@bors-servo
Copy link
Contributor

bors-servo commented Mar 11, 2016

📌 Commit f1c46c2 has been approved by pcwalton

@pcwalton
Copy link
Contributor

pcwalton commented Mar 11, 2016

@bors-servo: r-

Tests are failing. But r=me when they're fixed.

SimonSapin added 2 commits Mar 8, 2016
(I think it’s never worked in over a year since it was implemented…)
@bors-servo
Copy link
Contributor

bors-servo commented Mar 18, 2016

@jdm
Copy link
Member

jdm commented Mar 18, 2016

@SimonSapin: #9012 - nothing new about it.

@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 18, 2016

Ok, I’ll remember to try more variations of github search.

@pcwalton try passed, please r? the bug fixes, I’m not super confident in them.

@pcwalton
Copy link
Contributor

pcwalton commented Mar 18, 2016

Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions.


components/style/properties.mako.rs, line 6681 [r5] (raw file):
Does it make sense to only call Arc::make_mut() if we're actually going to make a change? Arc::make_mut() is always high in the profile.


Comments from the review on Reviewable.io

@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 18, 2016

Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions.


components/style/properties.mako.rs, line 6681 [r5] (raw file):
Yes, we only go inside if let Some(… if we’re going to make a change. The match above is None for no change.


Comments from the review on Reviewable.io

@pcwalton
Copy link
Contributor

pcwalton commented Mar 18, 2016

Looks good, r=me.

@SimonSapin
Copy link
Member Author

SimonSapin commented Mar 18, 2016

@bors-servo r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Mar 18, 2016

📌 Commit 529164e has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Mar 18, 2016

Testing commit 529164e with merge 1ade640...

bors-servo added a commit that referenced this pull request Mar 18, 2016
Refactor the cascade

Converting the specified value of some properties into a computed value depends on the value of other properties. For example, the `em` unit of any length depends on the `font-size` property.

Previously, we would do a first pass over applicable declarations to build up a `values::computed::Context` struct with a number of fields for each such piece of data from other properties.

This simplies the struct by instead having it contain the set of computed values (for a given element) that is being populated and classify properties into "early" and "other", such that the only dependencies can be from "other" to "early". We iterate applicable_declarations twice, first cascading "early" properties then "other". Unfortunately, it’s not easy to check that this classification is correct.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9929)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 18, 2016

💔 Test failed - linux-rel

@bholley
Copy link
Contributor

bholley commented Mar 18, 2016

@bors-servo retry

@mbrubeck
Copy link
Contributor

mbrubeck commented Mar 19, 2016

The failed test was #9724.

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

Previous build results for android, gonk, linux-dev, mac-dev-unit, mac-rel-css, mac-rel-wpt, status-appveyor are reusable. Rebuilding only linux-rel...

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

💔 Test failed - linux-rel

@KiChjang
Copy link
Member

KiChjang commented Mar 19, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

Testing commit 529164e with merge 2d6283c...

bors-servo added a commit that referenced this pull request Mar 19, 2016
Refactor the cascade

Converting the specified value of some properties into a computed value depends on the value of other properties. For example, the `em` unit of any length depends on the `font-size` property.

Previously, we would do a first pass over applicable declarations to build up a `values::computed::Context` struct with a number of fields for each such piece of data from other properties.

This simplies the struct by instead having it contain the set of computed values (for a given element) that is being populated and classify properties into "early" and "other", such that the only dependencies can be from "other" to "early". We iterate applicable_declarations twice, first cascading "early" properties then "other". Unfortunately, it’s not easy to check that this classification is correct.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9929)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Mar 19, 2016

@bors-servo bors-servo merged commit 529164e into master Mar 19, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@SimonSapin SimonSapin deleted the cascade branch Mar 19, 2016
.${property.ident} = computed_value;
% endif

% if property.name in DERIVED_LONGHANDS:
% if not style_struct.inherited:

This comment has been minimized.

Copy link
@bholley

bholley Mar 22, 2016

Contributor

@SimonSapin what happened to this bit?

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Mar 22, 2016

Author Member

It’s not needed since derive_from_* functions don’t take a computed_value parameter anymore. Computed values (as known "so far") are already available through e.g. context.style.box_.display, whereas context.display was previously the specified value, so when the computed value was needed it had to be passed separately.

This comment has been minimized.

Copy link
@bholley

bholley Mar 22, 2016

Contributor

I was talking about the |if not style_struct.inherited| bit.

This comment has been minimized.

Copy link
@SimonSapin

SimonSapin Mar 23, 2016

Author Member

Yes. In this function non-inherited styles are cached so we don’t need to run the cascade for them again. let computed_value = …; is in a larger block above is in % if style_struct.inherited: (without not).

Before this PR, computed_value was needed unconditionally, so this % if not style_struct.inherited: block (with not) defined it for the rest of the cases. Now that computed_value is not used in the derive_from_* call anymore, this second let computed_value = …; statement would be dead code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants
You can’t perform that action at this time.