Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: vm/port.cc

Issue 11052006: 1. Create a port when a debugger object is created for an isolate, use this (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/port.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 if (index < 0) { 223 if (index < 0) {
224 // Port does not exist. 224 // Port does not exist.
225 return false; 225 return false;
226 } 226 }
227 227
228 MessageHandler* handler = map_[index].handler; 228 MessageHandler* handler = map_[index].handler;
229 return handler->IsCurrentIsolate(); 229 return handler->IsCurrentIsolate();
230 } 230 }
231 231
232 232
233 Isolate* PortMap::GetIsolate(Dart_Port id) {
234 MutexLocker ml(mutex_);
235 intptr_t index = FindPort(id);
236 if (index < 0) {
237 // Port does not exist.
238 return NULL;
239 }
240
241 MessageHandler* handler = map_[index].handler;
242 return handler->GetIsolate();
243 }
244
245
233 void PortMap::InitOnce() { 246 void PortMap::InitOnce() {
234 mutex_ = new Mutex(); 247 mutex_ = new Mutex();
235 248
236 static const intptr_t kInitialCapacity = 8; 249 static const intptr_t kInitialCapacity = 8;
237 // TODO(iposva): Verify whether we want to keep exponentially growing. 250 // TODO(iposva): Verify whether we want to keep exponentially growing.
238 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); 251 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity));
239 map_ = new Entry[kInitialCapacity]; 252 map_ = new Entry[kInitialCapacity];
240 memset(map_, 0, kInitialCapacity * sizeof(Entry)); 253 memset(map_, 0, kInitialCapacity * sizeof(Entry));
241 capacity_ = kInitialCapacity; 254 capacity_ = kInitialCapacity;
242 used_ = 0; 255 used_ = 0;
243 deleted_ = 0; 256 deleted_ = 0;
244 } 257 }
245 258
246 } // namespace dart 259 } // namespace dart
OLDNEW
« no previous file with comments | « vm/port.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698