OLD | NEW |
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/port.h" | 5 #include "vm/port.h" |
6 | 6 |
7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
8 #include "platform/utils.h" | 8 #include "platform/utils.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 map_ = new Entry[kInitialCapacity]; | 298 map_ = new Entry[kInitialCapacity]; |
299 memset(map_, 0, kInitialCapacity * sizeof(Entry)); | 299 memset(map_, 0, kInitialCapacity * sizeof(Entry)); |
300 capacity_ = kInitialCapacity; | 300 capacity_ = kInitialCapacity; |
301 used_ = 0; | 301 used_ = 0; |
302 deleted_ = 0; | 302 deleted_ = 0; |
303 } | 303 } |
304 | 304 |
305 | 305 |
306 void PortMap::PrintPortsForMessageHandler(MessageHandler* handler, | 306 void PortMap::PrintPortsForMessageHandler(MessageHandler* handler, |
307 JSONStream* stream) { | 307 JSONStream* stream) { |
| 308 if (!FLAG_support_service) { |
| 309 return; |
| 310 } |
308 JSONObject jsobj(stream); | 311 JSONObject jsobj(stream); |
309 jsobj.AddProperty("type", "_Ports"); | 312 jsobj.AddProperty("type", "_Ports"); |
310 Object& msg_handler = Object::Handle(); | 313 Object& msg_handler = Object::Handle(); |
311 { | 314 { |
312 JSONArray ports(&jsobj, "ports"); | 315 JSONArray ports(&jsobj, "ports"); |
313 MutexLocker ml(mutex_); | 316 MutexLocker ml(mutex_); |
314 for (intptr_t i = 0; i < capacity_; i++) { | 317 for (intptr_t i = 0; i < capacity_; i++) { |
315 if (map_[i].handler == handler) { | 318 if (map_[i].handler == handler) { |
316 if (map_[i].state == kLivePort) { | 319 if (map_[i].state == kLivePort) { |
317 JSONObject port(&ports); | 320 JSONObject port(&ports); |
318 port.AddProperty("type", "_Port"); | 321 port.AddProperty("type", "_Port"); |
319 port.AddPropertyF("name", "Isolate Port (%" Pd64 ")", map_[i].port); | 322 port.AddPropertyF("name", "Isolate Port (%" Pd64 ")", map_[i].port); |
320 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); | 323 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); |
321 port.AddProperty("handler", msg_handler); | 324 port.AddProperty("handler", msg_handler); |
322 } | 325 } |
323 } | 326 } |
324 } | 327 } |
325 } | 328 } |
326 } | 329 } |
327 | 330 |
328 } // namespace dart | 331 } // namespace dart |
OLD | NEW |