Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r...
commit9041daf265a5e2dda2283a2bec011a9ed07c401f
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 17 Jan 2023 17:06:50 +0000 (17 17:06 +0000)
committerJon Coppeard <jcoppeard@mozilla.com>
Tue, 17 Jan 2023 17:06:50 +0000 (17 17:06 +0000)
treeef11da8203badac025edfa9a35337809ce419210
parent4b6832ec0c14dfd6067f5f1f8c484a4a18191d93
Bug 1809861 - Part 1: Simplify and clean up off-main thread script compilation r=smaug

The main change in this patch is to prevent access to main-thread objects
while off-thread. This is done by using nsMainThreadPtrHandle to wrap main
thread pointers in the runnable. This prevents access to their targets when
off thread and ensure they are only released on the main thread.

This means that mRunnable is now only accessed on the main thread and so it
doesn't need to be atomic and can be a normal RefPtr. We also don't need to
leak a reference to it in AttemptOffThreadScriptCompile.

This also requires that timing data is moved to the runnable.

Cancellation should always have happened by unlink or destruction of
ScriptLoadContext so handling for that is removed.

Differential Revision: https://phabricator.services.mozilla.com/D166667
dom/script/ScriptLoadContext.cpp
dom/script/ScriptLoadContext.h
dom/script/ScriptLoader.cpp
dom/script/ScriptLoader.h