[meta] Parse JS without allocating on the GC
Categories
(Core :: JavaScript Engine, enhancement, P2)
Tracking
()
People
(Reporter: tcampbell, Unassigned)
References
(Blocks 1 open bug)
Details
(Keywords: meta)
Off-thread parsing currently results in complexities around GC interactions.
Currently we do the following steps for off-thread parsing:
- Create a new gc::Zone, Compartment, and Realm/Global
- Use AutoKeepAutos to prevent main-thread from starting any GC in AtomsZone
- Do the parse
- Create GC things in our Realm as we go
- Inner-functions
- RegExp
- Object literals (including their Shape)
- Scopes
- Atomize property-names and string-literals as we go,
taking global locks in the AtomZone as needed.
- Create GC things in our Realm as we go
- Perform 'mergeRealms' step to munge the temporary Zone into the target
zone, performing minor updates on gc-things as we transfer ownership.
There is also a lot of hard to follow code around these GC-things as the are incrementally constructed across various parts of parser and frequently used in partially initialized states.
We are starting to see more examples of real-world perf impact by the off-thread parse getting conflicting with main-thread such as Bug 1543776 and atom lock contention that sometimes shows up.
In this bug I'd like for us to look at what the minimal requirements would be to fix in our existing parser. This would involving atomizing private to the parser (in the off-thread case), and replacing the ObjectBox design.
Reporter | ||
Comment 1•5 years ago
|
||
Matthew has been working away on the FunctionBox aspect of this which is probably the most challenging. Patches are being reviewed and landed to decouple Parser from JSFunction/LazyScript. The following topics still need more planning and work:
- Decouple BytecodeEmitter from JSFunction/JSScript
- Decouple Parser from JSAtom
- Decouple ObjectBox, etc
- Create the GC-things directly in target realm (instead of using mergeRealms)
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 2•4 years ago
|
||
The machinery is in place within the Parser so I think we can close this bug. Other bugs will track making use of these changes.
Description
•