Index: runtime/lib/isolate.cc |
=================================================================== |
--- runtime/lib/isolate.cc (revision 37860) |
+++ runtime/lib/isolate.cc (working copy) |
@@ -166,7 +166,9 @@ |
} |
-static RawObject* Spawn(NativeArguments* arguments, IsolateSpawnState* state) { |
+static RawArray* Spawn(Isolate* isolate, |
siva
2014/07/01 21:42:56
This isolate parameter is not being used anywhere
Ivan Posva
2014/07/03 12:51:16
- Removed the unnecessary parameter, it was used i
|
+ NativeArguments* arguments, |
+ IsolateSpawnState* state) { |
// Create a new isolate. |
char* error = NULL; |
if (!CreateIsolate(state, &error)) { |
@@ -176,9 +178,16 @@ |
ThrowIsolateSpawnException(msg); |
} |
+ const Array& result = Array::Handle(Array::New(3)); |
// Try to create a SendPort for the new isolate. |
const SendPort& port = SendPort::Handle( |
SendPort::New(state->isolate()->main_port())); |
+ result.SetAt(0, port); |
+ Capability& capability = Capability::Handle(); |
+ capability = Capability::New(state->isolate()->pause_capability()); |
+ result.SetAt(1, capability); // pauseCapability |
+ capability = Capability::New(state->isolate()->terminate_capability()); |
+ result.SetAt(2, capability); // terminateCapability |
// Start the new isolate if it is already marked as runnable. |
MutexLocker ml(state->isolate()->mutex()); |
@@ -187,7 +196,7 @@ |
state->isolate()->Run(); |
} |
- return port.raw(); |
+ return result.raw(); |
} |
@@ -202,7 +211,7 @@ |
ctx = Closure::context(closure); |
ASSERT(ctx.num_variables() == 0); |
#endif |
- return Spawn(arguments, new IsolateSpawnState(func)); |
+ return Spawn(isolate, arguments, new IsolateSpawnState(func)); |
} |
} |
const String& msg = String::Handle(String::New( |
@@ -226,10 +235,28 @@ |
ThrowIsolateSpawnException(msg); |
} |
- return Spawn(arguments, new IsolateSpawnState(canonical_uri)); |
+ return Spawn(isolate, arguments, new IsolateSpawnState(canonical_uri)); |
} |
+DEFINE_NATIVE_ENTRY(Isolate_sendOOB, 2) { |
+ GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
+ GET_NON_NULL_NATIVE_ARGUMENT(Array, msg, arguments->NativeArgAt(1)); |
+ |
+ // Make sure to route this request to the isolate library OOB mesage handler. |
+ msg.SetAt(0, Smi::Handle(Smi::New(Message::kIsolateLibOOBMsg))); |
+ |
+ uint8_t* data = NULL; |
+ MessageWriter writer(&data, &allocator); |
+ writer.WriteMessage(msg); |
+ |
+ PortMap::PostMessage(new Message(port.Id(), |
+ data, writer.BytesWritten(), |
+ Message::kOOBPriority)); |
+ return Object::null(); |
+} |
+ |
+ |
DEFINE_NATIVE_ENTRY(Isolate_mainPort, 0) { |
// The control port is being accessed as a regular port from Dart code. This |
// is most likely due to the _startIsolate code in dart:isolate. Account for |