- From: Allen Wirfs-Brock <allen@wirfs-brock.com>
- Date: Fri, 15 Jul 2011 08:22:59 -0700
- To: Jason Orendorff <jason.orendorff@gmail.com>
- Cc: "Mark S. Miller" <erights@google.com>, public-script-coord@w3.org, es-discuss <es-discuss@mozilla.org>
- Message-Id: <75FB8EAF-A05C-4BA4-B0F0-DDC412087267@wirfs-brock.com>
On Jul 14, 2011, at 9:30 PM, Jason Orendorff wrote: > On Thu, Jul 14, 2011 at 2:46 PM, Mark S. Miller <erights@google.com> wrote: >> > > Allen Wirfs-Brock write: >> Something that isn't clear to me is which primordials are used >> to set the [[Prototype]] of the generated objects. It isn't covered in >> the internal structured cloning algorithm. Perhaps it is, where >> structured clone is invoked. > > Consider that in IndexedDB, the "copy" is made at the time the object > is put into the database, and then the copy is used in perhaps a > completely different browser instance. And in the case of postMessage, > the copy is in a totally separate heap that lives on a separate > thread. Perhaps this makes it clearer what structured cloning really > is. > > It's serialization. > > Or, it's a spec fiction to explain and codify the Web-visible effects > of serialization and deserialization without specifying a > serialization format. As such, it seem like this may be a poor specification approach. Translation to/from a static serialization format would make clear that there is no sharing of any active object mechanisms such as prototype objects. This is not clear in the current specification. If the specification did use an explicit serialization format in this manner then certainly a valid optimization in appropriate situations would be for an implementation to eliminate the actual encoding/decoding of the serialized representation and to directly generate the target objects. However, by specifying it terms of such a format you would precisely define the required transformation. If you didn't want to be bothered with inventing a serialization format solely for specification purposes you could accomplish the same thing by specify structured clone as if it was a transformation to/from JSON format > > We implement a pair of functions, JS_WriteStructuredClone and > JS_ReadStructuredClone. The latter requires the caller to specify the > global object in which the clone is to be made. That global's > primordial prototypes are used. The actual serialization format is not > exposed to the web. What happens when cloning an object that is an "Object object" whose [[Prototype]] is not Object.prototype? Allen
Received on Friday, 15 July 2011 15:23:35 UTC