OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/message_handler.h" | 5 #include "vm/message_handler.h" |
6 #include "vm/dart.h" | 6 #include "vm/dart.h" |
7 | 7 |
8 namespace dart { | 8 namespace dart { |
9 | 9 |
10 DECLARE_FLAG(bool, trace_isolates); | 10 DECLARE_FLAG(bool, trace_isolates); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void MessageHandler::PostMessage(Message* message) { | 88 void MessageHandler::PostMessage(Message* message) { |
89 MonitorLocker ml(&monitor_); | 89 MonitorLocker ml(&monitor_); |
90 if (FLAG_trace_isolates) { | 90 if (FLAG_trace_isolates) { |
91 const char* source_name = "<native code>"; | 91 const char* source_name = "<native code>"; |
92 Isolate* source_isolate = Isolate::Current(); | 92 Isolate* source_isolate = Isolate::Current(); |
93 if (source_isolate) { | 93 if (source_isolate) { |
94 source_name = source_isolate->name(); | 94 source_name = source_isolate->name(); |
95 } | 95 } |
96 OS::Print("[>] Posting message:\n" | 96 OS::Print("[>] Posting message:\n" |
97 "\tsource: %s\n" | 97 "\tsource: %s\n" |
98 "\treply_port: %lld\n" | 98 "\treply_port: %"Pd64"\n" |
99 "\tdest: %s\n" | 99 "\tdest: %s\n" |
100 "\tdest_port: %lld\n", | 100 "\tdest_port: %"Pd64"\n", |
101 source_name, message->reply_port(), name(), message->dest_port()); | 101 source_name, message->reply_port(), name(), message->dest_port()); |
102 } | 102 } |
103 | 103 |
104 Message::Priority saved_priority = message->priority(); | 104 Message::Priority saved_priority = message->priority(); |
105 if (message->IsOOB()) { | 105 if (message->IsOOB()) { |
106 oob_queue_->Enqueue(message); | 106 oob_queue_->Enqueue(message); |
107 } else { | 107 } else { |
108 queue_->Enqueue(message); | 108 queue_->Enqueue(message); |
109 } | 109 } |
110 message = NULL; // Do not access message. May have been deleted. | 110 message = NULL; // Do not access message. May have been deleted. |
(...skipping 23 matching lines...) Expand all Loading... |
134 // TODO(turnidge): Add assert that monitor_ is held here. | 134 // TODO(turnidge): Add assert that monitor_ is held here. |
135 bool result = true; | 135 bool result = true; |
136 Message::Priority min_priority = (allow_normal_messages | 136 Message::Priority min_priority = (allow_normal_messages |
137 ? Message::kNormalPriority | 137 ? Message::kNormalPriority |
138 : Message::kOOBPriority); | 138 : Message::kOOBPriority); |
139 Message* message = DequeueMessage(min_priority); | 139 Message* message = DequeueMessage(min_priority); |
140 while (message) { | 140 while (message) { |
141 if (FLAG_trace_isolates) { | 141 if (FLAG_trace_isolates) { |
142 OS::Print("[<] Handling message:\n" | 142 OS::Print("[<] Handling message:\n" |
143 "\thandler: %s\n" | 143 "\thandler: %s\n" |
144 "\tport: %lld\n", | 144 "\tport: %"Pd64"\n", |
145 name(), message->dest_port()); | 145 name(), message->dest_port()); |
146 } | 146 } |
147 | 147 |
148 // Release the monitor_ temporarily while we handle the message. | 148 // Release the monitor_ temporarily while we handle the message. |
149 // The monitor was acquired in MessageHandler::TaskCallback(). | 149 // The monitor was acquired in MessageHandler::TaskCallback(). |
150 monitor_.Exit(); | 150 monitor_.Exit(); |
151 Message::Priority saved_priority = message->priority(); | 151 Message::Priority saved_priority = message->priority(); |
152 result = HandleMessage(message); | 152 result = HandleMessage(message); |
153 // ASSERT(Isolate::Current() == NULL); | 153 // ASSERT(Isolate::Current() == NULL); |
154 monitor_.Enter(); | 154 monitor_.Enter(); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // The handler may have been deleted after this point. | 228 // The handler may have been deleted after this point. |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 | 232 |
233 void MessageHandler::ClosePort(Dart_Port port) { | 233 void MessageHandler::ClosePort(Dart_Port port) { |
234 MonitorLocker ml(&monitor_); | 234 MonitorLocker ml(&monitor_); |
235 if (FLAG_trace_isolates) { | 235 if (FLAG_trace_isolates) { |
236 OS::Print("[-] Closing port:\n" | 236 OS::Print("[-] Closing port:\n" |
237 "\thandler: %s\n" | 237 "\thandler: %s\n" |
238 "\tport: %d\n", | 238 "\tport: %"Pd64"\n", |
239 name(), port); | 239 name(), port); |
240 } | 240 } |
241 queue_->Flush(port); | 241 queue_->Flush(port); |
242 oob_queue_->Flush(port); | 242 oob_queue_->Flush(port); |
243 } | 243 } |
244 | 244 |
245 | 245 |
246 void MessageHandler::CloseAllPorts() { | 246 void MessageHandler::CloseAllPorts() { |
247 MonitorLocker ml(&monitor_); | 247 MonitorLocker ml(&monitor_); |
248 if (FLAG_trace_isolates) { | 248 if (FLAG_trace_isolates) { |
(...skipping 17 matching lines...) Expand all Loading... |
266 | 266 |
267 void MessageHandler::decrement_live_ports() { | 267 void MessageHandler::decrement_live_ports() { |
268 MonitorLocker ml(&monitor_); | 268 MonitorLocker ml(&monitor_); |
269 #if defined(DEBUG) | 269 #if defined(DEBUG) |
270 CheckAccess(); | 270 CheckAccess(); |
271 #endif | 271 #endif |
272 live_ports_--; | 272 live_ports_--; |
273 } | 273 } |
274 | 274 |
275 } // namespace dart | 275 } // namespace dart |
OLD | NEW |