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() {
Page* current_page = page;
page = page->next_page();
if (current_page->allocated_bytes() == 0) {
memory_chunk_list().Remove(current_page);
ReleasePage(current_page);
}
}
......@@ -981,8 +982,9 @@ void PagedSpaceForNewSpace::ReleasePage(Page* page) {
}
bool PagedSpaceForNewSpace::AddFreshPage() {
if (TotalCapacity() >= MaximumCapacity()) return false;
return TryExpandImpl();
DCHECK_LE(TotalCapacity(), MaximumCapacity());
if (current_capacity_ >= target_capacity_) return false;
return EnsureCurrentCapacity();
}
bool PagedSpaceForNewSpace::EnsureCurrentCapacity() {
......@@ -1035,7 +1037,7 @@ PagedNewSpace::~PagedNewSpace() {
void PagedNewSpace::Verify(Isolate* isolate) const {
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.
VerifyPointersVisitor visitor(heap());
......
......@@ -584,7 +584,7 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase {
// Reset the allocation pointer.
void EvacuatePrologue();
void EvacuateEpilogue() {}
void EvacuateEpilogue() { allocated_linear_areas_ = 0; }
// When inline allocation stepping is active, either because of incremental
// marking, idle scavenge, or allocation statistics gathering, we 'interrupt'
......@@ -613,6 +613,12 @@ class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase {
void RemovePage(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
void Verify(Isolate* isolate, ObjectVisitor* visitor) const final;
#endif
......@@ -681,12 +687,9 @@ class V8_EXPORT_PRIVATE PagedNewSpace final : public NewSpace {
}
// Return the available bytes without growing.
// TODO(v8:12612): Rethink this method. In SemiSpaceNewSpace available memory
// was contiguous memory. With PagedNewSpace it is the sum of blocks in the
// 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 Available() const final {
return paged_space_.Available() + limit() - top();
}
size_t ExternalBackingStoreBytes(ExternalBackingStoreType type) const final {
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