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

Side by Side Diff: src/heap/heap.cc

Issue 1683653002: Add a generic remembered set class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/heap.h ('k') | src/heap/heap-inl.h » ('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/heap.h" 5 #include "src/heap/heap.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
11 #include "src/base/once.h" 11 #include "src/base/once.h"
12 #include "src/base/utils/random-number-generator.h" 12 #include "src/base/utils/random-number-generator.h"
13 #include "src/bootstrapper.h" 13 #include "src/bootstrapper.h"
14 #include "src/codegen.h" 14 #include "src/codegen.h"
15 #include "src/compilation-cache.h" 15 #include "src/compilation-cache.h"
16 #include "src/conversions.h" 16 #include "src/conversions.h"
17 #include "src/debug/debug.h" 17 #include "src/debug/debug.h"
18 #include "src/deoptimizer.h" 18 #include "src/deoptimizer.h"
19 #include "src/global-handles.h" 19 #include "src/global-handles.h"
20 #include "src/heap/array-buffer-tracker.h" 20 #include "src/heap/array-buffer-tracker.h"
21 #include "src/heap/gc-idle-time-handler.h" 21 #include "src/heap/gc-idle-time-handler.h"
22 #include "src/heap/gc-tracer.h" 22 #include "src/heap/gc-tracer.h"
23 #include "src/heap/incremental-marking.h" 23 #include "src/heap/incremental-marking.h"
24 #include "src/heap/mark-compact-inl.h" 24 #include "src/heap/mark-compact-inl.h"
25 #include "src/heap/mark-compact.h" 25 #include "src/heap/mark-compact.h"
26 #include "src/heap/memory-reducer.h" 26 #include "src/heap/memory-reducer.h"
27 #include "src/heap/object-stats.h" 27 #include "src/heap/object-stats.h"
28 #include "src/heap/objects-visiting-inl.h" 28 #include "src/heap/objects-visiting-inl.h"
29 #include "src/heap/objects-visiting.h" 29 #include "src/heap/objects-visiting.h"
30 #include "src/heap/remembered-set.h"
30 #include "src/heap/scavenge-job.h" 31 #include "src/heap/scavenge-job.h"
31 #include "src/heap/scavenger-inl.h" 32 #include "src/heap/scavenger-inl.h"
32 #include "src/heap/store-buffer.h" 33 #include "src/heap/store-buffer.h"
33 #include "src/interpreter/interpreter.h" 34 #include "src/interpreter/interpreter.h"
34 #include "src/profiler/cpu-profiler.h" 35 #include "src/profiler/cpu-profiler.h"
35 #include "src/regexp/jsregexp.h" 36 #include "src/regexp/jsregexp.h"
36 #include "src/runtime-profiler.h" 37 #include "src/runtime-profiler.h"
37 #include "src/snapshot/natives.h" 38 #include "src/snapshot/natives.h"
38 #include "src/snapshot/serialize.h" 39 #include "src/snapshot/serialize.h"
39 #include "src/snapshot/snapshot.h" 40 #include "src/snapshot/snapshot.h"
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 isolate()->optimizing_compile_dispatcher()->AgeBufferedOsrJobs(); 456 isolate()->optimizing_compile_dispatcher()->AgeBufferedOsrJobs();
456 } 457 }
457 458
458 if (new_space_.IsAtMaximumCapacity()) { 459 if (new_space_.IsAtMaximumCapacity()) {
459 maximum_size_scavenges_++; 460 maximum_size_scavenges_++;
460 } else { 461 } else {
461 maximum_size_scavenges_ = 0; 462 maximum_size_scavenges_ = 0;
462 } 463 }
463 CheckNewSpaceExpansionCriteria(); 464 CheckNewSpaceExpansionCriteria();
464 UpdateNewSpaceAllocationCounter(); 465 UpdateNewSpaceAllocationCounter();
466 store_buffer()->MoveEntriesToRememberedSet();
465 } 467 }
466 468
467 469
468 intptr_t Heap::SizeOfObjects() { 470 intptr_t Heap::SizeOfObjects() {
469 intptr_t total = 0; 471 intptr_t total = 0;
470 AllSpaces spaces(this); 472 AllSpaces spaces(this);
471 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { 473 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) {
472 total += space->SizeOfObjects(); 474 total += space->SizeOfObjects();
473 } 475 }
474 return total; 476 return total;
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 { 1673 {
1672 // Copy roots. 1674 // Copy roots.
1673 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); 1675 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_ROOTS);
1674 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); 1676 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE);
1675 } 1677 }
1676 1678
1677 { 1679 {
1678 // Copy objects reachable from the old generation. 1680 // Copy objects reachable from the old generation.
1679 GCTracer::Scope gc_scope(tracer(), 1681 GCTracer::Scope gc_scope(tracer(),
1680 GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); 1682 GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS);
1681 store_buffer()->IteratePointersToNewSpace(&Scavenger::ScavengeObject); 1683 RememberedSet<OLD_TO_NEW>::IterateWithWrapper(this,
1684 Scavenger::ScavengeObject);
1682 } 1685 }
1683 1686
1684 { 1687 {
1685 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_WEAK); 1688 GCTracer::Scope gc_scope(tracer(), GCTracer::Scope::SCAVENGER_WEAK);
1686 // Copy objects reachable from the encountered weak collections list. 1689 // Copy objects reachable from the encountered weak collections list.
1687 scavenge_visitor.VisitPointer(&encountered_weak_collections_); 1690 scavenge_visitor.VisitPointer(&encountered_weak_collections_);
1688 // Copy objects reachable from the encountered weak cells. 1691 // Copy objects reachable from the encountered weak cells.
1689 scavenge_visitor.VisitPointer(&encountered_weak_cells_); 1692 scavenge_visitor.VisitPointer(&encountered_weak_cells_);
1690 } 1693 }
1691 1694
(...skipping 2757 matching lines...) Expand 10 before | Expand all | Expand 10 after
4449 return false; 4452 return false;
4450 } 4453 }
4451 } 4454 }
4452 4455
4453 4456
4454 #ifdef VERIFY_HEAP 4457 #ifdef VERIFY_HEAP
4455 void Heap::Verify() { 4458 void Heap::Verify() {
4456 CHECK(HasBeenSetUp()); 4459 CHECK(HasBeenSetUp());
4457 HandleScope scope(isolate()); 4460 HandleScope scope(isolate());
4458 4461
4459 store_buffer()->Verify();
4460
4461 if (mark_compact_collector()->sweeping_in_progress()) { 4462 if (mark_compact_collector()->sweeping_in_progress()) {
4462 // We have to wait here for the sweeper threads to have an iterable heap. 4463 // We have to wait here for the sweeper threads to have an iterable heap.
4463 mark_compact_collector()->EnsureSweepingCompleted(); 4464 mark_compact_collector()->EnsureSweepingCompleted();
4464 } 4465 }
4465 4466
4466 VerifyPointersVisitor visitor; 4467 VerifyPointersVisitor visitor;
4467 IterateRoots(&visitor, VISIT_ONLY_STRONG); 4468 IterateRoots(&visitor, VISIT_ONLY_STRONG);
4468 4469
4469 VerifySmisVisitor smis_visitor; 4470 VerifySmisVisitor smis_visitor;
4470 IterateSmiRoots(&smis_visitor); 4471 IterateSmiRoots(&smis_visitor);
(...skipping 27 matching lines...) Expand all
4498 Memory::Address_at(cursor) = kFromSpaceZapValue; 4499 Memory::Address_at(cursor) = kFromSpaceZapValue;
4499 } 4500 }
4500 } 4501 }
4501 } 4502 }
4502 4503
4503 4504
4504 void Heap::IterateAndMarkPointersToFromSpace(HeapObject* object, Address start, 4505 void Heap::IterateAndMarkPointersToFromSpace(HeapObject* object, Address start,
4505 Address end, bool record_slots, 4506 Address end, bool record_slots,
4506 ObjectSlotCallback callback) { 4507 ObjectSlotCallback callback) {
4507 Address slot_address = start; 4508 Address slot_address = start;
4509 Page* page = Page::FromAddress(start);
4508 4510
4509 while (slot_address < end) { 4511 while (slot_address < end) {
4510 Object** slot = reinterpret_cast<Object**>(slot_address); 4512 Object** slot = reinterpret_cast<Object**>(slot_address);
4511 Object* target = *slot; 4513 Object* target = *slot;
4512 // If the store buffer becomes overfull we mark pages as being exempt from
4513 // the store buffer. These pages are scanned to find pointers that point
4514 // to the new space. In that case we may hit newly promoted objects and
4515 // fix the pointers before the promotion queue gets to them. Thus the 'if'.
4516 if (target->IsHeapObject()) { 4514 if (target->IsHeapObject()) {
4517 if (Heap::InFromSpace(target)) { 4515 if (Heap::InFromSpace(target)) {
4518 callback(reinterpret_cast<HeapObject**>(slot), 4516 callback(reinterpret_cast<HeapObject**>(slot),
4519 HeapObject::cast(target)); 4517 HeapObject::cast(target));
4520 Object* new_target = *slot; 4518 Object* new_target = *slot;
4521 if (InNewSpace(new_target)) { 4519 if (InNewSpace(new_target)) {
4522 SLOW_DCHECK(Heap::InToSpace(new_target)); 4520 SLOW_DCHECK(Heap::InToSpace(new_target));
4523 SLOW_DCHECK(new_target->IsHeapObject()); 4521 SLOW_DCHECK(new_target->IsHeapObject());
4524 store_buffer_.Mark(reinterpret_cast<Address>(slot)); 4522 RememberedSet<OLD_TO_NEW>::Insert(page, slot_address);
4525 } 4523 }
4526 SLOW_DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(new_target)); 4524 SLOW_DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(new_target));
4527 } else if (record_slots && 4525 } else if (record_slots &&
4528 MarkCompactCollector::IsOnEvacuationCandidate(target)) { 4526 MarkCompactCollector::IsOnEvacuationCandidate(target)) {
4529 mark_compact_collector()->RecordSlot(object, slot, target); 4527 mark_compact_collector()->RecordSlot(object, slot, target);
4530 } 4528 }
4531 } 4529 }
4532 slot_address += kPointerSize; 4530 slot_address += kPointerSize;
4533 } 4531 }
4534 } 4532 }
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
5490 }; 5488 };
5491 5489
5492 5490
5493 void Heap::CheckHandleCount() { 5491 void Heap::CheckHandleCount() {
5494 CheckHandleCountVisitor v; 5492 CheckHandleCountVisitor v;
5495 isolate_->handle_scope_implementer()->Iterate(&v); 5493 isolate_->handle_scope_implementer()->Iterate(&v);
5496 } 5494 }
5497 5495
5498 void Heap::ClearRecordedSlot(HeapObject* object, Object** slot) { 5496 void Heap::ClearRecordedSlot(HeapObject* object, Object** slot) {
5499 if (!InNewSpace(object)) { 5497 if (!InNewSpace(object)) {
5500 store_buffer()->Remove(reinterpret_cast<Address>(slot)); 5498 store_buffer()->MoveEntriesToRememberedSet();
5499 Address slot_addr = reinterpret_cast<Address>(slot);
5500 Page* page = Page::FromAddress(slot_addr);
5501 DCHECK_EQ(page->owner()->identity(), OLD_SPACE);
5502 RememberedSet<OLD_TO_NEW>::Remove(page, slot_addr);
5501 } 5503 }
5502 } 5504 }
5503 5505
5504 Space* AllSpaces::next() { 5506 Space* AllSpaces::next() {
5505 switch (counter_++) { 5507 switch (counter_++) {
5506 case NEW_SPACE: 5508 case NEW_SPACE:
5507 return heap_->new_space(); 5509 return heap_->new_space();
5508 case OLD_SPACE: 5510 case OLD_SPACE:
5509 return heap_->old_space(); 5511 return heap_->old_space();
5510 case CODE_SPACE: 5512 case CODE_SPACE:
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
6233 } 6235 }
6234 6236
6235 6237
6236 // static 6238 // static
6237 int Heap::GetStaticVisitorIdForMap(Map* map) { 6239 int Heap::GetStaticVisitorIdForMap(Map* map) {
6238 return StaticVisitorBase::GetVisitorId(map); 6240 return StaticVisitorBase::GetVisitorId(map);
6239 } 6241 }
6240 6242
6241 } // namespace internal 6243 } // namespace internal
6242 } // namespace v8 6244 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698