| 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 16483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16494 if (parent_value > child1_value) break; | 16494 if (parent_value > child1_value) break; |
| 16495 content->SwapPairs(numbers, parent_index, child_index); | 16495 content->SwapPairs(numbers, parent_index, child_index); |
| 16496 parent_index = child_index; | 16496 parent_index = child_index; |
| 16497 } else { | 16497 } else { |
| 16498 if (parent_value > child2_value) break; | 16498 if (parent_value > child2_value) break; |
| 16499 content->SwapPairs(numbers, parent_index, child_index + 1); | 16499 content->SwapPairs(numbers, parent_index, child_index + 1); |
| 16500 parent_index = child_index + 1; | 16500 parent_index = child_index + 1; |
| 16501 } | 16501 } |
| 16502 } | 16502 } |
| 16503 } | 16503 } |
| 16504 // Wipe deleted entries. |
| 16505 Heap* heap = GetHeap(); |
| 16506 Object* the_hole = heap->the_hole_value(); |
| 16507 Object* undefined = heap->undefined_value(); |
| 16508 for (uint32_t current = 0; current < capacity; current++) { |
| 16509 if (get(EntryToIndex(current)) == the_hole) { |
| 16510 set(EntryToIndex(current), undefined); |
| 16511 } |
| 16512 } |
| 16513 SetNumberOfDeletedElements(0); |
| 16504 } | 16514 } |
| 16505 | 16515 |
| 16506 | 16516 |
| 16507 // Sort this array and the numbers as pairs wrt. the (distinct) numbers. | 16517 // Sort this array and the numbers as pairs wrt. the (distinct) numbers. |
| 16508 void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) { | 16518 void FixedArray::SortPairs(FixedArray* numbers, uint32_t len) { |
| 16509 DCHECK(this->length() == numbers->length()); | 16519 DCHECK(this->length() == numbers->length()); |
| 16510 // For small arrays, simply use insertion sort. | 16520 // For small arrays, simply use insertion sort. |
| 16511 if (len <= 10) { | 16521 if (len <= 10) { |
| 16512 InsertionSortPairs(this, numbers, len); | 16522 InsertionSortPairs(this, numbers, len); |
| 16513 return; | 16523 return; |
| (...skipping 2188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18702 Isolate* isolate = table->GetIsolate(); | 18712 Isolate* isolate = table->GetIsolate(); |
| 18703 | 18713 |
| 18704 int entry = table->FindEntry(isolate, key, hash); | 18714 int entry = table->FindEntry(isolate, key, hash); |
| 18705 | 18715 |
| 18706 // Key is already in table, just overwrite value. | 18716 // Key is already in table, just overwrite value. |
| 18707 if (entry != kNotFound) { | 18717 if (entry != kNotFound) { |
| 18708 table->set(EntryToIndex(entry) + 1, *value); | 18718 table->set(EntryToIndex(entry) + 1, *value); |
| 18709 return table; | 18719 return table; |
| 18710 } | 18720 } |
| 18711 | 18721 |
| 18722 // Rehash if more than 25% of the entries are deleted entries. |
| 18723 // TODO(jochen): Consider to shrink the fixed array in place. |
| 18724 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { |
| 18725 table->Rehash(isolate->factory()->undefined_value()); |
| 18726 } |
| 18727 |
| 18712 // Check whether the hash table should be extended. | 18728 // Check whether the hash table should be extended. |
| 18713 table = EnsureCapacity(table, 1, key); | 18729 table = EnsureCapacity(table, 1, key); |
| 18714 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | 18730 table->AddEntry(table->FindInsertionEntry(hash), *key, *value); |
| 18715 return table; | 18731 return table; |
| 18716 } | 18732 } |
| 18717 | 18733 |
| 18718 | 18734 |
| 18719 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, | 18735 Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table, |
| 18720 Handle<Object> key, | 18736 Handle<Object> key, |
| 18721 bool* was_present) { | 18737 bool* was_present) { |
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 19864 if (cell->value() != *new_value) { | 19880 if (cell->value() != *new_value) { |
| 19865 cell->set_value(*new_value); | 19881 cell->set_value(*new_value); |
| 19866 Isolate* isolate = cell->GetIsolate(); | 19882 Isolate* isolate = cell->GetIsolate(); |
| 19867 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19883 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
| 19868 isolate, DependentCode::kPropertyCellChangedGroup); | 19884 isolate, DependentCode::kPropertyCellChangedGroup); |
| 19869 } | 19885 } |
| 19870 } | 19886 } |
| 19871 | 19887 |
| 19872 } // namespace internal | 19888 } // namespace internal |
| 19873 } // namespace v8 | 19889 } // namespace v8 |
| OLD | NEW |