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

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

Issue 1783313003: [heap] Use struct Entry to fill inlined promotion queue entries. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 return false; 1554 return false;
1555 } 1555 }
1556 1556
1557 1557
1558 void PromotionQueue::Initialize() { 1558 void PromotionQueue::Initialize() {
1559 // The last to-space page may be used for promotion queue. On promotion 1559 // The last to-space page may be used for promotion queue. On promotion
1560 // conflict, we use the emergency stack. 1560 // conflict, we use the emergency stack.
1561 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == 1561 DCHECK((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) ==
1562 0); 1562 0);
1563 front_ = rear_ = 1563 front_ = rear_ =
1564 reinterpret_cast<intptr_t*>(heap_->new_space()->ToSpaceEnd()); 1564 reinterpret_cast<struct Entry*>(heap_->new_space()->ToSpaceEnd());
1565 limit_ = reinterpret_cast<intptr_t*>( 1565 limit_ = reinterpret_cast<struct Entry*>(
1566 Page::FromAllocationTop(reinterpret_cast<Address>(rear_))->area_start()); 1566 Page::FromAllocationTop(reinterpret_cast<Address>(rear_))->area_start());
1567 emergency_stack_ = NULL; 1567 emergency_stack_ = NULL;
1568 } 1568 }
1569 1569
1570 1570
1571 void PromotionQueue::RelocateQueueHead() { 1571 void PromotionQueue::RelocateQueueHead() {
1572 DCHECK(emergency_stack_ == NULL); 1572 DCHECK(emergency_stack_ == NULL);
1573 1573
1574 Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_)); 1574 Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_));
1575 intptr_t* head_start = rear_; 1575 struct Entry* head_start = rear_;
1576 intptr_t* head_end = Min(front_, reinterpret_cast<intptr_t*>(p->area_end())); 1576 struct Entry* head_end =
1577 Min(front_, reinterpret_cast<struct Entry*>(p->area_end()));
1577 1578
1578 int entries_count = 1579 int entries_count =
1579 static_cast<int>(head_end - head_start) / kEntrySizeInWords; 1580 static_cast<int>(head_end - head_start) / kEntrySizeInWords;
1580 1581
1581 emergency_stack_ = new List<Entry>(2 * entries_count); 1582 emergency_stack_ = new List<Entry>(2 * entries_count);
1582 1583
1583 while (head_start != head_end) { 1584 while (head_start != head_end) {
1584 int size = static_cast<int>(*(head_start++)); 1585 struct Entry* entry = head_start++;
1585 HeapObject* obj = reinterpret_cast<HeapObject*>(*(head_start++));
1586 // New space allocation in SemiSpaceCopyObject marked the region 1586 // New space allocation in SemiSpaceCopyObject marked the region
1587 // overlapping with promotion queue as uninitialized. 1587 // overlapping with promotion queue as uninitialized.
1588 MSAN_MEMORY_IS_INITIALIZED(&size, sizeof(size)); 1588 MSAN_MEMORY_IS_INITIALIZED(&entry->size_, sizeof(size));
1589 MSAN_MEMORY_IS_INITIALIZED(&obj, sizeof(obj)); 1589 MSAN_MEMORY_IS_INITIALIZED(&entry->obj_, sizeof(obj));
1590 emergency_stack_->Add(Entry(obj, size)); 1590 emergency_stack_->Add(*entry);
1591 } 1591 }
1592 rear_ = head_end; 1592 rear_ = head_end;
1593 } 1593 }
1594 1594
1595 1595
1596 class ScavengeWeakObjectRetainer : public WeakObjectRetainer { 1596 class ScavengeWeakObjectRetainer : public WeakObjectRetainer {
1597 public: 1597 public:
1598 explicit ScavengeWeakObjectRetainer(Heap* heap) : heap_(heap) {} 1598 explicit ScavengeWeakObjectRetainer(Heap* heap) : heap_(heap) {}
1599 1599
1600 virtual Object* RetainAs(Object* object) { 1600 virtual Object* RetainAs(Object* object) {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 } else { 1938 } else {
1939 new_space_front = 1939 new_space_front =
1940 NewSpacePage::FromLimit(new_space_front)->next_page()->area_start(); 1940 NewSpacePage::FromLimit(new_space_front)->next_page()->area_start();
1941 } 1941 }
1942 } 1942 }
1943 1943
1944 // Promote and process all the to-be-promoted objects. 1944 // Promote and process all the to-be-promoted objects.
1945 { 1945 {
1946 while (!promotion_queue()->is_empty()) { 1946 while (!promotion_queue()->is_empty()) {
1947 HeapObject* target; 1947 HeapObject* target;
1948 int size; 1948 intptr_t size;
1949 promotion_queue()->remove(&target, &size); 1949 promotion_queue()->remove(&target, &size);
1950 1950
1951 // Promoted object might be already partially visited 1951 // Promoted object might be already partially visited
1952 // during old space pointer iteration. Thus we search specifically 1952 // during old space pointer iteration. Thus we search specifically
1953 // for pointers to from semispace instead of looking for pointers 1953 // for pointers to from semispace instead of looking for pointers
1954 // to new space. 1954 // to new space.
1955 DCHECK(!target->IsMap()); 1955 DCHECK(!target->IsMap());
1956 1956
1957 IteratePointersToFromSpace(target, size, &Scavenger::ScavengeObject); 1957 IteratePointersToFromSpace(target, static_cast<int>(size),
1958 &Scavenger::ScavengeObject);
1958 } 1959 }
1959 } 1960 }
1960 1961
1961 // Take another spin if there are now unswept objects in new space 1962 // Take another spin if there are now unswept objects in new space
1962 // (there are currently no more unswept promoted objects). 1963 // (there are currently no more unswept promoted objects).
1963 } while (new_space_front != new_space_.top()); 1964 } while (new_space_front != new_space_.top());
1964 1965
1965 return new_space_front; 1966 return new_space_front;
1966 } 1967 }
1967 1968
(...skipping 4381 matching lines...) Expand 10 before | Expand all | Expand 10 after
6349 } 6350 }
6350 6351
6351 6352
6352 // static 6353 // static
6353 int Heap::GetStaticVisitorIdForMap(Map* map) { 6354 int Heap::GetStaticVisitorIdForMap(Map* map) {
6354 return StaticVisitorBase::GetVisitorId(map); 6355 return StaticVisitorBase::GetVisitorId(map);
6355 } 6356 }
6356 6357
6357 } // namespace internal 6358 } // namespace internal
6358 } // namespace v8 6359 } // 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