Commit 95c860b3 authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

cppgc: Polish custom spaces

Bug: chromium:1056170
Change-Id: I778dc23c82e8cfda34559e5e2e7515a73010a9d7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2192656Reviewed-by: 's avatarAnton Bikineev <bikineev@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67700}
parent 125d3630
......@@ -12,8 +12,7 @@ namespace internal {
// static
constexpr size_t RawHeap::kNumberOfRegularSpaces;
RawHeap::RawHeap(Heap* heap, size_t custom_spaces)
: main_heap_(heap), custom_spaces_(custom_spaces) {
RawHeap::RawHeap(Heap* heap, size_t custom_spaces) : main_heap_(heap) {
size_t i = 0;
for (; i < static_cast<size_t>(RegularSpaceType::kLarge); ++i) {
spaces_.push_back(std::make_unique<NormalPageSpace>(this, i));
......
......@@ -30,8 +30,8 @@ class V8_EXPORT_PRIVATE RawHeap final {
//
// Objects of size greater than 2^16 get stored in the large space.
//
// Users can override where objects are allocated via Heap::SpacePolicy and
// force allocation in one of the kUserDefined* spaces.
// Users can override where objects are allocated via cppgc::CustomSpace to
// force allocation in a custom space.
enum class RegularSpaceType : uint8_t {
kNormal1,
kNormal2,
......@@ -60,11 +60,10 @@ class V8_EXPORT_PRIVATE RawHeap final {
iterator custom_end() { return end(); }
size_t size() const { return spaces_.size(); }
size_t custom_spaces() const { return custom_spaces_; }
BaseSpace* Space(RegularSpaceType type) {
const size_t index = static_cast<size_t>(type);
DCHECK_GT(spaces_.size(), index);
DCHECK_GT(kNumberOfRegularSpaces, index);
BaseSpace* space = spaces_[index].get();
DCHECK(space);
return space;
......@@ -83,8 +82,8 @@ class V8_EXPORT_PRIVATE RawHeap final {
return const_cast<RawHeap&>(*this).Space(space_index);
}
size_t SpaceIndexForCustomSpace(CustomSpaceIndex space_index) {
DCHECK_LT(space_index, custom_spaces_);
size_t SpaceIndexForCustomSpace(CustomSpaceIndex space_index) const {
DCHECK_LT(space_index, spaces_.size() - kNumberOfRegularSpaces);
return kNumberOfRegularSpaces + space_index;
}
......@@ -94,7 +93,6 @@ class V8_EXPORT_PRIVATE RawHeap final {
private:
Heap* main_heap_;
Spaces spaces_;
size_t custom_spaces_;
};
} // namespace internal
......
......@@ -24,7 +24,6 @@ namespace {
struct SpaceState {
BaseSpace::Pages unswept_pages;
};
// using SpaceStates = std::array<SpaceState, RawHeap::kMaxNumberOfSpaces>;
using SpaceStates = std::vector<SpaceState>;
bool SweepNormalPage(NormalPage* page) {
......
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