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