Repository navigation
Replace FlowRef with Arc<Flow>, now that Arc supports DST. - #7237
Conversation
|
@pcwalton In |
|
☔ The latest upstream changes (presumably #7177) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I'm uncomfortable with the amount of unsafe code this introduces throughout layout. The whole idea of parallel layout is that you are allowed to mutably access the flow you're working on only (as well as its children, but not its siblings). That's why I (tried to) forbid One way to do this would be to encapsulate the |
How can we make sure this rule is not violated in the current code or when reviewing layout code changes?
I don’t understand how |
It's only unsound in that it relies on undefined behavior (that the Rust compiler doesn't currently exploit, and likely won't for a long time). It's not actually unsafe, because FlowRefs never leak to the guts of layout. This is something that was designed a couple of years ago; the comments in #6503 are missing all the background.
One way would be to encapsulate the transmutation from |
|
Getting In the mean time, at least having |
|
The tree structure should ensure that it's safe. However, that crucially depends on the guts of layout never being able to see the |
|
Ok. So how does this PR look now? |
|
☔ The latest upstream changes (presumably #7294) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rebased. |
|
☔ The latest upstream changes (presumably #7265) made this pull request unmergeable. Please resolve the merge conflicts. |
… and WeakFlowRef with Weak<Flow>.
|
Rebased. |
There was a problem hiding this comment.
I don't think you will succeed. The reference count will pretty much never be 1, since it's a doubly-linked tree.
|
This looks OK except for the goal in the comment. I think that we should instead fix the undefined behavior problem in the long term (with |
See discussion in #7237
|
I’ve rephrased the comment. I don’t understand what you mean with |
|
Two threads can't mutate the same flow at the same time due to the tree structure. |
|
@bors-servo r=pcwalton
|
|
📌 Commit 21d6931 has been approved by |
Replace FlowRef with Arc<Flow>, now that Arc supports DST. … and `WeakFlowRef` with `Weak<Flow>`. r? @pcwalton <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7237) <!-- Reviewable:end -->
… and
WeakFlowRefwithWeak<Flow>.r? @pcwalton