Skip to content

Commit c27dcac

Browse files
committed
Remove IsoSubspace preciseOnly support
https://bugs.webkit.org/show_bug.cgi?id=288101 rdar://145220913 Reviewed by Yusuke Suzuki. It's no longer used and subsumed by PreciseSubspace. Also, add a SubspaceKind enum rather than have a bunch of bools. * Source/JavaScriptCore/heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::CompleteSubspace): * Source/JavaScriptCore/heap/Heap.cpp: * Source/JavaScriptCore/heap/IsoSubspace.cpp: (JSC::IsoSubspace::IsoSubspace): (JSC::IsoSubspace::tryAllocateLowerTierPrecise): (JSC::IsoSubspace::sweepLowerTierPreciseCell): (JSC::IsoSubspace::tryAllocatePreciseOrLowerTierPrecise): Deleted. * Source/JavaScriptCore/heap/IsoSubspace.h: * Source/JavaScriptCore/heap/LocalAllocator.cpp: (JSC::LocalAllocator::allocateSlowCase): * Source/JavaScriptCore/heap/PreciseSubspace.cpp: (JSC::PreciseSubspace::PreciseSubspace): * Source/JavaScriptCore/heap/Subspace.cpp: (JSC::Subspace::Subspace): * Source/JavaScriptCore/heap/Subspace.h: (JSC::Subspace::kind const): (JSC::Subspace::isIsoSubspace const): (JSC::Subspace::isPreciseOnly const): * Source/JavaScriptCore/runtime/JSCell.h: Canonical link: https://commits.webkit.org/290743@main
1 parent a664051 commit c27dcac

9 files changed

Lines changed: 26 additions & 32 deletions

File tree

