cppgc: Fix AgeTableTest
The test broke in https://crrev.com/c/3865148 Bug: chromium:1352649 Change-Id: I9857fd359d73a4c1f7d202feba27a3dcf56e23c6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3872275 Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Auto-Submit: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/main@{#82974}
This commit is contained in:
parent
7c79ab6d43
commit
ec5a042e66
@ -2,15 +2,20 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "include/cppgc/internal/caged-heap-local-data.h"
|
#include "include/cppgc/internal/caged-heap-local-data.h"
|
||||||
#include "include/cppgc/internal/caged-heap.h"
|
#include "include/cppgc/internal/caged-heap.h"
|
||||||
|
#include "src/base/logging.h"
|
||||||
|
#include "src/heap/cppgc/heap-page.h"
|
||||||
#include "test/unittests/heap/cppgc/tests.h"
|
#include "test/unittests/heap/cppgc/tests.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
namespace cppgc {
|
namespace cppgc::internal {
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class AgeTableTest : public testing::TestWithHeap {
|
class AgeTableTest : public testing::TestWithHeap {
|
||||||
public:
|
public:
|
||||||
using Age = AgeTable::Age;
|
using Age = AgeTable::Age;
|
||||||
@ -21,19 +26,16 @@ class AgeTableTest : public testing::TestWithHeap {
|
|||||||
: disallow_gc_(GetHeapHandle()),
|
: disallow_gc_(GetHeapHandle()),
|
||||||
age_table_(CagedHeapLocalData::Get().age_table) {}
|
age_table_(CagedHeapLocalData::Get().age_table) {}
|
||||||
|
|
||||||
~AgeTableTest() override {
|
~AgeTableTest() override { age_table_.ResetForTesting(); }
|
||||||
age_table_.ResetForTesting();
|
|
||||||
// Collect all allocated pages.
|
|
||||||
for (auto* page : allocated_pages_) BasePage::Destroy(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
NormalPage* AllocateNormalPage() {
|
NormalPage* AllocateNormalPage() {
|
||||||
RawHeap& heap = Heap::From(GetHeap())->raw_heap();
|
RawHeap& heap = Heap::From(GetHeap())->raw_heap();
|
||||||
auto* space = static_cast<NormalPageSpace*>(
|
auto* space = static_cast<NormalPageSpace*>(
|
||||||
heap.Space(RawHeap::RegularSpaceType::kNormal1));
|
heap.Space(RawHeap::RegularSpaceType::kNormal1));
|
||||||
auto* page =
|
auto* page =
|
||||||
NormalPage::Create(*Heap::From(GetHeap())->page_backend(), *space);
|
NormalPage::TryCreate(*Heap::From(GetHeap())->page_backend(), *space);
|
||||||
allocated_pages_.push_back(page);
|
CHECK_NOT_NULL(page);
|
||||||
|
allocated_pages_.push_back({page, &BasePage::Destroy});
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,9 +44,10 @@ class AgeTableTest : public testing::TestWithHeap {
|
|||||||
RawHeap& heap = Heap::From(GetHeap())->raw_heap();
|
RawHeap& heap = Heap::From(GetHeap())->raw_heap();
|
||||||
auto* space = static_cast<LargePageSpace*>(
|
auto* space = static_cast<LargePageSpace*>(
|
||||||
heap.Space(RawHeap::RegularSpaceType::kLarge));
|
heap.Space(RawHeap::RegularSpaceType::kLarge));
|
||||||
auto* page = LargePage::Create(*Heap::From(GetHeap())->page_backend(),
|
auto* page = LargePage::TryCreate(*Heap::From(GetHeap())->page_backend(),
|
||||||
*space, kObjectSize);
|
*space, kObjectSize);
|
||||||
allocated_pages_.push_back(page);
|
CHECK_NOT_NULL(page);
|
||||||
|
allocated_pages_.push_back({page, &BasePage::Destroy});
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +77,7 @@ class AgeTableTest : public testing::TestWithHeap {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
subtle::DisallowGarbageCollectionScope disallow_gc_;
|
subtle::DisallowGarbageCollectionScope disallow_gc_;
|
||||||
std::vector<BasePage*> allocated_pages_;
|
std::vector<std::unique_ptr<BasePage, void (*)(BasePage*)>> allocated_pages_;
|
||||||
AgeTable& age_table_;
|
AgeTable& age_table_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -205,5 +208,4 @@ TEST_F(AgeTableTest, MarkAllCardsAsYoung) {
|
|||||||
AssertAgeForAddressRange(heap_start, heap_end, Age::kYoung);
|
AssertAgeForAddressRange(heap_start, heap_end, Age::kYoung);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace cppgc::internal
|
||||||
} // namespace cppgc
|
|
||||||
|
Loading…
Reference in New Issue
Block a user