OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_WEAK_TABLE_H_ | 5 #ifndef VM_WEAK_TABLE_H_ |
6 #define VM_WEAK_TABLE_H_ | 6 #define VM_WEAK_TABLE_H_ |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 | 9 |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 if (val == 0) { | 147 if (val == 0) { |
148 data_[ObjectIndex(i)] = kDeletedEntry; | 148 data_[ObjectIndex(i)] = kDeletedEntry; |
149 set_count(count() - 1); | 149 set_count(count() - 1); |
150 } | 150 } |
151 data_[ValueIndex(i)] = val; | 151 data_[ValueIndex(i)] = val; |
152 } | 152 } |
153 | 153 |
154 void Rehash(); | 154 void Rehash(); |
155 | 155 |
156 static intptr_t Hash(RawObject* key) { | 156 static intptr_t Hash(RawObject* key) { |
157 return reinterpret_cast<intptr_t>(key) * 92821; | 157 return reinterpret_cast<uintptr_t>(key) * 92821; |
158 } | 158 } |
159 | 159 |
160 // data_ contains size_ tuples of key/value. | 160 // data_ contains size_ tuples of key/value. |
161 intptr_t* data_; | 161 intptr_t* data_; |
162 // size_ keeps the number of entries in data_. used_ maintains the number of | 162 // size_ keeps the number of entries in data_. used_ maintains the number of |
163 // non-NULL entries and will trigger rehashing if needed. count_ stores the | 163 // non-NULL entries and will trigger rehashing if needed. count_ stores the |
164 // number valid entries, and will determine the size_ after rehashing. | 164 // number valid entries, and will determine the size_ after rehashing. |
165 intptr_t size_; | 165 intptr_t size_; |
166 intptr_t used_; | 166 intptr_t used_; |
167 intptr_t count_; | 167 intptr_t count_; |
168 | 168 |
169 DISALLOW_COPY_AND_ASSIGN(WeakTable); | 169 DISALLOW_COPY_AND_ASSIGN(WeakTable); |
170 }; | 170 }; |
171 | 171 |
172 } // namespace dart | 172 } // namespace dart |
173 | 173 |
174 #endif // VM_WEAK_TABLE_H_ | 174 #endif // VM_WEAK_TABLE_H_ |
OLD | NEW |