| 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 "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/message_handler.h" | 10 #include "vm/message_handler.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 247 |
| 248 Isolate* PortMap::GetIsolate(Dart_Port id) { | 248 Isolate* PortMap::GetIsolate(Dart_Port id) { |
| 249 MutexLocker ml(mutex_); | 249 MutexLocker ml(mutex_); |
| 250 intptr_t index = FindPort(id); | 250 intptr_t index = FindPort(id); |
| 251 if (index < 0) { | 251 if (index < 0) { |
| 252 // Port does not exist. | 252 // Port does not exist. |
| 253 return NULL; | 253 return NULL; |
| 254 } | 254 } |
| 255 | 255 |
| 256 MessageHandler* handler = map_[index].handler; | 256 MessageHandler* handler = map_[index].handler; |
| 257 return handler->GetIsolate(); | 257 return handler->isolate(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 | 260 |
| 261 void PortMap::InitOnce() { | 261 void PortMap::InitOnce() { |
| 262 mutex_ = new Mutex(); | 262 mutex_ = new Mutex(); |
| 263 prng_ = new Random(); | 263 prng_ = new Random(); |
| 264 | 264 |
| 265 static const intptr_t kInitialCapacity = 8; | 265 static const intptr_t kInitialCapacity = 8; |
| 266 // TODO(iposva): Verify whether we want to keep exponentially growing. | 266 // TODO(iposva): Verify whether we want to keep exponentially growing. |
| 267 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); | 267 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); |
| 268 map_ = new Entry[kInitialCapacity]; | 268 map_ = new Entry[kInitialCapacity]; |
| 269 memset(map_, 0, kInitialCapacity * sizeof(Entry)); | 269 memset(map_, 0, kInitialCapacity * sizeof(Entry)); |
| 270 capacity_ = kInitialCapacity; | 270 capacity_ = kInitialCapacity; |
| 271 used_ = 0; | 271 used_ = 0; |
| 272 deleted_ = 0; | 272 deleted_ = 0; |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace dart | 275 } // namespace dart |
| OLD | NEW |