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

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

Issue 1900423002: [heap] Merge NewSpacePage into Page (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix after rebase 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
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"
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 } 938 }
939 } 939 }
940 940
941 941
942 void Heap::EnsureFillerObjectAtTop() { 942 void Heap::EnsureFillerObjectAtTop() {
943 // There may be an allocation memento behind objects in new space. Upon 943 // There may be an allocation memento behind objects in new space. Upon
944 // evacuation of a non-full new space (or if we are on the last page) there 944 // evacuation of a non-full new space (or if we are on the last page) there
945 // may be uninitialized memory behind top. We fill the remainder of the page 945 // may be uninitialized memory behind top. We fill the remainder of the page
946 // with a filler. 946 // with a filler.
947 Address to_top = new_space_.top(); 947 Address to_top = new_space_.top();
948 NewSpacePage* page = NewSpacePage::FromAddress(to_top - kPointerSize); 948 Page* page = Page::FromAddress(to_top - kPointerSize);
949 if (page->Contains(to_top)) { 949 if (page->Contains(to_top)) {
950 int remaining_in_page = static_cast<int>(page->area_end() - to_top); 950 int remaining_in_page = static_cast<int>(page->area_end() - to_top);
951 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo); 951 CreateFillerObjectAt(to_top, remaining_in_page, ClearRecordedSlots::kNo);
952 } 952 }
953 } 953 }
954 954
955 955
956 bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason, 956 bool Heap::CollectGarbage(GarbageCollector collector, const char* gc_reason,
957 const char* collector_reason, 957 const char* collector_reason,
958 const v8::GCCallbackFlags gc_callback_flags) { 958 const v8::GCCallbackFlags gc_callback_flags) {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 1545
1546 1546
1547 void PromotionQueue::Initialize() { 1547 void PromotionQueue::Initialize() {
1548 // The last to-space page may be used for promotion queue. On promotion 1548 // The last to-space page may be used for promotion queue. On promotion
1549 // conflict, we use the emergency stack. 1549 // conflict, we use the emergency stack.
1550 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == 1550 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) ==
1551 0); 1551 0);
1552 front_ = rear_ = 1552 front_ = rear_ =
1553 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd()); 1553 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd());
1554 limit_ = reinterpret_cast<struct Entry*>( 1554 limit_ = reinterpret_cast<struct Entry*>(
1555 Page::FromAllocationTop(reinterpret_cast<Address>(rear_))->area_start()); 1555 Page::FromTopOrLimit(reinterpret_cast<Address>(rear_))->area_start());
1556 emergency_stack_ = NULL; 1556 emergency_stack_ = NULL;
1557 } 1557 }
1558 1558
1559 1559
1560 void PromotionQueue::RelocateQueueHead() { 1560 void PromotionQueue::RelocateQueueHead() {
1561 DCHECK(emergency_stack_ == NULL); 1561 DCHECK(emergency_stack_ == NULL);
1562 1562
1563 Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_)); 1563 Page* p = Page::FromTopOrLimit(reinterpret_cast<Address>(rear_));
1564 struct Entry* head_start = rear_; 1564 struct Entry* head_start = rear_;
1565 struct Entry* head_end = 1565 struct Entry* head_end =
1566 Min(front_, reinterpret_cast<struct Entry*>(p->area_end())); 1566 Min(front_, reinterpret_cast<struct Entry*>(p->area_end()));
1567 1567
1568 int entries_count = 1568 int entries_count =
1569 static_cast<int>(head_end - head_start) / sizeof(struct Entry); 1569 static_cast<int>(head_end - head_start) / sizeof(struct Entry);
1570 1570
1571 emergency_stack_ = new List<Entry>(2 * entries_count); 1571 emergency_stack_ = new List<Entry>(2 * entries_count);
1572 1572
1573 while (head_start != head_end) { 1573 while (head_start != head_end) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1902
1903 1903
1904 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, 1904 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor,
1905 Address new_space_front) { 1905 Address new_space_front) {
1906 do { 1906 do {
1907 SemiSpace::AssertValidRange(new_space_front, new_space_.top()); 1907 SemiSpace::AssertValidRange(new_space_front, new_space_.top());
1908 // The addresses new_space_front and new_space_.top() define a 1908 // The addresses new_space_front and new_space_.top() define a
1909 // queue of unprocessed copied objects. Process them until the 1909 // queue of unprocessed copied objects. Process them until the
1910 // queue is empty. 1910 // queue is empty.
1911 while (new_space_front != new_space_.top()) { 1911 while (new_space_front != new_space_.top()) {
1912 if (!NewSpacePage::IsAtEnd(new_space_front)) { 1912 if (!Page::IsAtEnd(new_space_front)) {
1913 HeapObject* object = HeapObject::FromAddress(new_space_front); 1913 HeapObject* object = HeapObject::FromAddress(new_space_front);
1914 new_space_front += 1914 new_space_front +=
1915 StaticScavengeVisitor::IterateBody(object->map(), object); 1915 StaticScavengeVisitor::IterateBody(object->map(), object);
1916 } else { 1916 } else {
1917 new_space_front = 1917 new_space_front =
1918 NewSpacePage::FromLimit(new_space_front)->next_page()->area_start(); 1918 Page::FromTopOrLimit(new_space_front)->next_page()->area_start();
1919 } 1919 }
1920 } 1920 }
1921 1921
1922 // Promote and process all the to-be-promoted objects. 1922 // Promote and process all the to-be-promoted objects.
1923 { 1923 {
1924 while (!promotion_queue()->is_empty()) { 1924 while (!promotion_queue()->is_empty()) {
1925 HeapObject* target; 1925 HeapObject* target;
1926 int32_t size; 1926 int32_t size;
1927 bool was_marked_black; 1927 bool was_marked_black;
1928 promotion_queue()->remove(&target, &size, &was_marked_black); 1928 promotion_queue()->remove(&target, &size, &was_marked_black);
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4626 } 4626 }
4627 } 4627 }
4628 #endif 4628 #endif
4629 4629
4630 4630
4631 void Heap::ZapFromSpace() { 4631 void Heap::ZapFromSpace() {
4632 if (!new_space_.IsFromSpaceCommitted()) return; 4632 if (!new_space_.IsFromSpaceCommitted()) return;
4633 NewSpacePageIterator it(new_space_.FromSpaceStart(), 4633 NewSpacePageIterator it(new_space_.FromSpaceStart(),
4634 new_space_.FromSpaceEnd()); 4634 new_space_.FromSpaceEnd());
4635 while (it.has_next()) { 4635 while (it.has_next()) {
4636 NewSpacePage* page = it.next(); 4636 Page* page = it.next();
4637 for (Address cursor = page->area_start(), limit = page->area_end(); 4637 for (Address cursor = page->area_start(), limit = page->area_end();
4638 cursor < limit; cursor += kPointerSize) { 4638 cursor < limit; cursor += kPointerSize) {
4639 Memory::Address_at(cursor) = kFromSpaceZapValue; 4639 Memory::Address_at(cursor) = kFromSpaceZapValue;
4640 } 4640 }
4641 } 4641 }
4642 } 4642 }
4643 4643
4644 void Heap::IteratePromotedObjectPointers(HeapObject* object, Address start, 4644 void Heap::IteratePromotedObjectPointers(HeapObject* object, Address start,
4645 Address end, bool record_slots, 4645 Address end, bool record_slots,
4646 ObjectSlotCallback callback) { 4646 ObjectSlotCallback callback) {
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 } 6425 }
6426 6426
6427 6427
6428 // static 6428 // static
6429 int Heap::GetStaticVisitorIdForMap(Map* map) { 6429 int Heap::GetStaticVisitorIdForMap(Map* map) {
6430 return StaticVisitorBase::GetVisitorId(map); 6430 return StaticVisitorBase::GetVisitorId(map);
6431 } 6431 }
6432 6432
6433 } // namespace internal 6433 } // namespace internal
6434 } // namespace v8 6434 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/heap-inl.h » ('j') | src/heap/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698