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

Side by Side Diff: runtime/vm/hash_map.h

Issue 1220193009: Migrate most uses of Isolate::current_zone to Thread::zone. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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/growable_array.h ('k') | runtime/vm/il_printer.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 #ifndef VM_HASH_MAP_H_ 5 #ifndef VM_HASH_MAP_H_
6 #define VM_HASH_MAP_H_ 6 #define VM_HASH_MAP_H_
7 7
8 namespace dart { 8 namespace dart {
9 9
10 template <typename KeyValueTrait> 10 template <typename KeyValueTrait>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 99 }
100 100
101 101
102 template <typename KeyValueTrait> 102 template <typename KeyValueTrait>
103 DirectChainedHashMap<KeyValueTrait>:: 103 DirectChainedHashMap<KeyValueTrait>::
104 DirectChainedHashMap(const DirectChainedHashMap& other) 104 DirectChainedHashMap(const DirectChainedHashMap& other)
105 : ValueObject(), 105 : ValueObject(),
106 array_size_(other.array_size_), 106 array_size_(other.array_size_),
107 lists_size_(other.lists_size_), 107 lists_size_(other.lists_size_),
108 count_(other.count_), 108 count_(other.count_),
109 array_(Isolate::Current()->current_zone()-> 109 array_(Thread::Current()->zone()->
110 Alloc<HashMapListElement>(other.array_size_)), 110 Alloc<HashMapListElement>(other.array_size_)),
111 lists_(Isolate::Current()->current_zone()-> 111 lists_(Thread::Current()->zone()->
112 Alloc<HashMapListElement>(other.lists_size_)), 112 Alloc<HashMapListElement>(other.lists_size_)),
113 free_list_head_(other.free_list_head_) { 113 free_list_head_(other.free_list_head_) {
114 memmove(array_, other.array_, array_size_ * sizeof(HashMapListElement)); 114 memmove(array_, other.array_, array_size_ * sizeof(HashMapListElement));
115 memmove(lists_, other.lists_, lists_size_ * sizeof(HashMapListElement)); 115 memmove(lists_, other.lists_, lists_size_ * sizeof(HashMapListElement));
116 } 116 }
117 117
118 118
119 template <typename KeyValueTrait> 119 template <typename KeyValueTrait>
120 void DirectChainedHashMap<KeyValueTrait>::Resize(intptr_t new_size) { 120 void DirectChainedHashMap<KeyValueTrait>::Resize(intptr_t new_size) {
121 const typename KeyValueTrait::Value kNoValue = 121 const typename KeyValueTrait::Value kNoValue =
122 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair()); 122 KeyValueTrait::ValueOf(typename KeyValueTrait::Pair());
123 123
124 ASSERT(new_size > count_); 124 ASSERT(new_size > count_);
125 // Hashing the values into the new array has no more collisions than in the 125 // Hashing the values into the new array has no more collisions than in the
126 // old hash map, so we can use the existing lists_ array, if we are careful. 126 // old hash map, so we can use the existing lists_ array, if we are careful.
127 127
128 // Make sure we have at least one free element. 128 // Make sure we have at least one free element.
129 if (free_list_head_ == kNil) { 129 if (free_list_head_ == kNil) {
130 ResizeLists(lists_size_ << 1); 130 ResizeLists(lists_size_ << 1);
131 } 131 }
132 132
133 HashMapListElement* new_array = 133 HashMapListElement* new_array =
134 Isolate::Current()->current_zone()->Alloc<HashMapListElement>(new_size); 134 Thread::Current()->zone()->Alloc<HashMapListElement>(new_size);
135 InitArray(new_array, new_size); 135 InitArray(new_array, new_size);
136 136
137 HashMapListElement* old_array = array_; 137 HashMapListElement* old_array = array_;
138 intptr_t old_size = array_size_; 138 intptr_t old_size = array_size_;
139 139
140 intptr_t old_count = count_; 140 intptr_t old_count = count_;
141 count_ = 0; 141 count_ = 0;
142 array_size_ = new_size; 142 array_size_ = new_size;
143 array_ = new_array; 143 array_ = new_array;
144 144
(...skipping 17 matching lines...) Expand all
162 USE(old_count); 162 USE(old_count);
163 ASSERT(count_ == old_count); 163 ASSERT(count_ == old_count);
164 } 164 }
165 165
166 166
167 template <typename T> 167 template <typename T>
168 void DirectChainedHashMap<T>::ResizeLists(intptr_t new_size) { 168 void DirectChainedHashMap<T>::ResizeLists(intptr_t new_size) {
169 ASSERT(new_size > lists_size_); 169 ASSERT(new_size > lists_size_);
170 170
171 HashMapListElement* new_lists = 171 HashMapListElement* new_lists =
172 Isolate::Current()->current_zone()-> 172 Thread::Current()->zone()->
173 Alloc<HashMapListElement>(new_size); 173 Alloc<HashMapListElement>(new_size);
174 InitArray(new_lists, new_size); 174 InitArray(new_lists, new_size);
175 175
176 HashMapListElement* old_lists = lists_; 176 HashMapListElement* old_lists = lists_;
177 intptr_t old_size = lists_size_; 177 intptr_t old_size = lists_size_;
178 178
179 lists_size_ = new_size; 179 lists_size_ = new_size;
180 lists_ = new_lists; 180 lists_ = new_lists;
181 181
182 if (old_lists != NULL) { 182 if (old_lists != NULL) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 242
243 static inline bool IsKeyEqual(Pair kv, Key key) { 243 static inline bool IsKeyEqual(Pair kv, Key key) {
244 return kv->Equals(key); 244 return kv->Equals(key);
245 } 245 }
246 }; 246 };
247 247
248 } // namespace dart 248 } // namespace dart
249 249
250 #endif // VM_HASH_MAP_H_ 250 #endif // VM_HASH_MAP_H_
OLDNEW
« no previous file with comments | « runtime/vm/growable_array.h ('k') | runtime/vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698