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

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

Issue 1877233005: Rehash and clear deleted entries in weak collections during GC (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 | « no previous file | 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 if ((table->NumberOfDeletedElements() << 1) > table->NumberOfElements()) {
Hannes Payer (out of office) 2016/04/15 08:20:11 Can you make that a constant?
jochen (gone - plz use gerrit) 2016/04/15 08:21:28 which one do you propose?
2555 HandleScope scope(heap()->isolate());
2556 table->Rehash(heap()->isolate()->factory()->undefined_value());
2557 }
2553 } 2558 }
2554 weak_collection_obj = weak_collection->next(); 2559 weak_collection_obj = weak_collection->next();
2555 weak_collection->set_next(heap()->undefined_value()); 2560 weak_collection->set_next(heap()->undefined_value());
2556 } 2561 }
2557 heap()->set_encountered_weak_collections(Smi::FromInt(0)); 2562 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2558 } 2563 }
2559 2564
2560 2565
2561 void MarkCompactCollector::AbortWeakCollections() { 2566 void MarkCompactCollector::AbortWeakCollections() {
2562 Object* weak_collection_obj = heap()->encountered_weak_collections(); 2567 Object* weak_collection_obj = heap()->encountered_weak_collections();
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 MarkBit mark_bit = Marking::MarkBitFrom(host); 3901 MarkBit mark_bit = Marking::MarkBitFrom(host);
3897 if (Marking::IsBlack(mark_bit)) { 3902 if (Marking::IsBlack(mark_bit)) {
3898 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3903 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3899 RecordRelocSlot(host, &rinfo, target); 3904 RecordRelocSlot(host, &rinfo, target);
3900 } 3905 }
3901 } 3906 }
3902 } 3907 }
3903 3908
3904 } // namespace internal 3909 } // namespace internal
3905 } // namespace v8 3910 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698