Bug 1779940 part 3 - Add dummy ScopeBindingCache, and get it across. r=arai
This patch isolate the boiler plate code to create a dummy ScopeBindingCache with no logic to split the noise of this not-so mechanical patch driven by compiler error messages. This patch modify the interface of every function, adding the option to provide a custom ScopeBindingCache when parsing a Stencil, except for publicly facing functions such as from `js/public/experimental/JSStencil.h`. The intent being that Helper thread functions, which are relying on Stencil should have their own ScopeBindingCache which is either unused, or dedicated to caching the bindings of multiple delazifications. The reasons are that in the future we are interested in stripping the JSContext* out of HelperThreads, and that there is no value in sharing the content across threads. Differential Revision: https://phabricator.services.mozilla.com/D154513
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
#endif
|
||||
#include "frontend/ModuleSharedContext.h"
|
||||
#include "frontend/Parser.h"
|
||||
#include "frontend/ScopeBindingCache.h" // js::frontend::ScopeBindingCache
|
||||
#include "frontend/SourceNotes.h" // SrcNote, SrcNoteType, SrcNoteIterator
|
||||
#include "gc/PublicIterators.h"
|
||||
#ifdef DEBUG
|
||||
@@ -5442,14 +5443,16 @@ template <typename Unit>
|
||||
}
|
||||
|
||||
MainThreadErrorContext ec(cx);
|
||||
js::frontend::NoScopeBindingCache scopeCache;
|
||||
UniquePtr<frontend::ExtensibleCompilationStencil> stencil;
|
||||
if (goal == frontend::ParseGoal::Script) {
|
||||
stencil = frontend::CompileGlobalScriptToExtensibleStencil(
|
||||
cx, &ec, cx->stackLimitForCurrentPrincipal(), input.get(), srcBuf,
|
||||
ScopeKind::Global);
|
||||
cx, &ec, cx->stackLimitForCurrentPrincipal(), input.get(), &scopeCache,
|
||||
srcBuf, ScopeKind::Global);
|
||||
} else {
|
||||
stencil = frontend::ParseModuleToExtensibleStencil(
|
||||
cx, &ec, cx->stackLimitForCurrentPrincipal(), input.get(), srcBuf);
|
||||
cx, &ec, cx->stackLimitForCurrentPrincipal(), input.get(), &scopeCache,
|
||||
srcBuf);
|
||||
}
|
||||
|
||||
if (!stencil) {
|
||||
@@ -5678,8 +5681,9 @@ static bool FrontendTest(JSContext* cx, unsigned argc, Value* vp,
|
||||
}
|
||||
|
||||
LifoAllocScope allocScope(&cx->tempLifoAlloc());
|
||||
frontend::NoScopeBindingCache scopeCache;
|
||||
frontend::CompilationState compilationState(cx, allocScope, input.get());
|
||||
if (!compilationState.init(cx, &ec)) {
|
||||
if (!compilationState.init(cx, &ec, &scopeCache)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5754,8 +5758,9 @@ static bool SyntaxParse(JSContext* cx, unsigned argc, Value* vp) {
|
||||
}
|
||||
|
||||
LifoAllocScope allocScope(&cx->tempLifoAlloc());
|
||||
frontend::NoScopeBindingCache scopeCache;
|
||||
frontend::CompilationState compilationState(cx, allocScope, input.get());
|
||||
if (!compilationState.init(cx, &ec)) {
|
||||
if (!compilationState.init(cx, &ec, &scopeCache)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user