Bug 1652126: Obtain an OffThreadToken immediately so parse tasks can be canceled anytime, and clean up dangling Runnables during cancellation. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D89465
This commit is contained in:
Denis Palmeiro
2020-09-11 15:28:04 +00:00
parent 550b941b20
commit 274ab31942
3 changed files with 53 additions and 15 deletions

View File

@@ -7,6 +7,7 @@
#ifndef mozilla_dom_ScriptLoadRequest_h
#define mozilla_dom_ScriptLoadRequest_h
#include "mozilla/Atomics.h"
#include "mozilla/Assertions.h"
#include "mozilla/CORSMode.h"
#include "mozilla/dom/Element.h"
@@ -324,6 +325,10 @@ class ScriptLoadRequest
JS::OffThreadToken* mOffThreadToken; // Off-thread parsing token.
Maybe<nsString> mSourceMapURL; // Holds source map url for loaded scripts
Atomic<Runnable*> mRunnable; // Runnable created when dispatching off thread
// compile. Tracked here so that it can be
// properly released during cancellation.
// Holds the top-level JSScript that corresponds to the current source, once
// it is parsed, and planned to be saved in the bytecode cache.
JS::Heap<JSScript*> mScript;