Add Vector/ParserAtomsTable variant of CompilationStencil
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox88 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(5 files, 5 obsolete files)
To achieve bug 1687095, one of the solution is to add Vector/ParserAtomsTable variant of CompilationStencil, and store the initial stencil of that type into XDR encoder associated with ScriptSource,
and merge/accumulate all delazifications into the initial stencil,
and encode the single CompilationStencil into XDR buffer.
This will solve the ScriptStencil duplication, ParserAtom duplication,
and also reduce the time taken by decode+instantiate.
This will also help bug 1692577, by using Vector/ParserAtomsTable variant of CompilationStencil as the base class of CompilationState, and instantiate directly from it,
so that we can skip CompilationState::finish call.
The plan is:
- Templatize
BaseCompilationStencil/CompilationStencilforSpan/ParserAtomSpantypes - Add
Vector/ParserAtomsTablevariant ofBaseCompilationStencil/CompilationStencil - Make
CompilationStatea subclass of theVector/ParserAtomsTablevariant ofCompilationStencil - Accumulate all information into
CompilationStencilfrom parser/emitter (don't store any info into finalCompilationStencil) - Make
CompilationState::finishcopy/move all data fromVectorvariant toSpanvariant - Support instantiation from
Vector/ParserAtomsTablevariant ofCompilationStencil - for the case
CompilationStencildoesn't escape compilation scope, do not callCompilationState::finishbut instantiate fromCompilationState
| Assignee | ||
Comment 1•5 years ago
|
||
And the plan for bug 1687095:
- In initial compilation, do not finish into
Spanvariant ofCompilationStencil, but instantiate fromVectorvariant ofCompilationStencil, and store it intoXDRIncrementalStencilEncoder - In delazification, do not finish into
Spanvariant ofCompilationStencil, but instantiate fromVectorvariant ofCompilationStencil, and merge it into initial stencil stored inXDRIncrementalStencilEncoder- with
Vector/ParserAtomsTablevariant ofCompilationStencil, previous patches' way should work, with minor modification:
- with
- when encoding, encode the merged initial stencil
- when decoding, decode the merged initial stencil
| Assignee | ||
Comment 2•5 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #1)
And the plan for bug 1687095:
- In initial compilation, do not finish into
Spanvariant ofCompilationStencil, but instantiate fromVectorvariant ofCompilationStencil, and store it intoXDRIncrementalStencilEncoder
This will require detaching Vector variant of CompilationStencil from CompilationState, either by moving/copying, or perhaps allocating it on heap instead of using it as base class.
| Assignee | ||
Comment 3•5 years ago
•
|
||
| Assignee | ||
Comment 4•5 years ago
|
||
More plan for bug 1687095:
- once decoding stops using
StencilDelazificationSet, removedelazificationSetfield - merge
BaseCompilationStencilTemplateandCompilationStencilTemplate
Comment 5•5 years ago
|
||
It might be nice for the 'finish' method to be something like CompilationStencil::unshare and have it also support the XDR-decode case if we wanted to the stencil to out-live the XDR buffer in some cases.
| Assignee | ||
Comment 6•5 years ago
|
||
in current patch stack, the implementation of finish method is a copy/move from Vector variant to Span variant,
and internally it supports other direction as well (it was to support "decode and start incremental encoding" tho),
so we could use the "Span variant -> Vector variant" to detach stencil from XDR buffer.
Comment 7•5 years ago
|
||
I was just imagining from Span to -> Span-over-LifoAlloc as a simple thing.
| Assignee | ||
Comment 8•5 years ago
|
||
okay, will look into it.
| Assignee | ||
Comment 9•5 years ago
|
||
| Assignee | ||
Comment 10•5 years ago
|
||
As a preparation to decouple CompilationState from the final CompilationStencil,
removed the direct dependency to CompilationStencil from the constructor.
The later patch adds yet another LifoAlloc inside CompilationState base class.
| Assignee | ||
Comment 11•5 years ago
|
||
Depends on D105140
| Assignee | ||
Comment 12•5 years ago
|
||
To add Vector/ParserAtomsTable variant,
templatize BaseCompilationStencil/CompilationStencil for Span/ParserAtomSpan.
Span type is defined for each element type, to support different Vector inline
storage for each in bug 1689161.
Depends on D105141
| Assignee | ||
Comment 13•5 years ago
|
||
As a preparation to make CompilationState a subclass of
AbstractCompilationStencil.
Depends on D105142
| Assignee | ||
Comment 14•5 years ago
|
||
Add Vector/ParserAtomsTable variant of AbstractCompilationStencil, and
make CompilationState a subclass of it.
Some fields of
AbstractBaseCompilationStencil/AbstractCompilationStencil are unused,
but the later patch fixes it by decoupling parser/emitter from final
CompilationStencil.
Depends on D105143
| Assignee | ||
Comment 15•5 years ago
|
||
Instead of direclty stroing into CompilationStencil, store all data into
CompilationState, from Parser and BytecodeEmitter.
Depends on D105144
| Assignee | ||
Comment 16•5 years ago
|
||
Now prepareStorageFor is called only for CompilationState.
Move/rename it to CompilationState::prepareSharedDataStorage, and directly
use member fields.
Depends on D105145
| Assignee | ||
Comment 17•5 years ago
|
||
Depends on D105146
| Assignee | ||
Comment 18•5 years ago
|
||
Depends on D105147
| Assignee | ||
Comment 19•5 years ago
|
||
after this, maybe we can split Span variant of CompilationStencil into 2 classes, one that points XDR buffer, and one that points only LifoAlloc,
sharing the base template class to keep using the same code.
| Assignee | ||
Comment 20•5 years ago
|
||
After bug 1687095, we can modify each CompilationStencil consumer to use ExtensibleCompilationStencil, so that extra copy doesn't happen in most case.
| Assignee | ||
Comment 21•5 years ago
|
||
(In reply to Ted Campbell [:tcampbell] from comment #7)
I was just imagining from Span to -> Span-over-LifoAlloc as a simple thing.
https://phabricator.services.mozilla.com/D105152 this patch adds "Span/pointer-over-XDR" to "Vector+pointer-over-LifoAlloc" code.
If necessary, we can templatize it to support "Span/pointer-over-XDR" to "Span/pointer-over-LifoAlloc" code as well.
Comment 22•4 years ago
|
||
What is your general thought here around future Smoosh/Rust support? I presume if we continue that work we'd want to get away from Frontend2.cpp if possible. Would we simply keep the ScriptStencil stuff Rust-friendly and do a bit of glue to generate the CompilationStencil? Not a serious concern now, but I want to consider a few different futures if it is easy.
| Assignee | ||
Comment 23•4 years ago
|
||
IMO, the top-level struct doesn't necessarily be byte-to-byte compatible, and some kind of conversion/map is acceptable.
(of course it's better not having such conversion tho)
For inner pointer-free structs like ScriptStencil, we should keep it XDR-friendly, and that will result in Rust-friendly anyway.
In smoosh binding, currently we perform conversion for all types just because we cannot use single [repr(C)] definition across them, for dependency reason.
Once we make jsparagus crate required for all build, we can create a binding from jsparagus's code and use single struct,
that will let us make top-level struct compatible, or generate conversion method automatically.
For Span vs Vector variation, some kind of it will be necessary anyway also in smoosh,
either by having 2 container types, or adding yet-another container that's compatible with both usage (extensible/own vs static/borrow).
the latter might be simpler if we cross the C++/Rust binding, but former will also work with trait and some macro.
in any way, we would use different container types than MFBT, and some kind of rewrite is necessary around consumer.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
| Assignee | ||
Comment 24•4 years ago
|
||
Depends on D105143
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 25•4 years ago
|
||
Comment 26•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/7e752dd5849a
https://hg.mozilla.org/mozilla-central/rev/e443f865ee88
https://hg.mozilla.org/mozilla-central/rev/6a6215a33d11
https://hg.mozilla.org/mozilla-central/rev/259111ca1dd0
https://hg.mozilla.org/mozilla-central/rev/c4a032c9bf84
Description
•