Commit graph

68 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
0bcd36838d
style: Remove redundant style sharing check.
We check that a few lines before calling test_candidate.
2017-11-30 17:26:45 +01:00
Emilio Cobos Álvarez
47b02658ec
style: Move lru_cache to its own crate.
One less crate pointlessly in components/.
2017-11-15 16:18:11 +01:00
Emilio Cobos Álvarez
0df912be93
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU
2017-10-28 12:43:43 +02:00
Gecko Backout
cda9d186c1 Backed out changeset fc813bf68348 for failing reftest layout/reftests/bugs/272646-1.xul on OS X. r=backout
Backs out https://github.com/servo/servo/pull/19045
2017-10-28 08:08:47 +00:00
Emilio Cobos Álvarez
4b43b7c7f8
style: Make style sharing look at XBL / Shadow DOM rules.
Bug: 1412251
Reviewed-by: bz
MozReview-Commit-ID: II6lk6OmSZU
2017-10-28 02:13:59 +02:00
Bobby Holley
438740b912 Implement an nth-index cache.
MozReview-Commit-ID: Ee0um3QXkxl
2017-09-21 15:25:38 -07:00
Bobby Holley
48466bf876 Introduce an NthIndexCache type and pipe it from ThreadLocalStyleContext to MatchingContext.
Some future refactoring here to pass fewer things as parameters would be nice.
2017-09-20 23:22:38 -07:00
Bobby Holley
05c03d5104 Hoist lookup() into lru_cache.
MozReview-Commit-ID: F5FbKFqpXEh
2017-09-20 23:22:33 -07:00
Bobby Holley
13a3cf27a8 LRUCache::new -> LRUCache::default.
MozReview-Commit-ID: KouOaYTluRx
2017-09-20 23:22:27 -07:00
Bobby Holley
8b6c5988b5 Hoist the LRU cache into its own crate to share it with selectors. 2017-09-20 23:22:20 -07:00
Bobby Holley
4abe8002e9 Bug 1401317 - Make second pass sharing sensitive to DISABLE_STYLE_SHARING_CACHE. r=emilio
MozReview-Commit-ID: 8U0xekMHGg8
2017-09-19 23:09:12 -07:00
Emilio Cobos Álvarez
a5842165d9
style: Assert we don't try to share against ourselves. 2017-09-18 04:57:53 +02:00
Emilio Cobos Álvarez
891bc7d174
style: Massage the resolver code so it's cleaner and prevents the problem.
This way all the borrows stay in the sharing code, and prevents an extra borrow
on a cache hit, which is not a big deal but nice.
2017-09-18 04:57:50 +02:00
Emilio Cobos Álvarez
36fed07b1c
style: avoid testing against ourselves in lookup_for_rules.
There's a path in finish_restyle, where we can recascade a style for a given
element, in get_after_change_style.

I haven't been able to construct a test-case for this, but this is the only
coherent story I have for crashes like:

  https://crash-stats.mozilla.com/report/index/bcdfe629-ca1f-4e4d-aa17-27f890170917#tab-details
2017-09-18 03:23:32 +02:00
Bobby Holley
703a5c93d0 Undo #18497 in the MatchAndCascade case.
It's easy to construct examples where not inserting in those cases causes performance
to get worse (for example, any long list of siblings that match the same selectors
while having some non-effectual differences in LocalName/Class/Id/etc). And the LRU
nature of the cache already does the right thing of pruning non-useful entries.

Fixing this causes several hundred more sharing hits on wikipedia.

MozReview-Commit-ID: L7W8vcMnHaq
2017-09-15 23:21:00 -07:00
Matt Brubeck
286888009f Make LRUCache use a linked list to reduce memmoves.
https://bugzilla.mozilla.org/show_bug.cgi?id=1398957
2017-09-14 11:33:02 -07:00
Emilio Cobos Álvarez
158aa0ffdf
style: Move the check into insert_if_possible. 2017-09-14 11:56:45 +02:00
Emilio Cobos Álvarez
9d671058df
style: Reformat the signature of insert_if_possible. 2017-09-14 09:59:48 +02:00
Bobby Holley
8e5c1c771e Share styles during recascades.
MozReview-Commit-ID: AFTwtzi4P93
2017-09-13 22:06:46 -07:00
Bobby Holley
1c9b39a8e8 Do a second pass on the sharing cache to reuse style by rule node identity.
MozReview-Commit-ID: H67j3Sbt3gr
2017-09-13 22:06:39 -07:00
Bobby Holley
9092e6b4c2 Return the element rather than styles from the style sharing cache.
This gives us more flexibility, and doesn't cost us anything.

