Bug 1782569 - Pass ErrorContext to ReportoutOfMemory for Stencil. r=nbp

To keep this patch simple to follow, I introduce some temporary functions
(initVector, initMap, setInitial, addDelazification) so I can plumb
ErrorContext through StencilXdr and ParseAtom in separate patches.

Differential Revision: https://phabricator.services.mozilla.com/D153971
This commit is contained in:
Bryan Thrall
2022-08-19 14:59:22 +00:00
parent e78b3c922c
commit b9bfb7ca2c
12 changed files with 243 additions and 178 deletions

View File

@@ -5397,7 +5397,7 @@ static bool DumpAST(JSContext* cx, const JS::ReadOnlyCompileOptions& options,
// Emplace the top-level stencil.
MOZ_ASSERT(compilationState.scriptData.length() ==
CompilationStencil::TopLevelIndex);
if (!compilationState.appendScriptStencilAndData(cx)) {
if (!compilationState.appendScriptStencilAndData(&ec)) {
return false;
}
@@ -5673,8 +5673,9 @@ static bool FrontendTest(JSContext* cx, unsigned argc, Value* vp,
}
LifoAllocScope allocScope(&cx->tempLifoAlloc());
MainThreadErrorContext ec(cx);
frontend::CompilationState compilationState(cx, allocScope, input.get());
if (!compilationState.init(cx)) {
if (!compilationState.init(cx, &ec)) {
return false;
}
@@ -5748,12 +5749,12 @@ static bool SyntaxParse(JSContext* cx, unsigned argc, Value* vp) {
}
LifoAllocScope allocScope(&cx->tempLifoAlloc());
MainThreadErrorContext ec(cx);
frontend::CompilationState compilationState(cx, allocScope, input.get());
if (!compilationState.init(cx)) {
if (!compilationState.init(cx, &ec)) {
return false;
}
MainThreadErrorContext ec(cx);
Parser<frontend::SyntaxParseHandler, char16_t> parser(
cx, &ec, cx->stackLimitForCurrentPrincipal(), options, chars, length,
/* foldConstants = */ false, compilationState,