Commit 856124c7 authored by Omer Katz's avatar Omer Katz Committed by V8 LUCI CQ

[heap] Move use_lab_ to LinearAllocationArea

The new PagedNewSpace composes a PagedSpaceBase subclass
(PagedSpaceForNewSpace) to avoid a diamond inheritance since both
PagedSpaceBase and NewSpace inherit from SpaceWithLinearArea.
Both use the same LinearAllocationArea, LinearAreaOriginalData, and
AllocationCounter, but use_lab_ remained a field of SpaceWithLinearArea.
As a result, disabling inline allocations for new space only updated one
of the use_lab_ instances (the one in PagedNewSpace) while allocations
were using the other.
Moving this field to LinearAllocationArea lets both use the same field
and keep in sync.

Bug: v8:12612
Change-Id: I47eccc6444040efc3a3e5d93f6015fd2bdb611b1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3820065Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82315}
parent a217f66b
...@@ -102,7 +102,10 @@ class LinearAllocationArea final { ...@@ -102,7 +102,10 @@ class LinearAllocationArea final {
#endif // DEBUG #endif // DEBUG
} }
static constexpr int kSize = 3 * kSystemPointerSize; static constexpr int kSize = 4 * kSystemPointerSize;
bool enabled() const { return enabled_; }
void SetEnabled(bool enabled) { enabled_ = enabled; }
private: private:
// The start of the LAB. Initially coincides with `top_`. As top is moved // The start of the LAB. Initially coincides with `top_`. As top is moved
...@@ -113,9 +116,11 @@ class LinearAllocationArea final { ...@@ -113,9 +116,11 @@ class LinearAllocationArea final {
Address top_ = kNullAddress; Address top_ = kNullAddress;
// Limit of the LAB the denotes the end of the valid range for allocation. // Limit of the LAB the denotes the end of the valid range for allocation.
Address limit_ = kNullAddress; Address limit_ = kNullAddress;
bool enabled_ = true;
}; };
static_assert(sizeof(LinearAllocationArea) == LinearAllocationArea::kSize, static_assert(sizeof(LinearAllocationArea) <= LinearAllocationArea::kSize,
"LinearAllocationArea's size must be small because it " "LinearAllocationArea's size must be small because it "
"is included in IsolateData."); "is included in IsolateData.");
......
...@@ -239,7 +239,7 @@ Address SpaceWithLinearArea::ComputeLimit(Address start, Address end, ...@@ -239,7 +239,7 @@ Address SpaceWithLinearArea::ComputeLimit(Address start, Address end,
size_t min_size) const { size_t min_size) const {
DCHECK_GE(end - start, min_size); DCHECK_GE(end - start, min_size);
if (!use_lab_) { if (!allocation_info_.enabled()) {
// LABs are disabled, so we fit the requested area exactly. // LABs are disabled, so we fit the requested area exactly.
return start + min_size; return start + min_size;
} }
...@@ -267,17 +267,17 @@ Address SpaceWithLinearArea::ComputeLimit(Address start, Address end, ...@@ -267,17 +267,17 @@ Address SpaceWithLinearArea::ComputeLimit(Address start, Address end,
} }
void SpaceWithLinearArea::DisableInlineAllocation() { void SpaceWithLinearArea::DisableInlineAllocation() {
if (!use_lab_) return; if (!allocation_info_.enabled()) return;
use_lab_ = false; allocation_info_.SetEnabled(false);
FreeLinearAllocationArea(); FreeLinearAllocationArea();
UpdateInlineAllocationLimit(0); UpdateInlineAllocationLimit(0);
} }
void SpaceWithLinearArea::EnableInlineAllocation() { void SpaceWithLinearArea::EnableInlineAllocation() {
if (use_lab_) return; if (allocation_info_.enabled()) return;
use_lab_ = true; allocation_info_.SetEnabled(true);
AdvanceAllocationObservers(); AdvanceAllocationObservers();
UpdateInlineAllocationLimit(0); UpdateInlineAllocationLimit(0);
} }
......
...@@ -561,7 +561,7 @@ class SpaceWithLinearArea : public Space { ...@@ -561,7 +561,7 @@ class SpaceWithLinearArea : public Space {
void DisableInlineAllocation(); void DisableInlineAllocation();
void EnableInlineAllocation(); void EnableInlineAllocation();
bool IsInlineAllocationEnabled() const { return use_lab_; } bool IsInlineAllocationEnabled() const { return allocation_info_.enabled(); }
void PrintAllocationsOrigins() const; void PrintAllocationsOrigins() const;
...@@ -635,8 +635,6 @@ class SpaceWithLinearArea : public Space { ...@@ -635,8 +635,6 @@ class SpaceWithLinearArea : public Space {
LinearAllocationArea& allocation_info_; LinearAllocationArea& allocation_info_;
LinearAreaOriginalData& linear_area_original_data_; LinearAreaOriginalData& linear_area_original_data_;
bool use_lab_ = true;
size_t allocations_origins_[static_cast<int>( size_t allocations_origins_[static_cast<int>(
AllocationOrigin::kNumberOfAllocationOrigins)] = {0}; AllocationOrigin::kNumberOfAllocationOrigins)] = {0};
}; };
......
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