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

Side by Side Diff: runtime/vm/isolate.cc

Issue 11440035: Optimize the message queue for many active ports with few messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Lookup ReceivePort in Dart code Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/isolate.h" 5 #include "vm/isolate.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "lib/mirrors.h" 9 #include "lib/mirrors.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 (*callback)(Api::CastIsolate(isolate_)); 80 (*callback)(Api::CastIsolate(isolate_));
81 } 81 }
82 } 82 }
83 83
84 84
85 bool IsolateMessageHandler::HandleMessage(Message* message) { 85 bool IsolateMessageHandler::HandleMessage(Message* message) {
86 StartIsolateScope start_scope(isolate_); 86 StartIsolateScope start_scope(isolate_);
87 StackZone zone(isolate_); 87 StackZone zone(isolate_);
88 HandleScope handle_scope(isolate_); 88 HandleScope handle_scope(isolate_);
89 89
90 // If the message is in band we lookup the receive port to dispatch to. If
91 // the receive port is closed, we drop the message without deserializing it.
92 Object& receiver = Object::Handle();
Ivan Posva 2012/12/19 07:09:44 I find the name choice of receiver a bit confusing
Mads Ager (google) 2012/12/19 15:47:57 Done.
93 if (!message->IsOOB()) {
94 receiver = DartLibraryCalls::LookupReceivePort(message->dest_port());
95 if (receiver.IsError()) {
96 return ProcessUnhandledException(receiver);
97 }
98 if (receiver.IsNull()) {
99 delete message;
100 return true;
101 }
102 }
103
90 // Parse the message. 104 // Parse the message.
91 SnapshotReader reader(message->data(), message->len(), 105 SnapshotReader reader(message->data(), message->len(),
92 Snapshot::kMessage, Isolate::Current()); 106 Snapshot::kMessage, Isolate::Current());
93 const Object& msg_obj = Object::Handle(reader.ReadObject()); 107 const Object& msg_obj = Object::Handle(reader.ReadObject());
94 if (msg_obj.IsError()) { 108 if (msg_obj.IsError()) {
95 // An error occurred while reading the message. 109 // An error occurred while reading the message.
96 return ProcessUnhandledException(msg_obj); 110 return ProcessUnhandledException(msg_obj);
97 } 111 }
98 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { 112 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) {
99 // TODO(turnidge): We need to decide what an isolate does with 113 // TODO(turnidge): We need to decide what an isolate does with
100 // malformed messages. If they (eventually) come from a remote 114 // malformed messages. If they (eventually) come from a remote
101 // machine, then it might make sense to drop the message entirely. 115 // machine, then it might make sense to drop the message entirely.
102 // In the case that the message originated locally, which is 116 // In the case that the message originated locally, which is
103 // always true for now, then this should never occur. 117 // always true for now, then this should never occur.
104 UNREACHABLE(); 118 UNREACHABLE();
105 } 119 }
106 120
107 Instance& msg = Instance::Handle(); 121 Instance& msg = Instance::Handle();
108 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. 122 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null.
109 123
110 if (message->IsOOB()) { 124 if (message->IsOOB()) {
111 // For now the only OOB messages are Mirrors messages. 125 // For now the only OOB messages are Mirrors messages.
112 HandleMirrorsMessage(isolate_, message->reply_port(), msg); 126 HandleMirrorsMessage(isolate_, message->reply_port(), msg);
113 delete message; 127 delete message;
114 } else { 128 } else {
115 const Object& result = Object::Handle( 129 const Object& result = Object::Handle(
116 DartLibraryCalls::HandleMessage( 130 DartLibraryCalls::HandleMessage(receiver, message->reply_port(), msg));
117 message->dest_port(), message->reply_port(), msg));
118 delete message; 131 delete message;
119 if (result.IsError()) { 132 if (result.IsError()) {
120 return ProcessUnhandledException(result); 133 return ProcessUnhandledException(result);
121 } 134 }
122 ASSERT(result.IsNull()); 135 ASSERT(result.IsNull());
123 } 136 }
124 return true; 137 return true;
125 } 138 }
126 139
127 140
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 532
520 533
521 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, 534 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor,
522 bool visit_prologue_weak_handles) { 535 bool visit_prologue_weak_handles) {
523 if (api_state() != NULL) { 536 if (api_state() != NULL) {
524 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); 537 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles);
525 } 538 }
526 } 539 }
527 540
528 } // namespace dart 541 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.cc ('k') | runtime/vm/message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698