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

Side by Side Diff: runtime/vm/port.cc

Issue 1140263005: Revert "Hide Isolate pointer from embedder" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « runtime/vm/port.h ('k') | runtime/vm/service_isolate.cc » ('j') | 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/lockers.h" 10 #include "vm/lockers.h"
11 #include "vm/message_handler.h" 11 #include "vm/message_handler.h"
12 #include "vm/os_thread.h" 12 #include "vm/os_thread.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DECLARE_FLAG(bool, trace_isolates); 16 DECLARE_FLAG(bool, trace_isolates);
17 17
18 Mutex* PortMap::mutex_ = NULL; 18 Mutex* PortMap::mutex_ = NULL;
19 PortMap::Entry* PortMap::map_ = NULL; 19 PortMap::Entry* PortMap::map_ = NULL;
20 MessageHandler* PortMap::deleted_entry_ = reinterpret_cast<MessageHandler*>(1); 20 MessageHandler* PortMap::deleted_entry_ = reinterpret_cast<MessageHandler*>(1);
21 intptr_t PortMap::capacity_ = 0; 21 intptr_t PortMap::capacity_ = 0;
22 intptr_t PortMap::used_ = 0; 22 intptr_t PortMap::used_ = 0;
23 intptr_t PortMap::deleted_ = 0; 23 intptr_t PortMap::deleted_ = 0;
24 Random* PortMap::prng_ = NULL; 24 Random* PortMap::prng_ = NULL;
25 25
26 26
27 intptr_t PortMap::FindPort(Dart_Port port) { 27 intptr_t PortMap::FindPort(Dart_Port port) {
28 // DART_ILLEGAL_PORT (0) is used as a sentinel value in Entry.port. The loop 28 // ILLEGAL_PORT (0) is used as a sentinel value in Entry.port. The loop below
29 // below could return the index to a deleted port when we are searching for 29 // could return the index to a deleted port when we are searching for
30 // port id DART_ILLEGAL_PORT. Return -1 immediately to indicate the port 30 // port id ILLEGAL_PORT. Return -1 immediately to indicate the port
31 // does not exist. 31 // does not exist.
32 if (port == DART_ILLEGAL_PORT) { 32 if (port == ILLEGAL_PORT) {
33 return -1; 33 return -1;
34 } 34 }
35 ASSERT(port != DART_ILLEGAL_PORT); 35 ASSERT(port != ILLEGAL_PORT);
36 intptr_t index = port % capacity_; 36 intptr_t index = port % capacity_;
37 intptr_t start_index = index; 37 intptr_t start_index = index;
38 Entry entry = map_[index]; 38 Entry entry = map_[index];
39 while (entry.handler != NULL) { 39 while (entry.handler != NULL) {
40 if (entry.port == port) { 40 if (entry.port == port) {
41 return index; 41 return index;
42 } 42 }
43 index = (index + 1) % capacity_; 43 index = (index + 1) % capacity_;
44 // Prevent endless loops. 44 // Prevent endless loops.
45 ASSERT(index != start_index); 45 ASSERT(index != start_index);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // TODO(iposva): Verify whether we want to keep exponentially growing. 295 // TODO(iposva): Verify whether we want to keep exponentially growing.
296 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); 296 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity));
297 map_ = new Entry[kInitialCapacity]; 297 map_ = new Entry[kInitialCapacity];
298 memset(map_, 0, kInitialCapacity * sizeof(Entry)); 298 memset(map_, 0, kInitialCapacity * sizeof(Entry));
299 capacity_ = kInitialCapacity; 299 capacity_ = kInitialCapacity;
300 used_ = 0; 300 used_ = 0;
301 deleted_ = 0; 301 deleted_ = 0;
302 } 302 }
303 303
304 } // namespace dart 304 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/port.h ('k') | runtime/vm/service_isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698