Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: client/dart.js

Issue 10690142: Move function serialization to sync ports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/html/src/Isolates.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/dart.js
diff --git a/client/dart.js b/client/dart.js
index 30b0883c644165b04529082cb0fd1f083f92b928..d1d9122488c6e01dd35b0333268bce82cb0979a3 100644
--- a/client/dart.js
+++ b/client/dart.js
@@ -89,6 +89,7 @@ function ReceivePortSync() {
case 'map': return deserializeMap(x);
case 'sendport': return deserializeSendPort(x);
case 'list': return deserializeList(x);
+ case 'funcref': return deserializeFunction(x);
vsm 2012/08/10 00:18:50 How about a more descriptive name? E.g., 'functio
Anton Muhin 2012/08/14 16:42:38 I can definitely do it, but I wished to minimize t
vsm 2012/08/15 15:35:38 It's fine for now. On 2012/08/14 16:42:38, Anton
default: throw 'unimplemented';
}
}
@@ -131,6 +132,14 @@ function ReceivePortSync() {
return result;
}
+ function deserializeFunction(x) {
+ var ref = x[1];
+ var sendPort = deserializeSendPort(x[2]);
+ // Number of arguments is not used as as of now
vsm 2012/08/10 00:18:50 "as as" -> as
Anton Muhin 2012/08/14 16:42:38 Done.
+ // we cannot find it out for Dart function in pure Dart.
+ return _makeFunctionFromRef(ref, sendPort);
+ }
+
window.registerPort = function(name, port) {
var stringified = JSON.stringify(serialize(port));
window.localStorage['dart-port:' + name] = stringified;
@@ -214,4 +223,12 @@ function ReceivePortSync() {
window.removeEventListener(source, listener, false);
return deserialize(result);
}
+
+ // Leaking implementation.
+ // TODO: provide proper, backend-specific implementation.
+ function _makeFunctionFromRef(ref, sendPort) {
+ return function() {
+ return sendPort.callSync([ref, Array.prototype.slice.call(arguments)]);
vsm 2012/08/10 00:18:50 Don't the arguments and return value need to be se
Anton Muhin 2012/08/14 16:42:38 I don't remember all the details, but won't callSy
vsm 2012/08/15 15:35:38 Yes, I think you're correct. On 2012/08/14 16:42:
+ }
+ }
})();
« no previous file with comments | « no previous file | lib/html/src/Isolates.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698