| 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 map_ = new Entry[kInitialCapacity]; | 296 map_ = new Entry[kInitialCapacity]; |
| 297 memset(map_, 0, kInitialCapacity * sizeof(Entry)); | 297 memset(map_, 0, kInitialCapacity * sizeof(Entry)); |
| 298 capacity_ = kInitialCapacity; | 298 capacity_ = kInitialCapacity; |
| 299 used_ = 0; | 299 used_ = 0; |
| 300 deleted_ = 0; | 300 deleted_ = 0; |
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 void PortMap::PrintPortsForMessageHandler(MessageHandler* handler, | 304 void PortMap::PrintPortsForMessageHandler(MessageHandler* handler, |
| 305 JSONStream* stream) { | 305 JSONStream* stream) { |
| 306 #ifndef PRODUCT |
| 306 if (!FLAG_support_service) { | 307 if (!FLAG_support_service) { |
| 307 return; | 308 return; |
| 308 } | 309 } |
| 309 JSONObject jsobj(stream); | 310 JSONObject jsobj(stream); |
| 310 jsobj.AddProperty("type", "_Ports"); | 311 jsobj.AddProperty("type", "_Ports"); |
| 311 Object& msg_handler = Object::Handle(); | 312 Object& msg_handler = Object::Handle(); |
| 312 { | 313 { |
| 313 JSONArray ports(&jsobj, "ports"); | 314 JSONArray ports(&jsobj, "ports"); |
| 314 SafepointMutexLocker ml(mutex_); | 315 SafepointMutexLocker ml(mutex_); |
| 315 for (intptr_t i = 0; i < capacity_; i++) { | 316 for (intptr_t i = 0; i < capacity_; i++) { |
| 316 if (map_[i].handler == handler) { | 317 if (map_[i].handler == handler) { |
| 317 if (map_[i].state == kLivePort) { | 318 if (map_[i].state == kLivePort) { |
| 318 JSONObject port(&ports); | 319 JSONObject port(&ports); |
| 319 port.AddProperty("type", "_Port"); | 320 port.AddProperty("type", "_Port"); |
| 320 port.AddPropertyF("name", "Isolate Port (%" Pd64 ")", map_[i].port); | 321 port.AddPropertyF("name", "Isolate Port (%" Pd64 ")", map_[i].port); |
| 321 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); | 322 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); |
| 322 port.AddProperty("handler", msg_handler); | 323 port.AddProperty("handler", msg_handler); |
| 323 } | 324 } |
| 324 } | 325 } |
| 325 } | 326 } |
| 326 } | 327 } |
| 328 #endif |
| 327 } | 329 } |
| 328 | 330 |
| 329 | 331 |
| 330 void PortMap::DebugDumpForMessageHandler(MessageHandler* handler) { | 332 void PortMap::DebugDumpForMessageHandler(MessageHandler* handler) { |
| 331 SafepointMutexLocker ml(mutex_); | 333 SafepointMutexLocker ml(mutex_); |
| 332 Object& msg_handler = Object::Handle(); | 334 Object& msg_handler = Object::Handle(); |
| 333 for (intptr_t i = 0; i < capacity_; i++) { | 335 for (intptr_t i = 0; i < capacity_; i++) { |
| 334 if (map_[i].handler == handler) { | 336 if (map_[i].handler == handler) { |
| 335 if (map_[i].state == kLivePort) { | 337 if (map_[i].state == kLivePort) { |
| 336 OS::Print("Live Port = %" Pd64 "\n", map_[i].port); | 338 OS::Print("Live Port = %" Pd64 "\n", map_[i].port); |
| 337 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); | 339 msg_handler = DartLibraryCalls::LookupHandler(map_[i].port); |
| 338 OS::Print("Handler = %s\n", msg_handler.ToCString()); | 340 OS::Print("Handler = %s\n", msg_handler.ToCString()); |
| 339 } | 341 } |
| 340 } | 342 } |
| 341 } | 343 } |
| 342 } | 344 } |
| 343 | 345 |
| 344 | 346 |
| 345 } // namespace dart | 347 } // namespace dart |
| OLD | NEW |