Commit aa6e13aa authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

WTF: Clean up some container/allocator dead code

Bug: 1021889
Change-Id: Ic258b0bdcf0cd796c0c4380ff25dc051d897e528
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901034Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712985}
parent 4708285f
...@@ -98,19 +98,6 @@ class PLATFORM_EXPORT HeapAllocator { ...@@ -98,19 +98,6 @@ class PLATFORM_EXPORT HeapAllocator {
state, ThreadHeap::AllocationSizeFromSize(size), state, ThreadHeap::AllocationSizeFromSize(size),
BlinkGC::kVectorArenaIndex, gc_info_index, type_name))); BlinkGC::kVectorArenaIndex, gc_info_index, type_name)));
} }
template <typename T>
static T* AllocateExpandedVectorBacking(size_t size) {
ThreadState* state =
ThreadStateFor<ThreadingTrait<T>::kAffinity>::GetState();
DCHECK(state->IsAllocationAllowed());
uint32_t gc_info_index = GCInfoTrait<HeapVectorBacking<T>>::Index();
const char* type_name =
WTF_HEAP_PROFILER_TYPE_NAME(HeapHashTableBacking<HeapVectorBacking<T>>);
return reinterpret_cast<T*>(
MarkAsConstructed(state->Heap().AllocateOnArenaIndex(
state, ThreadHeap::AllocationSizeFromSize(size),
BlinkGC::kVectorArenaIndex, gc_info_index, type_name)));
}
static void FreeVectorBacking(void*); static void FreeVectorBacking(void*);
static bool ExpandVectorBacking(void*, size_t); static bool ExpandVectorBacking(void*, size_t);
static bool ShrinkVectorBacking(void* address, static bool ShrinkVectorBacking(void* address,
...@@ -153,16 +140,6 @@ class PLATFORM_EXPORT HeapAllocator { ...@@ -153,16 +140,6 @@ class PLATFORM_EXPORT HeapAllocator {
} }
} }
template <typename T>
static void BackingWriteBarrier(Member<T>* address, size_t size) {
MarkingVisitor::WriteBarrier(address);
}
template <typename T>
static void BackingWriteBarrier(T* address, size_t size) {
MarkingVisitor::WriteBarrier(address);
}
template <typename Return, typename Metadata> template <typename Return, typename Metadata>
static Return Malloc(size_t size, const char* type_name) { static Return Malloc(size_t size, const char* type_name) {
return reinterpret_cast<Return>( return reinterpret_cast<Return>(
......
...@@ -27,10 +27,4 @@ char* PartitionAllocator::AllocateVectorBacking<char>(size_t size) { ...@@ -27,10 +27,4 @@ char* PartitionAllocator::AllocateVectorBacking<char>(size_t size) {
AllocateBacking(size, "PartitionAllocator::allocateVectorBacking<char>")); AllocateBacking(size, "PartitionAllocator::allocateVectorBacking<char>"));
} }
template <>
char* PartitionAllocator::AllocateExpandedVectorBacking<char>(size_t size) {
return reinterpret_cast<char*>(AllocateBacking(
size, "PartitionAllocator::allocateExpandedVectorBacking<char>"));
}
} // namespace WTF } // namespace WTF
...@@ -42,11 +42,6 @@ class WTF_EXPORT PartitionAllocator { ...@@ -42,11 +42,6 @@ class WTF_EXPORT PartitionAllocator {
return reinterpret_cast<T*>( return reinterpret_cast<T*>(
AllocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T))); AllocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
} }
template <typename T>
static T* AllocateExpandedVectorBacking(size_t size) {
return reinterpret_cast<T*>(
AllocateBacking(size, WTF_HEAP_PROFILER_TYPE_NAME(T)));
}
static void FreeVectorBacking(void* address); static void FreeVectorBacking(void* address);
static inline bool ExpandVectorBacking(void*, size_t) { return false; } static inline bool ExpandVectorBacking(void*, size_t) { return false; }
static inline bool ShrinkVectorBacking(void* address, static inline bool ShrinkVectorBacking(void* address,
...@@ -88,7 +83,6 @@ class WTF_EXPORT PartitionAllocator { ...@@ -88,7 +83,6 @@ class WTF_EXPORT PartitionAllocator {
static void TraceMarkedBackingStore(void*) {} static void TraceMarkedBackingStore(void*) {}
static void BackingWriteBarrier(void*) {} static void BackingWriteBarrier(void*) {}
static void BackingWriteBarrier(void*, size_t) {}
template <typename> template <typename>
static void BackingWriteBarrierForHashTable(void*) {} static void BackingWriteBarrierForHashTable(void*) {}
...@@ -114,9 +108,6 @@ class WTF_EXPORT PartitionAllocator { ...@@ -114,9 +108,6 @@ class WTF_EXPORT PartitionAllocator {
// heap.) // heap.)
template <> template <>
WTF_EXPORT char* PartitionAllocator::AllocateVectorBacking<char>(size_t); WTF_EXPORT char* PartitionAllocator::AllocateVectorBacking<char>(size_t);
template <>
WTF_EXPORT char* PartitionAllocator::AllocateExpandedVectorBacking<char>(
size_t);
} // namespace WTF } // namespace WTF
......
...@@ -379,7 +379,7 @@ struct VectorTypeOperations { ...@@ -379,7 +379,7 @@ struct VectorTypeOperations {
// //
// Not meant for general consumption. // Not meant for general consumption.
template <typename T, bool hasInlineCapacity, typename Allocator> template <typename T, typename Allocator>
class VectorBufferBase { class VectorBufferBase {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -391,16 +391,7 @@ class VectorBufferBase { ...@@ -391,16 +391,7 @@ class VectorBufferBase {
size_t size_to_allocate = AllocationSize(new_capacity); size_t size_to_allocate = AllocationSize(new_capacity);
buffer_ = Allocator::template AllocateVectorBacking<T>(size_to_allocate); buffer_ = Allocator::template AllocateVectorBacking<T>(size_to_allocate);
capacity_ = static_cast<wtf_size_t>(size_to_allocate / sizeof(T)); capacity_ = static_cast<wtf_size_t>(size_to_allocate / sizeof(T));
Allocator::BackingWriteBarrier(buffer_, 0); Allocator::BackingWriteBarrier(buffer_);
}
void AllocateExpandedBuffer(wtf_size_t new_capacity) {
DCHECK(new_capacity);
size_t size_to_allocate = AllocationSize(new_capacity);
buffer_ =
Allocator::template AllocateExpandedVectorBacking<T>(size_to_allocate);
capacity_ = static_cast<wtf_size_t>(size_to_allocate / sizeof(T));
Allocator::BackingWriteBarrier(buffer_, 0);
} }
size_t AllocationSize(size_t capacity) const { size_t AllocationSize(size_t capacity) const {
...@@ -469,10 +460,9 @@ template <typename T, ...@@ -469,10 +460,9 @@ template <typename T,
class VectorBuffer; class VectorBuffer;
template <typename T, typename Allocator> template <typename T, typename Allocator>
class VectorBuffer<T, 0, Allocator> class VectorBuffer<T, 0, Allocator> : protected VectorBufferBase<T, Allocator> {
: protected VectorBufferBase<T, false, Allocator> {
private: private:
using Base = VectorBufferBase<T, false, Allocator>; using Base = VectorBufferBase<T, Allocator>;
public: public:
using OffsetRange = typename Base::OffsetRange; using OffsetRange = typename Base::OffsetRange;
...@@ -530,8 +520,8 @@ class VectorBuffer<T, 0, Allocator> ...@@ -530,8 +520,8 @@ class VectorBuffer<T, 0, Allocator>
std::swap(buffer_, other.buffer_); std::swap(buffer_, other.buffer_);
std::swap(capacity_, other.capacity_); std::swap(capacity_, other.capacity_);
std::swap(size_, other.size_); std::swap(size_, other.size_);
Allocator::BackingWriteBarrier(buffer_, size_); Allocator::BackingWriteBarrier(buffer_);
Allocator::BackingWriteBarrier(other.buffer_, other.size_); Allocator::BackingWriteBarrier(other.buffer_);
} }
using Base::AllocateBuffer; using Base::AllocateBuffer;
...@@ -560,9 +550,9 @@ class VectorBuffer<T, 0, Allocator> ...@@ -560,9 +550,9 @@ class VectorBuffer<T, 0, Allocator>
}; };
template <typename T, wtf_size_t inlineCapacity, typename Allocator> template <typename T, wtf_size_t inlineCapacity, typename Allocator>
class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { class VectorBuffer : protected VectorBufferBase<T, Allocator> {
private: private:
using Base = VectorBufferBase<T, true, Allocator>; using Base = VectorBufferBase<T, Allocator>;
public: public:
using OffsetRange = typename Base::OffsetRange; using OffsetRange = typename Base::OffsetRange;
...@@ -636,13 +626,6 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { ...@@ -636,13 +626,6 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
ResetBufferPointer(); ResetBufferPointer();
} }
void AllocateExpandedBuffer(wtf_size_t new_capacity) {
if (new_capacity > inlineCapacity)
Base::AllocateExpandedBuffer(new_capacity);
else
ResetBufferPointer();
}
size_t AllocationSize(size_t capacity) const { size_t AllocationSize(size_t capacity) const {
if (capacity <= inlineCapacity) if (capacity <= inlineCapacity)
return kInlineBufferSize; return kInlineBufferSize;
...@@ -677,8 +660,8 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { ...@@ -677,8 +660,8 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
std::swap(buffer_, other.buffer_); std::swap(buffer_, other.buffer_);
std::swap(capacity_, other.capacity_); std::swap(capacity_, other.capacity_);
std::swap(size_, other.size_); std::swap(size_, other.size_);
Allocator::BackingWriteBarrier(buffer_, size_); Allocator::BackingWriteBarrier(buffer_);
Allocator::BackingWriteBarrier(other.buffer_, other.size_); Allocator::BackingWriteBarrier(other.buffer_);
return; return;
} }
...@@ -739,7 +722,7 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { ...@@ -739,7 +722,7 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
other.buffer_ = other.InlineBuffer(); other.buffer_ = other.InlineBuffer();
std::swap(size_, other.size_); std::swap(size_, other.size_);
ANNOTATE_NEW_BUFFER(other.buffer_, inlineCapacity, other.size_); ANNOTATE_NEW_BUFFER(other.buffer_, inlineCapacity, other.size_);
Allocator::BackingWriteBarrier(buffer_, size_); Allocator::BackingWriteBarrier(buffer_);
} else if (!this_source_begin && } else if (!this_source_begin &&
other_source_begin) { // Their buffer is inline, ours is not. other_source_begin) { // Their buffer is inline, ours is not.
DCHECK_NE(Buffer(), InlineBuffer()); DCHECK_NE(Buffer(), InlineBuffer());
...@@ -749,7 +732,7 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> { ...@@ -749,7 +732,7 @@ class VectorBuffer : protected VectorBufferBase<T, true, Allocator> {
buffer_ = InlineBuffer(); buffer_ = InlineBuffer();
std::swap(size_, other.size_); std::swap(size_, other.size_);
ANNOTATE_NEW_BUFFER(buffer_, inlineCapacity, size_); ANNOTATE_NEW_BUFFER(buffer_, inlineCapacity, size_);
Allocator::BackingWriteBarrier(other.buffer_, other.size_); Allocator::BackingWriteBarrier(other.buffer_);
} else { // Both buffers are inline. } else { // Both buffers are inline.
DCHECK(this_source_begin); DCHECK(this_source_begin);
DCHECK(other_source_begin); DCHECK(other_source_begin);
...@@ -1651,7 +1634,7 @@ void Vector<T, inlineCapacity, Allocator>::ReserveCapacity( ...@@ -1651,7 +1634,7 @@ void Vector<T, inlineCapacity, Allocator>::ReserveCapacity(
CHECK(Allocator::IsAllocationAllowed()); CHECK(Allocator::IsAllocationAllowed());
T* old_end = end(); T* old_end = end();
Base::AllocateExpandedBuffer(new_capacity); Base::AllocateBuffer(new_capacity);
ANNOTATE_NEW_BUFFER(begin(), capacity(), size_); ANNOTATE_NEW_BUFFER(begin(), capacity(), size_);
TypeOperations::Move(old_buffer, old_end, begin()); TypeOperations::Move(old_buffer, old_end, begin());
ClearUnusedSlots(old_buffer, old_end); ClearUnusedSlots(old_buffer, old_end);
......
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