| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 52bb377 commit 2d07fd7
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,7 +11,7 @@ | |||
| 11 | 11 | #define V8_MAJOR_VERSION 4 | |
| 12 | 12 | #define V8_MINOR_VERSION 5 | |
| 13 | 13 | #define V8_BUILD_NUMBER 103 | |
| 14 | - #define V8_PATCH_LEVEL 38 | ||
| 14 | + #define V8_PATCH_LEVEL 39 | ||
| 15 | 15 | ||
| 16 | 16 | // Use 1 for candidates and 0 otherwise. | |
| 17 | 17 | // (Boolean macro values are not supported by all preprocessors.) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2614,6 +2614,13 @@ void MarkCompactCollector::ClearWeakCollections() { | |||
| 2614 | 2614 | table->RemoveEntry(i); | |
| 2615 | 2615 | } | |
| 2616 | 2616 | } | |
| 2617 | + // Rehash if more than 25% of the entries are deleted entries. | ||
| 2618 | + // TODO(jochen): Consider to shrink the fixed array in place. | ||
| 2619 | + if ((table->NumberOfDeletedElements() << kJSWeakCollectionLoadFactorExp) > | ||
| 2620 | + table->NumberOfElements()) { | ||
| 2621 | + HandleScope scope(heap()->isolate()); | ||
| 2622 | + table->Rehash(heap()->isolate()->factory()->undefined_value()); | ||
| 2623 | + } | ||
| 2617 | 2624 | } | |
| 2618 | 2625 | weak_collection_obj = weak_collection->next(); | |
| 2619 | 2626 | weak_collection->set_next(heap()->undefined_value()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -612,6 +612,10 @@ class MarkCompactCollector { | |||
| 612 | 612 | static const uint32_t kSingleFreeEncoding = 0; | |
| 613 | 613 | static const uint32_t kMultiFreeEncoding = 1; | |
| 614 | 614 | ||
| 615 | + // If the number of deleted slots in a JSWeakCollection exceeds the number | ||
| 616 | + // of entries / 2^(factor), we rehash the table. | ||
| 617 | + static const int kJSWeakCollectionLoadFactorExp = 1; | ||
| 618 | + | ||
| 615 | 619 | static inline bool IsMarked(Object* obj); | |
| 616 | 620 | static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); | |
| 617 | 621 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13744,6 +13744,16 @@ void HashTable<Derived, Shape, Key>::Rehash(Key key) { | |||
| 13744 | 13744 | } | |
| 13745 | 13745 | } | |
| 13746 | 13746 | } | |
| 13747 | + // Wipe deleted entries. | ||
| 13748 | + Heap* heap = GetHeap(); | ||
| 13749 | + Object* the_hole = heap->the_hole_value(); | ||
| 13750 | + Object* undefined = heap->undefined_value(); | ||
| 13751 | + for (uint32_t current = 0; current < capacity; current++) { | ||
| 13752 | + if (get(EntryToIndex(current)) == the_hole) { | ||
| 13753 | + set(EntryToIndex(current), undefined); | ||
| 13754 | + } | ||
| 13755 | + } | ||
| 13756 | + SetNumberOfDeletedElements(0); | ||
| 13747 | 13757 | } | |
| 13748 | 13758 | ||
| 13749 | 13759 | ||
@@ -14656,6 +14666,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutRegExp( | |||
| 14656 | 14666 | void CompilationCacheTable::Age() { | |
| 14657 | 14667 | DisallowHeapAllocation no_allocation; | |
| 14658 | 14668 | Object* the_hole_value = GetHeap()->the_hole_value(); | |
| 14669 | + uint32_t capacity = Capacity(); | ||
| 14659 | 14670 | for (int entry = 0, size = Capacity(); entry < size; entry++) { | |
| 14660 | 14671 | int entry_index = EntryToIndex(entry); | |
| 14661 | 14672 | int value_index = entry_index + 1; | |
@@ -14679,6 +14690,16 @@ void CompilationCacheTable::Age() { | |||
| 14679 | 14690 | } | |
| 14680 | 14691 | } | |
| 14681 | 14692 | } | |
| 14693 | + // Wipe deleted entries. | ||
| 14694 | + Heap* heap = GetHeap(); | ||
| 14695 | + Object* the_hole = heap->the_hole_value(); | ||
| 14696 | + Object* undefined = heap->undefined_value(); | ||
| 14697 | + for (uint32_t current = 0; current < capacity; current++) { | ||
| 14698 | + if (get(EntryToIndex(current)) == the_hole) { | ||
| 14699 | + set(EntryToIndex(current), undefined); | ||
| 14700 | + } | ||
| 14701 | + } | ||
| 14702 | + SetNumberOfDeletedElements(0); | ||
| 14682 | 14703 | } | |
| 14683 | 14704 | ||
| 14684 | 14705 | ||
@@ -15187,6 +15208,12 @@ Handle<ObjectHashTable> ObjectHashTable::Put(Handle<ObjectHashTable> table, | |||
| 15187 | 15208 | return table; | |
| 15188 | 15209 | } | |
| 15189 | 15210 | ||
| 15211 | + // Rehash if more than 25% of the entries are deleted entries. | ||
| 15212 | + // TODO(jochen): Consider to shrink the fixed array in place. | ||
| 15213 | + if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) { | ||
| 15214 | + table->Rehash(isolate->factory()->undefined_value()); | ||
| 15215 | + } | ||
| 15216 | + | ||
| 15190 | 15217 | // Check whether the hash table should be extended. | |
| 15191 | 15218 | table = EnsureCapacity(table, 1, key); | |
| 15192 | 15219 | table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,7 +123,7 @@ TEST(Weakness) { | |||
| 123 | 123 | heap->CollectAllGarbage(false); | |
| 124 | 124 | CHECK_EQ(1, NumberOfWeakCalls); | |
| 125 | 125 | CHECK_EQ(0, ObjectHashTable::cast(weakmap->table())->NumberOfElements()); | |
| 126 | - CHECK_EQ(2, | ||
| 126 | + CHECK_EQ(0, | ||
| 127 | 127 | ObjectHashTable::cast(weakmap->table())->NumberOfDeletedElements()); | |
| 128 | 128 | } | |
| 129 | 129 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,8 +122,8 @@ TEST(WeakSet_Weakness) { | |||
| 122 | 122 | heap->CollectAllGarbage(false); | |
| 123 | 123 | CHECK_EQ(1, NumberOfWeakCalls); | |
| 124 | 124 | CHECK_EQ(0, ObjectHashTable::cast(weakset->table())->NumberOfElements()); | |
| 125 | - CHECK_EQ( | ||
| 126 | - 1, ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); | ||
| 125 | + CHECK_EQ(0, | ||
| 126 | + ObjectHashTable::cast(weakset->table())->NumberOfDeletedElements()); | ||
| 127 | 127 | } | |
| 128 | 128 | ||
| 129 | 129 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments