| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/identity-map.h" | 5 #include "src/identity-map.h" |
| 6 | 6 |
| 7 #include "src/heap/heap.h" | 7 #include "src/heap/heap.h" |
| 8 #include "src/heap/heap-inl.h" | 8 #include "src/heap/heap-inl.h" |
| 9 #include "src/zone-containers.h" | 9 #include "src/zone-containers.h" |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 keys_[i] = not_mapped; | 144 keys_[i] = not_mapped; |
| 145 values_[i] = nullptr; | 145 values_[i] = nullptr; |
| 146 last_empty = i; | 146 last_empty = i; |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 // Reinsert all the key/value pairs that were in the wrong place. | 150 // Reinsert all the key/value pairs that were in the wrong place. |
| 151 for (auto pair : reinsert) { | 151 for (auto pair : reinsert) { |
| 152 int index = InsertIndex(pair.first); | 152 int index = InsertIndex(pair.first); |
| 153 DCHECK_GE(index, 0); | 153 DCHECK_GE(index, 0); |
| 154 DCHECK_NE(heap_->not_mapped_symbol(), values_[index]); | 154 DCHECK_NULL(values_[index]); |
| 155 values_[index] = pair.second; | 155 values_[index] = pair.second; |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| 159 | 159 |
| 160 void IdentityMapBase::Resize() { | 160 void IdentityMapBase::Resize() { |
| 161 // Grow the internal storage and reinsert all the key/value pairs. | 161 // Grow the internal storage and reinsert all the key/value pairs. |
| 162 int old_size = size_; | 162 int old_size = size_; |
| 163 Object** old_keys = keys_; | 163 Object** old_keys = keys_; |
| 164 void** old_values = values_; | 164 void** old_values = values_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 181 DCHECK_GE(index, 0); | 181 DCHECK_GE(index, 0); |
| 182 values_[index] = old_values[i]; | 182 values_[index] = old_values[i]; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // Unregister old keys and register new keys. | 185 // Unregister old keys and register new keys. |
| 186 heap_->UnregisterStrongRoots(old_keys); | 186 heap_->UnregisterStrongRoots(old_keys); |
| 187 heap_->RegisterStrongRoots(keys_, keys_ + size_); | 187 heap_->RegisterStrongRoots(keys_, keys_ + size_); |
| 188 } | 188 } |
| 189 } // namespace internal | 189 } // namespace internal |
| 190 } // namespace v8 | 190 } // namespace v8 |
| OLD | NEW |