MozReview-Commit-ID: CuvOEcLA3My
2017-09-13 22:06:24 -07:00
Bobby Holley
729db5ccec Cache the parent CV identity on ValidationData.
This will make the linear probing faster. If we end up implementing the two-tier
cache setup, this code will be unnecessary and can go away.

MozReview-Commit-ID: BRfV5ump34n
2017-09-13 22:06:17 -07:00
Bobby Holley
7b019f807b Use inheritance_parent to control style_sharing.
Using traversal_parent here is wrong.

MozReview-Commit-ID: GHCIjkgx4VE
2017-09-13 22:06:09 -07:00
bors-servo
af077a7222 Auto merge of #18420 - servo:toml, r=nox,emilio
Get rustc commit hash from channel manifest

… added in https://github.com/rust-lang/rust/pull/44218, instead of using the GitHub API.

Also upgrade to rustc 1.22.0-nightly (d93036a04 2017-09-07).

<!-- 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/18420)
<!-- Reviewable:end -->
2017-09-12 05:01:24 -05:00
Simon Sapin
0d4168034f Un-inline some methods initializing thread_local! …
… in order to limit stack frame sizes after extra inlining from
https://github.com/rust-lang/rust/pull/43931

See https://github.com/servo/servo/pull/18420#issuecomment-328769322
2017-09-12 11:42:04 +02:00
Bobby Holley
8268217767 Avoid memmoving ValidationData more than necessary.
MozReview-Commit-ID: 70w3bZ2FU0W
2017-09-11 22:39:35 -07:00
Bobby Holley
74b4f95d71 Encapsulate the sharing cache backend better.
MozReview-Commit-ID: 2x9BIhmwH83
2017-09-11 22:39:34 -07:00
Bobby Holley
db67cd1759 Shorten the naming around the style sharing cache.
MozReview-Commit-ID: EcVQDLoxwFP
2017-09-11 22:39:31 -07:00
Matt Brubeck
21006fb752 Use SmallBitVec to replace BitVec 2017-09-11 06:33:43 -07:00
Hiroyuki Ikezoe
6ed7c69281 Don't cache style data if the element has running animations. 2017-08-23 09:51:27 +09:00
Bobby Holley
54c52910e4 Introduce a new flag and use it to be more permissive about cousin sharing.
MozReview-Commit-ID: BCJg0Ycsy6M
2017-08-05 01:07:02 -07:00
Michael Partheil
b07ebbae6b Replace all uses of the style::stylearc alias with servo_arc.
The alias is left there temporarilly and will be removed completely in a later commit where
also components/style/gecko/generated/structs_{debug|release}.rs are re-generated (they still
use the old alias).
2017-07-19 09:29:05 +02:00
Manish Goregaokar
8d7a368377 stylo: Don't ignore visited state when deciding to share style contexts 2017-07-18 12:40:01 -07:00
Hiroyuki Ikezoe
f91126ba86 Add has_current_styles_for_traversal().
In animation-only restyle, we just need to check the element
has animation restyle hints or has recascade self which is a result
of animation-only restyle for ancestors.
has_current_styles() in Servo_ResolveStyle() is intentionally left there,
it will be changed in a subsequent patch.
2017-07-18 19:13:50 +09:00
bors-servo
6597178b91
Auto merge of #17701 - bholley:reuse_allocations, r=emilio
reuse the bloom filter and style sharing cache across traversals

https://bugzilla.mozilla.org/show_bug.cgi?id=1380198

<!-- 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/17701)
<!-- Reviewable:end -->
2017-07-14 11:01:07 +02:00
bors-servo
1c85c55d02 Auto merge of #17713 - emilio:less-code-is-lovely, r=heycam
style: Kill some style sharing code.

It's trivial to do so after #17688.

<!-- 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/17713)
<!-- Reviewable:end -->
2017-07-14 00:25:37 -07:00
Emilio Cobos Álvarez
8667cea4ca
style: Don't stop looking at the sharing cache for various reasons.
All the information that made those failures expensive is now lazily computed
and cached, or eagerly computed anyway, so seems not worth to stop iteration.
2017-07-13 16:23:56 +02:00
Emilio Cobos Álvarez
62310d9bd5
style: Don't use the current element info for cached validation data.
We can take it straight from the validation target.
2017-07-13 15:36:59 +02:00
Emilio Cobos Álvarez
36310e3b66
style: Kill some style sharing code.
MozReview-Commit-ID: 42MyHx3QHuu
2017-07-13 15:32:20 +02:00
Emilio Cobos Álvarez
a34f288b98
Revert "Auto merge of #17701 - bholley:reuse_allocations, r=emilio"
This reverts commit ebfc8f5858, reversing
changes made to 5585ff2c44.

Animation code can reenter and create a new TLS context from the traversal
SequentialTask, so this won't work as written.
2017-07-13 09:58:08 +02:00
Bobby Holley
3bce0c7652 Stop using SendElement in StyleSharingCandiate.
MozReview-Commit-ID: AuNPDsq8bgk
2017-07-12 16:38:08 -07:00
Bobby Holley
ec6cca6d08 Reuse style sharing cache across traversals.
MozReview-Commit-ID: 9wCJtciqs6K
2017-07-12 16:38:07 -07:00
Emilio Cobos Álvarez
c6d5dbbb01
style: Rewrite restyling to split between resolving styles and handling changes.
MozReview-Commit-ID: 4BzjbLbFebF
2017-07-12 09:26:36 +02:00
J. Ryan Stinnett
2b5c56e6a8 Move match and cascade temporaries to CurrentElementInfo
Before this change, the `ComputedStyle` struct that is part of permanent style
data per element holds 2 `StrongRuleNode`s (unvisited and visited) and 2
`Arc<ComputedValues>` (unvisited and visited).

Both rule nodes and the visited values don't actually need to be here.  This
patch moves these 3 to new temporary storage in `CascadeInputs` on
`CurrentElementInfo` during the match and cascade process.  Rule nodes are
pushed down inside the `ComputedValues` for later access after the cascade.
(Visited values were already available there.)

The permanent style data per element now has just the `Arc<ComputedValues>` for
itself and eager pseudo-elements (plus the `RestyleHint`).

MozReview-Commit-ID: 3wq52ERMpdi
2017-06-22 15:47:32 -05:00
Emilio Cobos Álvarez
ffc45e9aaa
style: Inline RestyleData.
Bug: 1368236
MozReview-Commit-ID: 49s3SO0PMHf
2017-06-16 03:36:18 +02:00
Bobby Holley
a98fff1af8 Hoist ApplicableDeclaration{Block,List} into a separate file.
MozReview-Commit-ID: EXnAzfyoZ1e
2017-06-12 12:13:21 -07:00
Cameron McCormack
c533097e20 style: Distinguish between the tree structures used for traversal and selector matching.
This patch renames TNode::parent_element to traversal_parent, since it returns
the parent from the perspective of traversal (which in Gecko uses the
flattened tree).  It also renames TNode::children to traversal_children
for the saem reason.

We keep parent_element and children functions on TNode to use for selector
matching, which must be done on the real DOM tree structure.
2017-06-09 18:37:35 +08:00
bors-servo
310408a828 Auto merge of #17245 - bzbarsky:share-pseudo-styles, r=emilio
Share styles for elements with eager pseudo-elements attached to them

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1329361

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17245)
<!-- Reviewable:end -->
2017-06-08 15:25:10 -07:00
Boris Zbarsky
9110241360 Share styles for elements with eager pseudo-elements attached to them. 2017-06-08 15:34:30 -04:00
Boris Zbarsky
2f2b93c521 Increase the size of the style sharing cache to 31.
Still a lot of guesswork here, but this does seem to get us better sharing.  See
https://bugzilla.mozilla.org/show_bug.cgi?id=1369621 for some data.
2017-06-08 14:14:44 -04:00