Commit 6d5f9030 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Some small PagedNewSpace fixes

Bug: v8:12612
Change-Id: Ibd20ba65e81b86239e254b945c4c6c9c6137b714
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3822687
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82354}
parent 4ae65ade
...@@ -948,6 +948,7 @@ void PagedSpaceForNewSpace::Shrink() { ...@@ -948,6 +948,7 @@ void PagedSpaceForNewSpace::Shrink() {
Page* current_page = page; Page* current_page = page;
page = page->next_page(); page = page->next_page();
if (current_page->allocated_bytes() == 0) { if (current_page->allocated_bytes() == 0) {
memory_chunk_list().Remove(current_page);
ReleasePage(current_page); ReleasePage(current_page);
} }
} }
...@@ -981,8 +982,9 @@ void PagedSpaceForNewSpace::ReleasePage(Page* page) { ...@@ -981,8 +982,9 @@ void PagedSpaceForNewSpace::ReleasePage(Page* page) {
} }
bool PagedSpaceForNewSpace::AddFreshPage() { bool PagedSpaceForNewSpace::AddFreshPage() {
if (TotalCapacity() >= MaximumCapacity()) return false; DCHECK_LE(TotalCapacity(), MaximumCapacity());
return TryExpandImpl(); if (current_capacity_ >= target_capacity_) return false;
return EnsureCurrentCapacity();
} }
bool PagedSpaceForNewSpace::EnsureCurrentCapacity() { bool PagedSpaceForNewSpace::EnsureCurrentCapacity() {
...@@ -1035,7 +1037,7 @@ PagedNewSpace::~PagedNewSpace() { ...@@ -1035,7 +1037,7 @@ PagedNewSpace::~PagedNewSpace() {
void PagedNewSpace::Verify(Isolate* isolate) const { void PagedNewSpace::Verify(Isolate* isolate) const {
const Page* first_page = paged_space_.first_page(); const Page* first_page = paged_space_.first_page();
VerifyImpl(isolate, first_page, first_page->area_start()); if (first_page) VerifyImpl(isolate, first_page, first_page->area_start());
// Check paged-spaces. // Check paged-spaces.
VerifyPointersVisitor visitor(heap()); VerifyPointersVisitor visitor(heap());
......
...@@ -584,7 +584,7 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { ...@@ -584,7 +584,7 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase {
// Reset the allocation pointer. // Reset the allocation pointer.
void EvacuatePrologue(); void EvacuatePrologue();
void EvacuateEpilogue() {} void EvacuateEpilogue() { allocated_linear_areas_ = 0; }
// When inline allocation stepping is active, either because of incremental // When inline allocation stepping is active, either because of incremental
// marking, idle scavenge, or allocation statistics gathering, we 'interrupt' // marking, idle scavenge, or allocation statistics gathering, we 'interrupt'
...@@ -613,6 +613,12 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { ...@@ -613,6 +613,12 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase {
void RemovePage(Page* page) final; void RemovePage(Page* page) final;
void ReleasePage(Page* page) final; void ReleasePage(Page* page) final;
size_t ExternalBackingStoreBytes(ExternalBackingStoreType type) const final {
if (type == ExternalBackingStoreType::kArrayBuffer)
return heap()->YoungArrayBufferBytes();
return external_backing_store_bytes_[type];
}
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
void Verify(Isolate* isolate, ObjectVisitor* visitor) const final; void Verify(Isolate* isolate, ObjectVisitor* visitor) const final;
#endif #endif
...@@ -681,12 +687,9 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace { ...@@ -681,12 +687,9 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace {
} }
// Return the available bytes without growing. // Return the available bytes without growing.
// TODO(v8:12612): Rethink this method. In SemiSpaceNewSpace available memory size_t Available() const final {
// was contiguous memory. With PagedNewSpace it is the sum of blocks in the return paged_space_.Available() + limit() - top();
// freelist. Available() returning X does not guarantee that an object of size }
// lower than X can be allocated without growing as it might still not fit in
// any block in the freelist.
size_t Available() const final { return paged_space_.Available(); }
size_t ExternalBackingStoreBytes(ExternalBackingStoreType type) const final { size_t ExternalBackingStoreBytes(ExternalBackingStoreType type) const final {
return paged_space_.ExternalBackingStoreBytes(type); return paged_space_.ExternalBackingStoreBytes(type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment