| Index: runtime/vm/dart_api_impl.cc
|
| ===================================================================
|
| --- runtime/vm/dart_api_impl.cc (revision 5107)
|
| +++ runtime/vm/dart_api_impl.cc (working copy)
|
| @@ -519,17 +519,20 @@
|
| char** error) {
|
| Isolate* isolate = Dart::CreateIsolate(name_prefix);
|
| assert(isolate != NULL);
|
| - DARTSCOPE_NOCHECKS(isolate);
|
| - const Error& error_obj =
|
| - Error::Handle(Dart::InitializeIsolate(snapshot, callback_data));
|
| - if (error_obj.IsNull()) {
|
| - START_TIMER(time_total_runtime);
|
| - return reinterpret_cast<Dart_Isolate>(isolate);
|
| - } else {
|
| - *error = strdup(error_obj.ToErrorCString());
|
| - Dart::ShutdownIsolate();
|
| - return reinterpret_cast<Dart_Isolate>(NULL);
|
| + {
|
| + DARTSCOPE_NOCHECKS(isolate);
|
| + const Error& error_obj =
|
| + Error::Handle(Dart::InitializeIsolate(snapshot, callback_data));
|
| + if (error_obj.IsNull()) {
|
| + START_TIMER(time_total_runtime);
|
| + return reinterpret_cast<Dart_Isolate>(isolate);
|
| + } else {
|
| + *error = strdup(error_obj.ToErrorCString());
|
| + }
|
| + // We need to leave the DARTSCOPE before shutting down the isolate.
|
| }
|
| + Dart::ShutdownIsolate();
|
| + return reinterpret_cast<Dart_Isolate>(NULL);
|
| }
|
|
|
|
|
| @@ -677,27 +680,35 @@
|
| Message::Priority priority = Message::kNormalPriority;
|
| do {
|
| DARTSCOPE(isolate);
|
| + // TODO(turnidge): This code is duplicated elsewhere. Consolidate.
|
| message = isolate->message_handler()->queue()->DequeueNoWait();
|
| if (message == NULL) {
|
| break;
|
| }
|
| + const Instance& msg =
|
| + Instance::Handle(DeserializeMessage(message->data()));
|
| priority = message->priority();
|
| if (priority == Message::kOOBPriority) {
|
| - // TODO(turnidge): Out of band messages will not go through the
|
| - // regular message handler. Instead they will be dispatched to
|
| - // special vm code. Implement.
|
| - UNIMPLEMENTED();
|
| + // For now the only OOB messages are Mirrors messages.
|
| + const Object& result = Object::Handle(
|
| + DartLibraryCalls::HandleMirrorsMessage(
|
| + message->dest_port(), message->reply_port(), msg));
|
| + delete message;
|
| + if (result.IsError()) {
|
| + // TODO(turnidge): Propagating the error is probably wrong here.
|
| + return Api::NewLocalHandle(result);
|
| + }
|
| + ASSERT(result.IsNull());
|
| + } else {
|
| + const Object& result = Object::Handle(
|
| + DartLibraryCalls::HandleMessage(
|
| + message->dest_port(), message->reply_port(), msg));
|
| + delete message;
|
| + if (result.IsError()) {
|
| + return Api::NewLocalHandle(result);
|
| + }
|
| + ASSERT(result.IsNull());
|
| }
|
| - const Instance& msg =
|
| - Instance::Handle(DeserializeMessage(message->data()));
|
| - const Object& result = Object::Handle(
|
| - DartLibraryCalls::HandleMessage(
|
| - message->dest_port(), message->reply_port(), msg));
|
| - delete message;
|
| - if (result.IsError()) {
|
| - return Api::NewLocalHandle(result);
|
| - }
|
| - ASSERT(result.IsNull());
|
| } while (priority >= Message::kOOBPriority);
|
| return Api::Success();
|
| }
|
| @@ -790,26 +801,7 @@
|
| DART_EXPORT Dart_Handle Dart_NewSendPort(Dart_Port port_id) {
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| - Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
|
| - ASSERT(!isolate_lib.IsNull());
|
| - const String& class_name =
|
| - String::Handle(isolate_lib.PrivateName("_SendPortImpl"));
|
| - const String& function_name = String::Handle(String::NewSymbol("_create"));
|
| - const int kNumArguments = 1;
|
| - const Array& kNoArgumentNames = Array::Handle();
|
| - // TODO(turnidge): Consider adding a helper function to make
|
| - // function resolution by class name and function name more concise.
|
| - const Function& function = Function::Handle(
|
| - Resolver::ResolveStatic(isolate_lib,
|
| - class_name,
|
| - function_name,
|
| - kNumArguments,
|
| - kNoArgumentNames,
|
| - Resolver::kIsQualified));
|
| - GrowableArray<const Object*> arguments(kNumArguments);
|
| - arguments.Add(&Integer::Handle(Integer::New(port_id)));
|
| - const Object& result = Object::Handle(
|
| - DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
|
| + const Object& result = Object::Handle(DartLibraryCalls::NewSendPort(port_id));
|
| return Api::NewLocalHandle(result);
|
| }
|
|
|
|
|