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

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

Issue 11642048: Revert "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: 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 (*callback)(Api::CastIsolate(isolate_)); 82 (*callback)(Api::CastIsolate(isolate_));
83 } 83 }
84 } 84 }
85 85
86 86
87 bool IsolateMessageHandler::HandleMessage(Message* message) { 87 bool IsolateMessageHandler::HandleMessage(Message* message) {
88 StartIsolateScope start_scope(isolate_); 88 StartIsolateScope start_scope(isolate_);
89 StackZone zone(isolate_); 89 StackZone zone(isolate_);
90 HandleScope handle_scope(isolate_); 90 HandleScope handle_scope(isolate_);
91 91
92 // If the message is in band we lookup the receive port to dispatch to. If
93 // the receive port is closed, we drop the message without deserializing it.
94 Object& receive_port = Object::Handle();
95 if (!message->IsOOB()) {
96 receive_port = DartLibraryCalls::LookupReceivePort(message->dest_port());
97 if (receive_port.IsError()) {
98 return ProcessUnhandledException(Instance::Handle(),
99 Error::Cast(receive_port));
100 }
101 if (receive_port.IsNull()) {
102 delete message;
103 return true;
104 }
105 }
106
107 // Parse the message. 92 // Parse the message.
108 SnapshotReader reader(message->data(), message->len(), 93 SnapshotReader reader(message->data(), message->len(),
109 Snapshot::kMessage, Isolate::Current()); 94 Snapshot::kMessage, Isolate::Current());
110 const Object& msg_obj = Object::Handle(reader.ReadObject()); 95 const Object& msg_obj = Object::Handle(reader.ReadObject());
111 if (msg_obj.IsError()) { 96 if (msg_obj.IsError()) {
112 // An error occurred while reading the message. 97 // An error occurred while reading the message.
113 return ProcessUnhandledException(Instance::Handle(), Error::Cast(msg_obj)); 98 return ProcessUnhandledException(Instance::Handle(), Error::Cast(msg_obj));
114 } 99 }
115 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) { 100 if (!msg_obj.IsNull() && !msg_obj.IsInstance()) {
116 // TODO(turnidge): We need to decide what an isolate does with 101 // TODO(turnidge): We need to decide what an isolate does with
117 // malformed messages. If they (eventually) come from a remote 102 // malformed messages. If they (eventually) come from a remote
118 // machine, then it might make sense to drop the message entirely. 103 // machine, then it might make sense to drop the message entirely.
119 // In the case that the message originated locally, which is 104 // In the case that the message originated locally, which is
120 // always true for now, then this should never occur. 105 // always true for now, then this should never occur.
121 UNREACHABLE(); 106 UNREACHABLE();
122 } 107 }
123 108
124 Instance& msg = Instance::Handle(); 109 Instance& msg = Instance::Handle();
125 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. 110 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null.
126 111
127 bool success = true; 112 bool success = true;
128 if (message->IsOOB()) { 113 if (message->IsOOB()) {
129 // For now the only OOB messages are Mirrors messages. 114 // For now the only OOB messages are Mirrors messages.
130 HandleMirrorsMessage(isolate_, message->reply_port(), msg); 115 HandleMirrorsMessage(isolate_, message->reply_port(), msg);
131 } else { 116 } else {
132 const Object& result = Object::Handle( 117 const Object& result = Object::Handle(
133 DartLibraryCalls::HandleMessage( 118 DartLibraryCalls::HandleMessage(
134 receive_port, message->reply_port(), msg)); 119 message->dest_port(), message->reply_port(), msg));
135 if (result.IsError()) { 120 if (result.IsError()) {
136 success = ProcessUnhandledException(msg, Error::Cast(result)); 121 success = ProcessUnhandledException(msg, Error::Cast(result));
137 } else { 122 } else {
138 ASSERT(result.IsNull()); 123 ASSERT(result.IsNull());
139 } 124 }
140 } 125 }
141 delete message; 126 delete message;
142 return success; 127 return success;
143 } 128 }
144 129
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 601
617 602
618 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor, 603 void Isolate::VisitWeakPersistentHandles(HandleVisitor* visitor,
619 bool visit_prologue_weak_handles) { 604 bool visit_prologue_weak_handles) {
620 if (api_state() != NULL) { 605 if (api_state() != NULL) {
621 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles); 606 api_state()->VisitWeakHandles(visitor, visit_prologue_weak_handles);
622 } 607 }
623 } 608 }
624 609
625 } // namespace dart 610 } // 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