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

Unified Diff: sdk/lib/_internal/compiler/js_lib/isolate_helper.dart

Issue 584843003: Allow sending static/top-level functions through ports and as isolate (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Update status files. Created 6 years, 3 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 | tests/isolate/function_send_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart b/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
index dabbb2e43645c48ba8ead3ff80b8e50b7de3b8db..90620facc95632643c4a0b6486d6a212917866ff 100644
--- a/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/isolate_helper.dart
@@ -1368,6 +1368,15 @@ class _JsSerializer extends _Serializer {
visitWorkerSendPort(_WorkerSendPort port) {
return ['sendport', port._workerId, port._isolateId, port._receivePortId];
}
+
+ visitFunction(Function topLevelFunction) {
+ final name = IsolateNatives._getJSFunctionName(topLevelFunction);
+ if (name == null) {
+ throw new UnsupportedError(
+ "only top-level functions can be sent.");
+ }
+ return ['function', name];
+ }
}
@@ -1396,6 +1405,16 @@ class _JsCopier extends _Copier {
return new _WorkerSendPort(
port._workerId, port._isolateId, port._receivePortId);
}
+
+ Function visitFunction(Function topLevelFunction) {
+ final name = IsolateNatives._getJSFunctionName(topLevelFunction);
+ if (name == null) {
+ throw new UnsupportedError(
+ "only top-level functions can be sent.");
+ }
+ // Is this getting it from the correct isolate? Is it just topLevelFunction?
+ return IsolateNatives._getJSFunctionFromName(name);
+ }
}
class _JsDeserializer extends _Deserializer {
@@ -1420,6 +1439,10 @@ class _JsDeserializer extends _Deserializer {
Capability deserializeCapability(List list) {
return new CapabilityImpl._internal(list[1]);
}
+
+ Function deserializeFunction(List list) {
+ return IsolateNatives._getJSFunctionFromName(list[1]);
+ }
}
class _JsVisitedMap implements _MessageTraverserVisitedMap {
@@ -1519,6 +1542,7 @@ abstract class _MessageTraverser {
if (x is Map) return visitMap(x);
if (x is SendPort) return visitSendPort(x);
if (x is Capability) return visitCapability(x);
+ if (x is Function) return visitFunction(x);
// Overridable fallback.
return visitObject(x);
@@ -1529,6 +1553,7 @@ abstract class _MessageTraverser {
visitMap(Map x);
visitSendPort(SendPort x);
visitCapability(Capability x);
+ visitFunction(Function f);
visitObject(Object x) {
// TODO(floitsch): make this a real exception. (which one)?
@@ -1574,6 +1599,8 @@ class _Copier extends _MessageTraverser {
return copy;
}
+ visitFunction(Function f) => throw new UnimplementedError();
+
visitSendPort(SendPort x) => throw new UnimplementedError();
visitCapability(Capability x) => throw new UnimplementedError();
@@ -1622,6 +1649,8 @@ class _Serializer extends _MessageTraverser {
visitSendPort(SendPort x) => throw new UnimplementedError();
visitCapability(Capability x) => throw new UnimplementedError();
+
+ visitFunction(Function f) => throw new UnimplementedError();
}
/** Deserializes arrays created with [_Serializer]. */
@@ -1650,6 +1679,7 @@ abstract class _Deserializer {
case 'map': return _deserializeMap(x);
case 'sendport': return deserializeSendPort(x);
case 'capability': return deserializeCapability(x);
+ case 'function' : return deserializeFunction(x);
default: return deserializeObject(x);
}
}
@@ -1689,6 +1719,8 @@ abstract class _Deserializer {
return result;
}
+ deserializeFunction(List x);
+
deserializeSendPort(List x);
deserializeCapability(List x);
« no previous file with comments | « no previous file | tests/isolate/function_send_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698