‎Source/JavaScriptCore/heap/CompleteSubspace.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
namespace JSC {
3838

3939
CompleteSubspace::CompleteSubspace(CString name, JSC::Heap& heap, const HeapCellType& heapCellType, AlignedMemoryAllocator* alignedMemoryAllocator)
40-
: Subspace(name, heap)
40+
: Subspace(SubspaceKind::CompleteSubspace, name, heap)
4141
{
4242
initialize(heapCellType, alignedMemoryAllocator);
4343
}

‎Source/JavaScriptCore/heap/Heap.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class Heap::HeapThread final : public AutomaticThread {
296296
, name ISO_SUBSPACE_INIT(*this, heapCellType, type)
297297

298298
#define INIT_SERVER_STRUCTURE_ISO_SUBSPACE(name, heapCellType, type) \
299-
, name("IsoSubspace" #name, *this, heapCellType, WTF::roundUpToMultipleOf<type::atomSize>(sizeof(type)), type::usePreciseAllocationsOnly, type::numberOfLowerTierPreciseCells, makeUnique<StructureAlignedMemoryAllocator>("Structure"))
299+
, name("IsoSubspace" #name, *this, heapCellType, WTF::roundUpToMultipleOf<type::atomSize>(sizeof(type)), type::numberOfLowerTierPreciseCells, makeUnique<StructureAlignedMemoryAllocator>("Structure"))
300300

301301
Heap::Heap(VM& vm, HeapType heapType)
302302
: m_heapType(heapType)

‎Source/JavaScriptCore/heap/IsoSubspace.cpp‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,15 @@ namespace JSC {
3636

3737
WTF_MAKE_TZONE_ALLOCATED_IMPL(IsoSubspace);
3838

39-
IsoSubspace::IsoSubspace(CString name, JSC::Heap& heap, const HeapCellType& heapCellType, size_t size, bool preciseOnly, uint8_t numberOfLowerTierPreciseCells, std::unique_ptr<IsoMemoryAllocatorBase>&& allocator)
40-
: Subspace(name, heap)
39+
IsoSubspace::IsoSubspace(CString name, JSC::Heap& heap, const HeapCellType& heapCellType, size_t size, uint8_t numberOfLowerTierPreciseCells, std::unique_ptr<IsoMemoryAllocatorBase>&& allocator)
40+
: Subspace(SubspaceKind::IsoSubspace, name, heap)
4141
, m_directory(WTF::roundUpToMultipleOf<MarkedBlock::atomSize>(size))
4242
, m_isoAlignedMemoryAllocator(allocator ? WTFMove(allocator) : makeUnique<IsoAlignedMemoryAllocator>(name))
4343
{
44-
if (preciseOnly)
45-
m_isPreciseOnly = true;
46-
else {
47-
m_remainingLowerTierPreciseCount = numberOfLowerTierPreciseCells;
48-
ASSERT(WTF::roundUpToMultipleOf<MarkedBlock::atomSize>(size) == cellSize());
49-
ASSERT(m_remainingLowerTierPreciseCount <= MarkedBlock::maxNumberOfLowerTierPreciseCells);
50-
}
44+
m_remainingLowerTierPreciseCount = numberOfLowerTierPreciseCells;
45+
ASSERT(WTF::roundUpToMultipleOf<MarkedBlock::atomSize>(size) == cellSize());
46+
ASSERT(m_remainingLowerTierPreciseCount <= MarkedBlock::maxNumberOfLowerTierPreciseCells);
5147

52-
m_isIsoSubspace = true;
5348
initialize(heapCellType, m_isoAlignedMemoryAllocator.get());
5449

5550
Locker locker { m_space.directoryLock() };
@@ -85,7 +80,7 @@ void IsoSubspace::didBeginSweepingToFreeList(MarkedBlock::Handle* block)
8580
});
8681
}
8782

88-
void* IsoSubspace::tryAllocatePreciseOrLowerTierPrecise(size_t size)
83+
void* IsoSubspace::tryAllocateLowerTierPrecise(size_t size)
8984
{
9085
auto revive = [&] (PreciseAllocation* allocation, bool isNewAllocation) {
9186
m_space.registerPreciseAllocation(allocation, isNewAllocation);
@@ -94,11 +89,6 @@ void* IsoSubspace::tryAllocatePreciseOrLowerTierPrecise(size_t size)
9489
return allocation->cell();
9590
};
9691

97-
if (UNLIKELY(m_isPreciseOnly)) {
98-
PreciseAllocation* allocation = PreciseAllocation::tryCreate(m_space.heap(), size, this, 0);
99-
return allocation ? revive(allocation, true) : nullptr;
100-
}
101-
10292
ASSERT_WITH_MESSAGE(cellSize() == size, "non-preciseOnly IsoSubspaces shouldn't have variable size");
10393
if (!m_lowerTierPreciseFreeList.isEmpty()) {
10494
PreciseAllocation* allocation = &*m_lowerTierPreciseFreeList.begin();
@@ -117,7 +107,6 @@ void* IsoSubspace::tryAllocatePreciseOrLowerTierPrecise(size_t size)
117107

118108
void IsoSubspace::sweepLowerTierPreciseCell(PreciseAllocation* preciseAllocation)
119109
{
120-
ASSERT(!m_isPreciseOnly);
121110
preciseAllocation = preciseAllocation->reuseForLowerTierPrecise();
122111
m_lowerTierPreciseFreeList.append(preciseAllocation);
123112
}

‎Source/JavaScriptCore/heap/IsoSubspace.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ class IsoSubspace;
4343
class IsoSubspace final : public Subspace {
4444
WTF_MAKE_TZONE_ALLOCATED_EXPORT(IsoSubspace, JS_EXPORT_PRIVATE);
4545
public:
46-
JS_EXPORT_PRIVATE IsoSubspace(CString name, Heap&, const HeapCellType&, size_t size, bool preciseOnly, uint8_t numberOfLowerTierPreciseCells, std::unique_ptr<IsoMemoryAllocatorBase>&& = nullptr);
46+
JS_EXPORT_PRIVATE IsoSubspace(CString name, Heap&, const HeapCellType&, size_t size, uint8_t numberOfLowerTierPreciseCells, std::unique_ptr<IsoMemoryAllocatorBase>&& = nullptr);
4747
JS_EXPORT_PRIVATE ~IsoSubspace() final;
4848

4949
size_t cellSize() { return m_directory.cellSize(); }
5050

5151
void sweepLowerTierPreciseCell(PreciseAllocation*);
5252
void clearIsoCellSetBit(PreciseAllocation*);
5353

54-
void* tryAllocatePreciseOrLowerTierPrecise(size_t cellSize);
54+
void* tryAllocateLowerTierPrecise(size_t cellSize);
5555
void destroyLowerTierPreciseFreeList();
5656

5757
void sweep();
@@ -100,7 +100,7 @@ ALWAYS_INLINE Allocator IsoSubspace::allocatorFor(size_t size, AllocatorForMode)
100100

101101
} // namespace GCClient
102102

103-
#define ISO_SUBSPACE_INIT(heap, heapCellType, type) ("IsoSpace " #type ""_s, (heap), (heapCellType), sizeof(type), type::usePreciseAllocationsOnly, type::numberOfLowerTierPreciseCells)
103+
#define ISO_SUBSPACE_INIT(heap, heapCellType, type) ("IsoSpace " #type ""_s, (heap), (heapCellType), sizeof(type), type::numberOfLowerTierPreciseCells)
104104

105105
} // namespace JSC
106106

‎Source/JavaScriptCore/heap/LocalAllocator.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void* LocalAllocator::allocateSlowCase(JSC::Heap& heap, size_t cellSize, GCDefer
138138

139139
Subspace* subspace = m_directory->m_subspace;
140140
if (subspace->isIsoSubspace()) {
141-
if (void* result = static_cast<IsoSubspace*>(subspace)->tryAllocatePreciseOrLowerTierPrecise(cellSize))
141+
if (void* result = static_cast<IsoSubspace*>(subspace)->tryAllocateLowerTierPrecise(cellSize))
142142
return result;
143143
}
144144

‎Source/JavaScriptCore/heap/PreciseSubspace.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ namespace JSC {
3838
WTF_MAKE_TZONE_ALLOCATED_IMPL(PreciseSubspace);
3939

4040
PreciseSubspace::PreciseSubspace(CString name, JSC::Heap& heap, const HeapCellType& heapCellType, AlignedMemoryAllocator* allocator)
41-
: Subspace(name, heap)
41+
: Subspace(SubspaceKind::PreciseSubspace, name, heap)
4242
{
43-
m_isPreciseOnly = true;
4443
initialize(heapCellType, allocator);
4544
}
4645

‎Source/JavaScriptCore/heap/Subspace.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ namespace JSC {
3737

3838
WTF_MAKE_TZONE_ALLOCATED_IMPL(Subspace);
3939

40-
Subspace::Subspace(CString name, JSC::Heap& heap)
40+
Subspace::Subspace(SubspaceKind kind, CString name, JSC::Heap& heap)
4141
: m_space(heap.objectSpace())
42+
, m_kind(kind)
4243
, m_name(name)
4344
{
4445
}

‎Source/JavaScriptCore/heap/Subspace.h‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ namespace JSC {
3838
class AlignedMemoryAllocator;
3939
class HeapCellType;
4040

41+
enum class SubspaceKind {
42+
CompleteSubspace,
43+
IsoSubspace,
44+
PreciseSubspace,
45+
};
46+
4147
// The idea of subspaces is that you can provide some custom behavior for your objects if you
4248
// allocate them from a custom Subspace in which you override some of the virtual methods. This
4349
// class is the baseclass of all subspaces e.g. CompleteSubspace, IsoSubspace.
@@ -99,11 +105,12 @@ class Subspace {
99105
virtual void didRemoveBlock(unsigned blockIndex);
100106
virtual void didBeginSweepingToFreeList(MarkedBlock::Handle*);
101107

102-
bool isIsoSubspace() const { return m_isIsoSubspace; }
103-
bool isPreciseOnly() const { return m_isPreciseOnly; }
108+
SubspaceKind kind() const { return m_kind; }
109+
bool isIsoSubspace() const { return kind() == SubspaceKind::IsoSubspace; }
110+
bool isPreciseOnly() const { return kind() == SubspaceKind::PreciseSubspace; }
104111

105112
protected:
106-
Subspace(CString name, Heap&);
113+
Subspace(SubspaceKind, CString name, Heap&);
107114

108115
void initialize(const HeapCellType&, AlignedMemoryAllocator*);
109116

@@ -116,8 +123,7 @@ class Subspace {
116123
BlockDirectory* m_directoryForEmptyAllocation { nullptr }; // Uses the MarkedSpace linked list of blocks.
117124
SentinelLinkedList<PreciseAllocation, BasicRawSentinelNode<PreciseAllocation>> m_preciseAllocations;
118125

119-
bool m_isIsoSubspace { false };
120-
bool m_isPreciseOnly { false };
126+
SubspaceKind m_kind;
121127
uint8_t m_remainingLowerTierPreciseCount { 0 }; // Lower tier is a precise allocation but we use the term lower to avoid confusion with precise-only.
122128

123129
Subspace* m_nextSubspaceInAlignedMemoryAllocator { nullptr };

‎Source/JavaScriptCore/runtime/JSCell.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class JSCell : public HeapCell {
102102

103103
static constexpr DestructionMode needsDestruction = DoesNotNeedDestruction;
104104

105-
static constexpr bool usePreciseAllocationsOnly = false;
106105
static constexpr uint8_t numberOfLowerTierPreciseCells = 8;
107106

108107
static constexpr size_t atomSize = 16; // This needs to be larger or equal to 16.

0 commit comments

Comments
 (0)