New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use structured cloning algorithm more #10654
Comments
Vijay mentions that we already have a Dart implementation of this: https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/sdk/lib/html/html_common/conversions.dart We could refactor this so it can be shared across other parts of the platform. |
I assume you are referring to invokeAsync and friends in dart:mirrors. |
Yes, Gilad: I mean the async versions. For people not familiar with dart:mirrors: the synchronous versions of invoke and friends expect regular objects, not InstanceMirrors. This is because the synchronous API is assumed to be used to communicate with the isolate itself, so there is no need for proxies. |
(fixing my earlier comment) Adding Stephen and Anton had implemented dart2js and dartium versions of this in html. I believe the Dartium version is tightly coupled to V8 right now. |
This comment was originally written by antonm@google.com Structured cloning algorithm is somewhat DOM specific, but that'd be great to be as close to it as possible. I would be especially happy to have transferable semantics (http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#transferable) in some of the case, e.g. typed data---there are enough of use cases when one isolate builds a big chunk of data and wants to hand it off to another isolate. |
This comment was originally written by antonm@google.com And forgotten: for efficient implementation identity maps would be great---afaik typical implementations emulate this by linear scan. Also JSON uses oretty close object graph traversal to find loops if memory serves. |
I think Expando provides identity maps in Dart. Not sure if we have a fast Expando implementation, though. |
When we talk about Dart "growing up" and targeting real world apps, this is a big one. I'm a huge fan of share-nothing for stability (and sanity) but that means I want (need?) the ability to pass large, non-trivial objects (and collections of objects, etc) around for background processing. |
We generally don't want a way to create objects without using a constructor. In Java, at least you have to mark the object Serializable for serialization and deserialization (which together gives a way to clone an object) to work. |
Issue #19892 has been merged into this issue. |
This is a meta-bug that covers aligning behavior across various different libraries (at least js-interop, dart:isolate, and dart:mirrors).
postMessage in dart:html supports a form of serialization of that resembles what's specified in HTML5 as "structured cloning" (http://www.w3.org/html/wg/drafts/html/master/infrastructure.html#safe-passing-of-structured-data)
When the structured cloning algorithm talks about an input of type "Object", read "Dart Map".
It seems like we should be able to use this algorithm in more places, for example:
* Arguments calls in js-interop.
* Arguments to invoke, setField, etc. in dart:mirrors. No need to wrap objects that can be serialized with the structured cloning algorithm in an InstanceMirror.
* Isolate communication.
The text was updated successfully, but these errors were encountered: