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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 9420038: Heartbeat implementation of dart:mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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 | « runtime/vm/code_generator.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « runtime/vm/code_generator.cc ('k') | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698