Index: lib/html/dartium/html_dartium.dart |
diff --git a/lib/html/dartium/html_dartium.dart b/lib/html/dartium/html_dartium.dart |
index 484532a4be932d179320e3db81b95f6d1ed03d0d..7693669ddcedd2fe0359e5b07120ada09010d1b3 100644 |
--- a/lib/html/dartium/html_dartium.dart |
+++ b/lib/html/dartium/html_dartium.dart |
@@ -40842,6 +40842,8 @@ class _JsSerializer extends _Serializer { |
} |
visitFunction(Function func) { |
+ var serialized = _deserializedFunctionTable.find(func); |
+ if (serialized != null) return serialized; |
return [ 'funcref', |
_functionRegistry._add(func), |
visitSendPortSync(_functionRegistry._sendPort), null ]; |
@@ -40938,6 +40940,33 @@ _deserialize(var message) { |
return new _JsDeserializer().deserialize(message); |
} |
+// TODO(vsm): Use a hashmap once functions are hashable. |
+class _DeserializedFunctionTable { |
+ List data; |
+ _DeserializedFunctionTable() { |
+ data = []; |
+ } |
+ |
+ find(Function f) { |
+ for (var item in data) { |
+ if (f == item[0]) return item[1]; |
+ } |
+ return null; |
+ } |
+ |
+ add(Function f, x) { |
+ data.add([f, x]); |
+ } |
+} |
+ |
+_DeserializedFunctionTable __deserializedFunctionTable = null; |
+get _deserializedFunctionTable { |
+ if (__deserializedFunctionTable == null) { |
+ __deserializedFunctionTable = new _DeserializedFunctionTable(); |
+ } |
+ return __deserializedFunctionTable; |
+} |
+ |
class _JsDeserializer extends _Deserializer { |
static final _UNSPECIFIED = const Object(); |
@@ -40970,8 +40999,11 @@ class _JsDeserializer extends _Deserializer { |
deserializeFunction(List x) { |
var id = x[1]; |
SendPortSync port = deserializeSendPort(x[2]); |
+ if (port is _LocalSendPortSync) { |
+ return _functionRegistry._get(id); |
+ } |
// TODO: Support varargs when there is support in the language. |
- return ([arg0 = _UNSPECIFIED, arg1 = _UNSPECIFIED, |
+ var f = ([arg0 = _UNSPECIFIED, arg1 = _UNSPECIFIED, |
arg2 = _UNSPECIFIED, arg3 = _UNSPECIFIED]) { |
var args = [arg0, arg1, arg2, arg3]; |
var last = args.indexOf(_UNSPECIFIED); |
@@ -40979,6 +41011,8 @@ class _JsDeserializer extends _Deserializer { |
var message = [id, args]; |
return port.callSync(message); |
}; |
+ _deserializedFunctionTable.add(f, x); |
+ return f; |
} |
deserializeProxy(x) { |