Skip to content
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

Closed
peter-ahe-google opened this issue May 14, 2013 · 10 comments
Closed

Use structured cloning algorithm more #10654

peter-ahe-google opened this issue May 14, 2013 · 10 comments
Labels
area-library closed-not-planned Closed as we don't intend to take action on the reported issue library-isolate library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@peter-ahe-google
Copy link
Contributor

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.

@peter-ahe-google
Copy link
Contributor Author

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.

@gbracha
Copy link
Contributor

gbracha commented May 14, 2013

I assume you are referring to invokeAsync and friends in dart:mirrors.

@peter-ahe-google
Copy link
Contributor Author

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.

@vsmenon
Copy link
Member

vsmenon commented May 14, 2013

(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.

@DartBot
Copy link

DartBot commented May 15, 2013

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.

@DartBot
Copy link

DartBot commented May 15, 2013

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.

@peter-ahe-google
Copy link
Contributor Author

I think Expando provides identity maps in Dart. Not sure if we have a fast Expando implementation, though.

@kevmoo
Copy link
Member

kevmoo commented Sep 2, 2013

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.

@lrhn
Copy link
Member

lrhn commented Nov 18, 2013

We generally don't want a way to create objects without using a constructor.
The ability to clone any object, without the participation of the object, is a problem in many ways.

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.
Not that I like marker interfaces, but it does show that the author of a class was aware that objects may be created out of thin air at some point.

@lrhn
Copy link
Member

lrhn commented Jul 9, 2014

Issue #19892 has been merged into this issue.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed triaged labels Feb 29, 2016
@a-siva a-siva added the closed-not-planned Closed as we don't intend to take action on the reported issue label Aug 5, 2022
@a-siva a-siva closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-library closed-not-planned Closed as we don't intend to take action on the reported issue library-isolate library-mirrors P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

7 participants