Expose copy-on-write wrapper




5 years ago
5 years ago


(Reporter: Yoric, Unassigned)


Firefox Tracking Flags

(Not tracked)


Many APIs would benefit from a copy-on-write wrapper for large JS objects. While this can be manually encoded with a Proxy, I am yet to see a single Proxy-based implementation that works as expected. I believe that it would be a good idea to expose an API that would automatically build such a wrapper.

Bonus points if it is possible if the API offers a near-constant-time |diff| (or "show me the root of changes") feature.

The main use case at the moment is Session Restore: to avoid unwanted side-effects, SessionRestore exposes data by stringifying/reparsing (often huge) JS objects before passing them to subsystems or API clients. I seem to remember that the add-on manager has similar issues.
I am also interested in adding copy-on-write wrapper to the engine.  Still I have no idea of the extra complexity this implies.  The goal in which I am interested in is to provide an easy way to clone the constants from any functions, such as the parser produce one immutable object and all remaining objects are copy-on-write of this immutable object.
You need to log in before you can comment on or make changes to this bug.