Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1891863003: Revert of Rehash and clear deleted entries in weak collections during GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/heap/mark-compact.h" 5 #include "src/heap/mark-compact.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/base/sys-info.h" 9 #include "src/base/sys-info.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 reinterpret_cast<JSWeakCollection*>(weak_collection_obj); 2543 reinterpret_cast<JSWeakCollection*>(weak_collection_obj);
2544 DCHECK(MarkCompactCollector::IsMarked(weak_collection)); 2544 DCHECK(MarkCompactCollector::IsMarked(weak_collection));
2545 if (weak_collection->table()->IsHashTable()) { 2545 if (weak_collection->table()->IsHashTable()) {
2546 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table()); 2546 ObjectHashTable* table = ObjectHashTable::cast(weak_collection->table());
2547 for (int i = 0; i < table->Capacity(); i++) { 2547 for (int i = 0; i < table->Capacity(); i++) {
2548 HeapObject* key = HeapObject::cast(table->KeyAt(i)); 2548 HeapObject* key = HeapObject::cast(table->KeyAt(i));
2549 if (!MarkCompactCollector::IsMarked(key)) { 2549 if (!MarkCompactCollector::IsMarked(key)) {
2550 table->RemoveEntry(i); 2550 table->RemoveEntry(i);
2551 } 2551 }
2552 } 2552 }
2553 // Rehash if more than 25% of the entries are deleted entries.
2554 // TODO(jochen): Consider to shrink the fixed array in place.
2555 if ((table->NumberOfDeletedElements() << kJSWeakCollectionLoadFactorExp) >
2556 table->NumberOfElements()) {
2557 HandleScope scope(heap()->isolate());
2558 table->Rehash(heap()->isolate()->factory()->undefined_value());
2559 }
2560 } 2553 }
2561 weak_collection_obj = weak_collection->next(); 2554 weak_collection_obj = weak_collection->next();
2562 weak_collection->set_next(heap()->undefined_value()); 2555 weak_collection->set_next(heap()->undefined_value());
2563 } 2556 }
2564 heap()->set_encountered_weak_collections(Smi::FromInt(0)); 2557 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2565 } 2558 }
2566 2559
2567 2560
2568 void MarkCompactCollector::AbortWeakCollections() { 2561 void MarkCompactCollector::AbortWeakCollections() {
2569 Object* weak_collection_obj = heap()->encountered_weak_collections(); 2562 Object* weak_collection_obj = heap()->encountered_weak_collections();
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3903 MarkBit mark_bit = Marking::MarkBitFrom(host); 3896 MarkBit mark_bit = Marking::MarkBitFrom(host);
3904 if (Marking::IsBlack(mark_bit)) { 3897 if (Marking::IsBlack(mark_bit)) {
3905 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3898 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3906 RecordRelocSlot(host, &rinfo, target); 3899 RecordRelocSlot(host, &rinfo, target);
3907 } 3900 }
3908 } 3901 }
3909 } 3902 }
3910 3903
3911 } // namespace internal 3904 } // namespace internal
3912 } // namespace v8 3905 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698