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 upComplexSelector to_css should probably not do recursion #16019
Comments
|
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
|
Happy to mentor this one. |
|
Presumably we'll want to convert the code in https://dxr.mozilla.org/servo/rev/103e827948e4c3592ee93cbed8adf270588b559e/components/selectors/parser.rs#379-382 to use a loop instead? |
|
Yes, that is the general idea. The complication is that you want to loop backwards over a singly linked list. Gecko does the obvious thing here: use a growable array with some preallocated stack storage (so you don't have to heap-allocate in common cases), walk the linked list adding things to the array, then walk the array backwards in a loop. |
|
Hi, I'm looking to contribute to servo. Is this being worked on/assigned? |
|
Please take it if you want! Reply to this mentioning @highfive, or saying you want to take it, and we'll assign it to you :) |
|
Okay, awesome. @highfive: assign me |
|
Hey @tictakk! Thanks for your interest in working on this issue. It's now assigned to you! |
|
cc @emilio |
|
@tictakk Any news on this? |
|
@wafflespeanut Spent the weekend finishing a school project and brushing up on Rust. I'll be expeditious as possible. |
|
Great! |
|
@emilio Hey, I think I could use some of that mentorship you mentioned. Should I be creating a vector of each child and looping to_css() one at a time? |
|
Yes, that sounds right. We could consider creating a |
Removing recursion from ComplexSelector <!-- Please describe your changes on the following line: --> Using a smallvec instead of recursively calling to_css for ComplexSelector to handle running out of stack. --- <!-- 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 #16019 (github issue number if applicable). <!-- Either: --> - [X] 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/16347) <!-- Reviewable:end -->
Currently it does:
which will run into crashes due to running out of stack; see https://bugzilla.mozilla.org/show_bug.cgi?id=475215