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

Unified Diff: runtime/lib/isolate.cc

Issue 8297004: Allow embedders to provide custom message delivery for an isolate. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 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/include/dart_api.h ('k') | runtime/vm/assert.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate.cc
===================================================================
--- runtime/lib/isolate.cc (revision 513)
+++ runtime/lib/isolate.cc (working copy)
@@ -37,20 +37,6 @@
};
-static RawInstance* DeserializeMessage(void* data) {
- // Create a snapshot object using the buffer.
- const Snapshot* snapshot = Snapshot::SetupFromBuffer(data);
- ASSERT(snapshot->IsPartialSnapshot());
-
- // Read object back from the snapshot.
- Isolate* isolate= Isolate::Current();
- SnapshotReader reader(snapshot, isolate->heap(), isolate->object_store());
- Instance& instance = Instance::Handle();
- instance ^= reader.ReadObject();
- return instance.raw();
-}
-
-
static uint8_t* allocator(uint8_t* ptr, intptr_t old_size, intptr_t new_size) {
void* new_ptr = realloc(reinterpret_cast<void*>(ptr), new_size);
return reinterpret_cast<uint8_t*>(new_ptr);
@@ -144,36 +130,6 @@
}
-void PortMessage::Handle() {
- const Instance& msg = Instance::Handle(DeserializeMessage(data()));
- const String& class_name =
- String::Handle(String::NewSymbol("ReceivePortImpl"));
- const String& function_name =
- String::Handle(String::NewSymbol("handleMessage_"));
- const int kNumArguments = 3;
- const Array& kNoArgumentNames = Array::Handle();
- const Function& function = Function::Handle(
- Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
- class_name,
- function_name,
- kNumArguments,
- kNoArgumentNames,
- Resolver::kIsQualified));
- GrowableArray<const Object*> arguments(kNumArguments);
- arguments.Add(&Integer::Handle(Integer::New(dest_id())));
- arguments.Add(&Integer::Handle(Integer::New(reply_id())));
- arguments.Add(&msg);
- const Object& result = Object::Handle(
- DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
- if (result.IsUnhandledException()) {
- UnhandledException& uhe = UnhandledException::Handle();
- uhe ^= result.raw();
- ProcessUnhandledException(uhe);
- }
- ASSERT(result.IsNull());
-}
-
-
static void RunIsolate(uword parameter) {
IsolateStartData* data = reinterpret_cast<IsolateStartData*>(parameter);
Isolate* isolate = data->isolate_;
@@ -246,16 +202,8 @@
}
ASSERT(result.IsNull());
free(class_name);
+ isolate->StandardRunLoop();
- // Keep listening until there are no active receive ports.
- while (isolate->active_ports() > 0) {
- Zone zone;
- HandleScope handle_scope;
-
- PortMessage* message = PortMap::ReceiveMessage(0);
- message->Handle();
- delete message;
- }
} else {
Zone zone;
HandleScope handle_scope;
@@ -389,8 +337,8 @@
// TODO(iposva): Allow for arbitrary messages to be sent.
void* data = SerializeObject(Instance::CheckedHandle(arguments->At(2)));
- PortMessage* message = new PortMessage(send_id, reply_id, data);
- PortMap::PostMessage(message);
+ // TODO(turnidge): Throw an exception when the return value is false?
+ PortMap::PostMessage(send_id, reply_id, data);
}
} // namespace dart
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/assert.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698