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

Side by Side Diff: vm/port.cc

Issue 8555024: - Avoid allocating variable length arrays on the stack. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years, 1 month 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/globals.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) 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
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
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
OLDNEW
« no previous file with comments | « vm/globals.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698