| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/isolate.h" | 7 #include "vm/isolate.h" |
| 8 #include "vm/thread.h" | 8 #include "vm/thread.h" |
| 9 #include "vm/utils.h" | 9 #include "vm/utils.h" |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 Entry entry = map_[i]; | 47 Entry entry = map_[i]; |
| 48 // Skip free and deleted entries. | 48 // Skip free and deleted entries. |
| 49 if (entry.port != 0) { | 49 if (entry.port != 0) { |
| 50 intptr_t new_index = entry.port % new_capacity; | 50 intptr_t new_index = entry.port % new_capacity; |
| 51 while (new_ports[new_index].port != 0) { | 51 while (new_ports[new_index].port != 0) { |
| 52 new_index = (new_index + 1) % new_capacity; | 52 new_index = (new_index + 1) % new_capacity; |
| 53 } | 53 } |
| 54 new_ports[new_index] = entry; | 54 new_ports[new_index] = entry; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 delete map_; | 57 delete[] map_; |
| 58 map_ = new_ports; | 58 map_ = new_ports; |
| 59 capacity_ = new_capacity; | 59 capacity_ = new_capacity; |
| 60 deleted_ = 0; | 60 deleted_ = 0; |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 |
| 64 Dart_Port PortMap::AllocatePort() { | 64 Dart_Port PortMap::AllocatePort() { |
| 65 Dart_Port result = next_port_; | 65 Dart_Port result = next_port_; |
| 66 | 66 |
| 67 do { | 67 do { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); | 225 ASSERT(Utils::IsPowerOfTwo(kInitialCapacity)); |
| 226 map_ = new Entry[kInitialCapacity]; | 226 map_ = new Entry[kInitialCapacity]; |
| 227 memset(map_, 0, kInitialCapacity * sizeof(Entry)); | 227 memset(map_, 0, kInitialCapacity * sizeof(Entry)); |
| 228 capacity_ = kInitialCapacity; | 228 capacity_ = kInitialCapacity; |
| 229 used_ = 0; | 229 used_ = 0; |
| 230 deleted_ = 0; | 230 deleted_ = 0; |
| 231 } | 231 } |
| 232 | 232 |
| 233 | 233 |
| 234 } // namespace dart | 234 } // namespace dart |
| OLD | NEW |