Closed Bug 1782569 Opened 3 years ago Closed 3 years ago

Add JSContext-free variant of js::ReportOutOfMemory()

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
105 Branch
Tracking Status
firefox105 --- fixed

People

(Reporter: bthrall, Assigned: bthrall)

References

Details

Attachments

(18 files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

js::ReportOutOfMemory() requires a JSContext, but is called in several places during compilation (see here , here, and here).

To remove JSContext from off-thread compilation, we need a version of js::ReportOutOfMemory() that uses ErrorContext.

Component: General → JavaScript Engine
Product: Firefox → Core
Assignee: nobody → bthrall
Status: NEW → ASSIGNED
Severity: -- → N/A
Priority: -- → P2

Following the pattern set by JS::ReportOverRecursed().

JSErrorNotes::addNoteASCII() is the only one currently required for off-thread
compiling, but I added support for addNoteLatin1() and addNoteUTF8() for
consistency.

ErrorArgumentsType declaration moved to ErrorReport.h to resolve header
#include recursion.

There's no need to go through the ParseContext's SharedContext to get the
ErrorContext in GeneralParser. For the main thread, it is the same context, and
off-thread we can use the ErrorContext member directly.

Depends on D153962

We will use it with ReportOutOfMemory() calls and probably other places.

Specifically: FunctionBox::setAsmJSModule() calls ReportOutOfMemory().

Depends on D153965

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.

Depends on D153970

Blocks: 1783935
Blocks: 1783951

ASTSerializer is not used in helper threads, so it doesn't need ErrorContext,
but it is better to reuse the existing MainThreadErrorContext in
reflect_parse() than to create a new one. Deciding which ErrorContext to use
should happen in few places, not everywhere.

Depends on D153971

ParserBase::liftParserAtomToJSAtom() moved down from ParserSharedBase because
it seemed slightly easier than plumbing the ErrorContext member up to
ParserSharedBase.

CompilationStencil::instantiateSelfHostedAtoms() knows it isn't used by helper
threads because it is for self-hosted code.

CompilationStencil::instantiateStencilAfterPreparation() is instantiating the
stencil, so it happens on the main thread.

Depends on D154459

Instantiating stencils happens on the main thread, so
InstantiateModuleStencil(), and InstantiateModuleStencilXDR() can safely use
MainThreadErrorContext.

Depends on D154463

If this is happening off the main thread, the errors are tracked in
ErrorContext, not JSContext.

Depends on D154464

Attachment #9288834 - Attachment description: WIP: Bug 1782569 - Extract JSContext::onOutOfMemory() → Bug 1782569 - Extract JSContext::onOutOfMemory() r=nbp
Attachment #9288835 - Attachment description: WIP: Bug 1782569 - Add JS::ReportOutOfMemory(ErrorContext*) → Bug 1782569 - Add JS::ReportOutOfMemory(ErrorContext*) r=nbp
Attachment #9288836 - Attachment description: WIP: Bug 1782569 - Use ErrorContext instead of JSContext for off-thread ReportOutOfMemory() → Bug 1782569 - Use ErrorContext instead of JSContext for off-thread ReportOutOfMemory() r=nbp
Attachment #9288837 - Attachment description: WIP: Bug 1782569 - Use ErrorContext from BytecodeEmitter for ReportOutOfMemory() → Bug 1782569 - Use ErrorContext from BytecodeEmitter for ReportOutOfMemory() r=nbp
Attachment #9288838 - Attachment description: WIP: Bug 1782569 - Use ErrorContext for ReportOutOfMemory() in FullParseHandler → Bug 1782569 - Use ErrorContext for ReportOutOfMemory() in FullParseHandler r=nbp
Attachment #9288839 - Attachment description: WIP: Bug 1782569 - Add ErrorContext member to SharedContext → Bug 1782569 - Add ErrorContext member to SharedContext r=nbp
Attachment #9288840 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in FunctionBox::setAsmJSModule() → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in FunctionBox::setAsmJSModule() r=nbp
Attachment #9288841 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in CollectionPool::acquire() → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in CollectionPool::acquire() r=nbp
Attachment #9288842 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() in ObjLiteralWriter and ObjLiteralWriterBase → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() in ObjLiteralWriter and ObjLiteralWriterBase r=nbp
Attachment #9288843 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in CompilationGCOutput::ensureReserved() → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in CompilationGCOutput::ensureReserved() r=nbp
Attachment #9288844 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportoutOfMemory for Stencil. → Bug 1782569 - Pass ErrorContext to ReportoutOfMemory for Stencil. r=nbp
Attachment #9289562 - Attachment description: WIP: Bug 1782569 - Add ErrorContext member to ASTSerializer → Bug 1782569 - Add ErrorContext member to ASTSerializer r=nbp
Attachment #9289563 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for CompilationAtomCache → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for CompilationAtomCache r=nbp
Attachment #9289564 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in Scope::maybeReportOOM() → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory in Scope::maybeReportOOM() r=nbp
Attachment #9289565 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() when creating scope data → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() when creating scope data r=nbp
Attachment #9289566 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for ScopeStencil → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for ScopeStencil r=nbp
Attachment #9289567 - Attachment description: WIP: Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for ParserAtom, ParserAtomsTable, ScriptSource, SharedImmutableScriptData → Bug 1782569 - Pass ErrorContext to ReportOutOfMemory() for ParserAtom, ParserAtomsTable, ScriptSource, SharedImmutableScriptData r=nbp
Attachment #9289568 - Attachment description: WIP: Bug 1782569 - Recover from OOM using ErrorContext → Bug 1782569 - Recover from OOM using ErrorContext r=nbp
Pushed by bthrall@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/294263a92e96 Extract JSContext::onOutOfMemory() r=nbp https://hg.mozilla.org/integration/autoland/rev/c33f089db610 Add JS::ReportOutOfMemory(ErrorContext*) r=nbp https://hg.mozilla.org/integration/autoland/rev/af724b3e2951 Use ErrorContext instead of JSContext for off-thread ReportOutOfMemory() r=nbp https://hg.mozilla.org/integration/autoland/rev/b83b667d8244 Use ErrorContext from BytecodeEmitter for ReportOutOfMemory() r=nbp https://hg.mozilla.org/integration/autoland/rev/6a9f97b3e66a Use ErrorContext for ReportOutOfMemory() in FullParseHandler r=nbp https://hg.mozilla.org/integration/autoland/rev/24737a6aae0a Add ErrorContext member to SharedContext r=nbp https://hg.mozilla.org/integration/autoland/rev/08d3b76abe02 Pass ErrorContext to ReportOutOfMemory in FunctionBox::setAsmJSModule() r=nbp https://hg.mozilla.org/integration/autoland/rev/70436815ee6d Pass ErrorContext to ReportOutOfMemory in CollectionPool::acquire() r=nbp https://hg.mozilla.org/integration/autoland/rev/69dd93866f29 Pass ErrorContext to ReportOutOfMemory() in ObjLiteralWriter and ObjLiteralWriterBase r=nbp https://hg.mozilla.org/integration/autoland/rev/9d377710076a Pass ErrorContext to ReportOutOfMemory in CompilationGCOutput::ensureReserved() r=nbp https://hg.mozilla.org/integration/autoland/rev/6aad32b63896 Pass ErrorContext to ReportoutOfMemory for Stencil. r=nbp https://hg.mozilla.org/integration/autoland/rev/5577cc3982d1 Add ErrorContext member to ASTSerializer r=nbp https://hg.mozilla.org/integration/autoland/rev/01541d4bf42e Pass ErrorContext to ReportOutOfMemory() for CompilationAtomCache r=nbp https://hg.mozilla.org/integration/autoland/rev/18c6e6eea130 Pass ErrorContext to ReportOutOfMemory in Scope::maybeReportOOM() r=nbp https://hg.mozilla.org/integration/autoland/rev/bbe13d650d2c Pass ErrorContext to ReportOutOfMemory() when creating scope data r=nbp https://hg.mozilla.org/integration/autoland/rev/a05d45bff643 Pass ErrorContext to ReportOutOfMemory() for ScopeStencil r=nbp https://hg.mozilla.org/integration/autoland/rev/dff2454b0433 Pass ErrorContext to ReportOutOfMemory() for ParserAtom, ParserAtomsTable, ScriptSource, SharedImmutableScriptData r=nbp https://hg.mozilla.org/integration/autoland/rev/ef4121bbd9c8 Recover from OOM using ErrorContext r=nbp
Blocks: 1782573
Blocks: 1786117
Regressions: 1787730
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: