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 upFix uses of JS<T> as a type on the stack #8026
Conversation
highfive
commented
Oct 15, 2015
|
Nice work! -S-awaiting-review +S-needs-code-changes Reviewed 7 of 7 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 11 of 11 files at r4, 7 of 7 files at r5, 1 of 1 files at r6. components/script/dom/bindings/js.rs, line 232 [r1] (raw file): components/script/dom/bindings/js.rs, line 305 [r1] (raw file): components/script/dom/document.rs, line 304 [r4] (raw file): components/script/dom/nodelist.rs, line 106 [r5] (raw file): Comments from the review on Reviewable.io |
|
Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. components/script/dom/bindings/js.rs, line 232 [r1] (raw file): components/script/dom/document.rs, line 304 [r4] (raw file): Comments from the review on Reviewable.io |
|
|
A copy of a JS<T> doesn't have the rooting properties of the original, so it makes no sense for it to implement Copy.
It's never correct to return a JS<T>. Maybe the lint should catch this?
MutNullableHeap is going away in favor of MutNullableHeapJS.
get() must always return a rooted value, because we have no way of ensuring the value won't be invalidated. set() takes an &T because it's convenient; there isn't any need to expose JS<T>.
…omments.
|
Rebased, addressed review comments. |
|
I'm curious if eefriedman@7a08b29 passes the rooting static analysis. I believe it shouldn't, since DOMRefCell isn't a |
|
Yes, this branch passes the lint. Why were you expecting it to trigger? (The current version of the |
|
Mmm, I forgot that the work in #4336 only blacklisted some particular types, rather than fully supporting generic types :( |
|
@bors-servo r+ -S-needs-rebase Reviewed 11 of 11 files at r7. Comments from the review on Reviewable.io |
|
|
Fix uses of JS<T> as a type on the stack `JS<T>` belongs on the heap, and only on the heap. This is a collection of fixes so that code uses either `Root<T>` or `&T` to pass around garbage-collected pointers. Ideally, we could completely ban constructing a `JS<T>` outside of constructor functions, but we aren't quite there yet. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8026) <!-- Reviewable:end -->
|
|
|
Can someone explain to me why &T is safe but JS is not? |
|
Because the only way to obtain |
|
I see. But what happens if the GC moves the |
|
The |
|
I see - so what happens when the GC wants to move the JS object allocated in the same buffer? Or are we not doing that anymore? |
|
The future of fused/magic DOM objects is still undecided. |
|
Ok - but what is the current behavior? Does the GC move the reflectors, or is moving GC disabled? |
|
Moving GC should be enabled; the only GC feature I'm aware of that's disabled is incremental GC. |
|
Oh - so the thing that isn't enabled is fused objects? I thought those were there from the start, but I suppose I'm probably wrong. |
|
Right, we've always had separate reflectors and Rust DOM objects. |
eefriedman commentedOct 15, 2015
JS<T>belongs on the heap, and only on the heap. This is a collection of fixes so that code uses eitherRoot<T>or&Tto pass around garbage-collected pointers.Ideally, we could completely ban constructing a
JS<T>outside of constructor functions, but we aren't quite there yet.