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

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: Addressed comments Created 4 years, 7 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"
(...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::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_))
1556 ->area_start());
1556 emergency_stack_ = NULL; 1557 emergency_stack_ = NULL;
1557 } 1558 }
1558 1559
1559 1560
1560 void PromotionQueue::RelocateQueueHead() { 1561 void PromotionQueue::RelocateQueueHead() {
1561 DCHECK(emergency_stack_ == NULL); 1562 DCHECK(emergency_stack_ == NULL);
1562 1563
1563 Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_)); 1564 Page* p = Page::FromAllocationAreaAddress(reinterpret_cast<Address>(rear_));
1564 struct Entry* head_start = rear_; 1565 struct Entry* head_start = rear_;
1565 struct Entry* head_end = 1566 struct Entry* head_end =
1566 Min(front_, reinterpret_cast<struct Entry*>(p->area_end())); 1567 Min(front_, reinterpret_cast<struct Entry*>(p->area_end()));
1567 1568
1568 int entries_count = 1569 int entries_count =
1569 static_cast<int>(head_end - head_start) / sizeof(struct Entry); 1570 static_cast<int>(head_end - head_start) / sizeof(struct Entry);
1570 1571
1571 emergency_stack_ = new List<Entry>(2 * entries_count); 1572 emergency_stack_ = new List<Entry>(2 * entries_count);
1572 1573
1573 while (head_start != head_end) { 1574 while (head_start != head_end) {
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1903
1903 1904
1904 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, 1905 Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor,
1905 Address new_space_front) { 1906 Address new_space_front) {
1906 do { 1907 do {
1907 SemiSpace::AssertValidRange(new_space_front, new_space_.top()); 1908 SemiSpace::AssertValidRange(new_space_front, new_space_.top());
1908 // The addresses new_space_front and new_space_.top() define a 1909 // The addresses new_space_front and new_space_.top() define a
1909 // queue of unprocessed copied objects. Process them until the 1910 // queue of unprocessed copied objects. Process them until the
1910 // queue is empty. 1911 // queue is empty.
1911 while (new_space_front != new_space_.top()) { 1912 while (new_space_front != new_space_.top()) {
1912 if (!NewSpacePage::IsAtEnd(new_space_front)) { 1913 if (!Page::IsAlignedToPageSize(new_space_front)) {
1913 HeapObject* object = HeapObject::FromAddress(new_space_front); 1914 HeapObject* object = HeapObject::FromAddress(new_space_front);
1914 new_space_front += 1915 new_space_front +=
1915 StaticScavengeVisitor::IterateBody(object->map(), object); 1916 StaticScavengeVisitor::IterateBody(object->map(), object);
1916 } else { 1917 } else {
1917 new_space_front = 1918 new_space_front = Page::FromAllocationAreaAddress(new_space_front)
1918 NewSpacePage::FromLimit(new_space_front)->next_page()->area_start(); 1919 ->next_page()
1920 ->area_start();
1919 } 1921 }
1920 } 1922 }
1921 1923
1922 // Promote and process all the to-be-promoted objects. 1924 // Promote and process all the to-be-promoted objects.
1923 { 1925 {
1924 while (!promotion_queue()->is_empty()) { 1926 while (!promotion_queue()->is_empty()) {
1925 HeapObject* target; 1927 HeapObject* target;
1926 int32_t size; 1928 int32_t size;
1927 bool was_marked_black; 1929 bool was_marked_black;
1928 promotion_queue()->remove(&target, &size, &was_marked_black); 1930 promotion_queue()->remove(&target, &size, &was_marked_black);
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after
4626 } 4628 }
4627 } 4629 }
4628 #endif 4630 #endif
4629 4631
4630 4632
4631 void Heap::ZapFromSpace() { 4633 void Heap::ZapFromSpace() {
4632 if (!new_space_.IsFromSpaceCommitted()) return; 4634 if (!new_space_.IsFromSpaceCommitted()) return;
4633 NewSpacePageIterator it(new_space_.FromSpaceStart(), 4635 NewSpacePageIterator it(new_space_.FromSpaceStart(),
4634 new_space_.FromSpaceEnd()); 4636 new_space_.FromSpaceEnd());
4635 while (it.has_next()) { 4637 while (it.has_next()) {
4636 NewSpacePage* page = it.next(); 4638 Page* page = it.next();
4637 for (Address cursor = page->area_start(), limit = page->area_end(); 4639 for (Address cursor = page->area_start(), limit = page->area_end();
4638 cursor < limit; cursor += kPointerSize) { 4640 cursor < limit; cursor += kPointerSize) {
4639 Memory::Address_at(cursor) = kFromSpaceZapValue; 4641 Memory::Address_at(cursor) = kFromSpaceZapValue;
4640 } 4642 }
4641 } 4643 }
4642 } 4644 }
4643 4645
4644 void Heap::IteratePromotedObjectPointers(HeapObject* object, Address start, 4646 void Heap::IteratePromotedObjectPointers(HeapObject* object, Address start,
4645 Address end, bool record_slots, 4647 Address end, bool record_slots,
4646 ObjectSlotCallback callback) { 4648 ObjectSlotCallback callback) {
(...skipping 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
6425 } 6427 }
6426 6428
6427 6429
6428 // static 6430 // static
6429 int Heap::GetStaticVisitorIdForMap(Map* map) { 6431 int Heap::GetStaticVisitorIdForMap(Map* map) {
6430 return StaticVisitorBase::GetVisitorId(map); 6432 return StaticVisitorBase::GetVisitorId(map);
6431 } 6433 }
6432 6434
6433 } // namespace internal 6435 } // namespace internal
6434 } // namespace v8 6436 } // 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