script: Store a Weak handle to ScriptThread in both ScriptThread and Window#40645
script: Store a Weak handle to ScriptThread in both ScriptThread and Window#40645mrobinson merged 6 commits intoservo:mainfrom
Weak handle to ScriptThread in both ScriptThread and Window#40645Conversation
0c4a5fc to
3e7dcbf
Compare
|
@mrobinson I wanted to grab this before somebody else does. However, I am not quite sure if this is safe.
|
|
I think this actually can be made safe if we trace the weak by upgrading it. |
3e7dcbf to
6aeb032
Compare
|
@sagudev Perhaps it is better to explain this in this example (related to servo/mozjs#659) as explained. With the upgraded Weak being the only valid reference that is not reachable by trace. |
We have custom_trace: , although it's mainly used to bypass orphan rules of rust, we can use it in this case to customize behavior. |
1deb29f to
ed91cb8
Compare
|
Tracing of the |
Indeed: servo/components/script/script_runtime.rs Line 1116 in bc9e8d2 |
|
I think we should land this one and land it as an incremental step toward #40864. |
1b24a82 to
aad2a01
Compare
|
@mrobinson Ok this should be ready now. |
Use this to call microtask checkpoint directly. Signed-off-by: Narfinger <[email protected]>
|
@Narfinger Thanks. A few small requests based on the changes that I made in #40864. |
Signed-off-by: Narfinger <[email protected]>
mrobinson
left a comment
There was a problem hiding this comment.
Couple minor suggestions, but otherwise this looks good. Thanks!
Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Narfinger <[email protected]>
Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Narfinger <[email protected]>
Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Narfinger <[email protected]>
Co-authored-by: Martin Robinson <[email protected]> Signed-off-by: Narfinger <[email protected]>
|
Thanks for the help getting this done! I really appreciate all the comments. |
Weak handle to ScriptThread in both ScriptThread and Window
We construct
ScriptThreadin anRcwhich itself has the givenWeakfor it. It then can give it toWindowand other elements in the future. We currently only use this for the microtask checkpoint function inWindow. This is the first step toward eliminating the usage of thread local storage to access theScriptThread.Testing: This should not change behavior so is covered by existing tests.
Fixes: Part of addressing: #37969 (comment)