| 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/objects.h" | 5 #include "src/objects.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 16849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16860 // The other element will be processed on the next iteration. | 16860 // The other element will be processed on the next iteration. |
| 16861 current--; | 16861 current--; |
| 16862 } else { | 16862 } else { |
| 16863 // The place for the current element is occupied. Leave the element | 16863 // The place for the current element is occupied. Leave the element |
| 16864 // for the next probe. | 16864 // for the next probe. |
| 16865 done = false; | 16865 done = false; |
| 16866 } | 16866 } |
| 16867 } | 16867 } |
| 16868 } | 16868 } |
| 16869 } | 16869 } |
| 16870 // Wipe deleted entries. |
| 16871 Heap* heap = GetHeap(); |
| 16872 Object* the_hole = heap->the_hole_value(); |
| 16873 Object* undefined = heap->undefined_value(); |
| 16874 for (uint32_t current = 0; current < capacity; current++) { |
| 16875 if (get(EntryToIndex(current)) == the_hole) { |
| 16876 set(EntryToIndex(current), undefined); |
| 16877 } |
| 16878 } |
| 16879 SetNumberOfDeletedElements(0); |
| 16870 } | 16880 } |
| 16871 | 16881 |
| 16872 | 16882 |
| 16873 template<typename Derived, typename Shape, typename Key> | 16883 template<typename Derived, typename Shape, typename Key> |
| 16874 Handle<Derived> HashTable<Derived, Shape, Key>::EnsureCapacity( | 16884 Handle<Derived> HashTable<Derived, Shape, Key>::EnsureCapacity( |
| 16875 Handle<Derived> table, | 16885 Handle<Derived> table, |
| 16876 int n, | 16886 int n, |
| 16877 Key key, | 16887 Key key, |
| 16878 PretenureFlag pretenure) { | 16888 PretenureFlag pretenure) { |
| 16879 Isolate* isolate = table->GetIsolate(); | 16889 Isolate* isolate = table->GetIsolate(); |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18210 Isolate* isolate = table->GetIsolate(); | 18220 Isolate* isolate = table->GetIsolate(); |
| 18211 | 18221 |
| 18212 int entry = table->FindEntry(isolate, key, hash); | 18222 int entry = table->FindEntry(isolate, key, hash); |
| 18213 | 18223 |
| 18214 // Key is already in table, just overwrite value. | 18224 // Key is already in table, just overwrite value. |
| 18215 if (entry != kNotFound) { | 18225 if (entry != kNotFound) { |
| 18216 table->set(EntryToIndex(entry) + 1, *value); | 18226 table->set(EntryToIndex(entry) + 1, *value); |
| 18217 return table; | 18227 return table; |
| 18218 } | 18228 } |
| 18219 | 18229 |
| 18230 // Rehash if more than 25% of the entries are deleted entries. |
| 18231 // TODO(jochen): Consider to shrink the fixed array in place. |
| 18232 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { |
| 18233 table->Rehash(isolate->factory()->undefined_value()); |
| 18234 } |
| 18235 |
| 18220 // Check whether the hash table should be extended. | 18236 // Check whether the hash table should be extended. |
| 18221 table = EnsureCapacity(table, 1, key); | 18237 table = EnsureCapacity(table, 1, key); |
| 18222 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | 18238 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); |
| 18223 return table; | 18239 return table; |
| 18224 } | 18240 } |
| 18225 | 18241 |
| 18226 | 18242 |
| 18227 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, | 18243 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
| 18228 Handle<Object> key, | 18244 Handle<Object> key, |
| 18229 bool* was_present) { | 18245 bool* was_present) { |
| (...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19374 if (cell->value() != *new_value) { | 19390 if (cell->value() != *new_value) { |
| 19375 cell->set_value(*new_value); | 19391 cell->set_value(*new_value); |
| 19376 Isolate* isolate = cell->GetIsolate(); | 19392 Isolate* isolate = cell->GetIsolate(); |
| 19377 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19393 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19378 isolate, DependentCode::kPropertyCellChangedGroup); | 19394 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19379 } | 19395 } |
| 19380 } | 19396 } |
| 19381 | 19397 |
| 19382 } // namespace internal | 19398 } // namespace internal |
| 19383 } // namespace v8 | 19399 } // namespace v8 |
| OLD | NEW |