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

Unified Diff: runtime/vm/isolate.cc

Issue 9924015: Use the ThreadPool for all isolates and native ports. Previously, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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/isolate.h ('k') | runtime/vm/message.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
===================================================================
--- runtime/vm/isolate.cc (revision 6698)
+++ runtime/vm/isolate.cc (working copy)
@@ -12,7 +12,7 @@
#include "vm/debugger.h"
#include "vm/debuginfo.h"
#include "vm/heap.h"
-#include "vm/message.h"
+#include "vm/message_handler.h"
#include "vm/object_store.h"
#include "vm/parser.h"
#include "vm/port.h"
@@ -39,6 +39,7 @@
const char* name() const;
void MessageNotify(Message::Priority priority);
+ bool HandleMessage(Message* message);
#if defined(DEBUG)
// Check that it is safe to access this handler.
@@ -75,6 +76,57 @@
}
+static RawInstance* DeserializeMessage(void* data) {
+ // Create a snapshot object using the buffer.
+ const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
+ ASSERT(snapshot->IsMessageSnapshot());
+
+ // Read object back from the snapshot.
+ SnapshotReader reader(snapshot, Isolate::Current());
+ Instance& instance = Instance::Handle();
+ instance ^= reader.ReadObject();
+ return instance.raw();
+}
+
+
+bool IsolateMessageHandler::HandleMessage(Message* message) {
+ StartIsolateScope start_scope(isolate_);
+ Zone zone(isolate_);
+ HandleScope handle_scope(isolate_);
+
+ const Instance& msg =
+ Instance::Handle(DeserializeMessage(message->data()));
+ if (message->IsOOB()) {
+ // 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.
+ Error& error = Error::Handle();
+ error ^= result.raw();
+ isolate_->object_store()->set_sticky_error(error);
+ return false;
+ }
+ ASSERT(result.IsNull());
+ } else {
+ const Object& result = Object::Handle(
+ DartLibraryCalls::HandleMessage(
+ message->dest_port(), message->reply_port(), msg));
+ delete message;
+ if (result.IsError()) {
+ Error& error = Error::Handle();
+ error ^= result.raw();
+ isolate_->object_store()->set_sticky_error(error);
+ return false;
+ }
+ ASSERT(result.IsNull());
+ }
+ return true;
+}
+
+
#if defined(DEBUG)
void IsolateMessageHandler::CheckAccess() {
ASSERT(isolate_ == Isolate::Current());
@@ -110,7 +162,9 @@
ast_node_id_(AstNode::kNoId),
mutex_(new Mutex()),
stack_limit_(0),
- saved_stack_limit_(0) {
+ saved_stack_limit_(0),
+ message_handler_(NULL),
+ spawn_data_(NULL) {
}
@@ -367,67 +421,6 @@
}
-static RawInstance* DeserializeMessage(void* data) {
- // Create a snapshot object using the buffer.
- const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
- ASSERT(snapshot->IsMessageSnapshot());
-
- // Read object back from the snapshot.
- SnapshotReader reader(snapshot, Isolate::Current());
- Instance& instance = Instance::Handle();
- instance ^= reader.ReadObject();
- return instance.raw();
-}
-
-
-
-RawError* Isolate::StandardRunLoop() {
- ASSERT(message_notify_callback() == NULL);
- ASSERT(message_handler() != NULL);
-
- while (message_handler()->HasLivePorts()) {
- ASSERT(this == Isolate::Current());
- Zone zone(this);
- HandleScope handle_scope(this);
-
- // TODO(turnidge): This code is duplicated elsewhere. Consolidate.
- Message* message = message_handler()->queue()->Dequeue(0);
- if (message != NULL) {
- const Instance& msg =
- Instance::Handle(DeserializeMessage(message->data()));
- if (message->priority() >= Message::kOOBPriority) {
- // 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.
- Error& error = Error::Handle();
- error ^= result.raw();
- return error.raw();
- }
- ASSERT(result.IsNull());
- } else {
- const Object& result = Object::Handle(
- DartLibraryCalls::HandleMessage(
- message->dest_port(), message->reply_port(), msg));
- delete message;
- if (result.IsError()) {
- Error& error = Error::Handle();
- error ^= result.raw();
- return error.raw();
- }
- ASSERT(result.IsNull());
- }
- }
- }
-
- // Indicates success.
- return Error::null();
-}
-
-
void Isolate::VisitObjectPointers(ObjectPointerVisitor* visitor,
bool visit_prologue_weak_handles,
bool validate_frames) {
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698