Commit f27b0a74 authored by Haruka Matsumura's avatar Haruka Matsumura Committed by Commit Bot

Oilpan: Implement slot remove method for HeapCollection

This CL adds will remove slots for HeapCollections that are destrcuted by mutator when Incremental Marking.
When each HeapCollection are destructed, RemoveSlot is called and destructed slots are removed from the registry in HeapCompact.

Bug: 864425
Change-Id: I09e7fcbe22cfd97fe5108249aed602de67c97066
Reviewed-on: https://chromium-review.googlesource.com/1150003
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKeishi Hattori <keishi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582142}
parent b91727ed
...@@ -123,6 +123,12 @@ class HeapCompact::MovableObjectFixups final { ...@@ -123,6 +123,12 @@ class HeapCompact::MovableObjectFixups final {
slot, std::pair<void*, MovingObjectCallback>(callback_data, callback)); slot, std::pair<void*, MovingObjectCallback>(callback_data, callback));
} }
void RemoveFixupCallback(MovableReference* slot) {
auto it = fixup_callbacks_.find(slot);
if (it != fixup_callbacks_.end())
fixup_callbacks_.erase(it);
}
void RelocateInteriorFixups(Address from, Address to, size_t size) { void RelocateInteriorFixups(Address from, Address to, size_t size) {
SparseHeapBitmap* range = interiors_->HasRange(from, size); SparseHeapBitmap* range = interiors_->HasRange(from, size);
if (LIKELY(!range)) if (LIKELY(!range))
...@@ -164,7 +170,7 @@ class HeapCompact::MovableObjectFixups final { ...@@ -164,7 +170,7 @@ class HeapCompact::MovableObjectFixups final {
void Relocate(Address from, Address to) { void Relocate(Address from, Address to) {
auto it = fixups_.find(from); auto it = fixups_.find(from);
/// This means that there is no corresponding slot for a live backing store. // This means that there is no corresponding slot for a live backing store.
// This may happen because a mutator may change the slot to point to a // This may happen because a mutator may change the slot to point to a
// different backing store after an incremental marking traced the slot (and // different backing store after an incremental marking traced the slot (and
// marked the old backing store as live). // marked the old backing store as live).
...@@ -377,6 +383,13 @@ void HeapCompact::Initialize(ThreadState* state) { ...@@ -377,6 +383,13 @@ void HeapCompact::Initialize(ThreadState* state) {
force_compaction_gc_ = false; force_compaction_gc_ = false;
} }
void HeapCompact::RemoveSlot(MovableReference* slot) {
auto it = traced_slots_.find(slot);
if (it != traced_slots_.end())
traced_slots_.erase(it);
Fixups().RemoveFixupCallback(slot);
}
void HeapCompact::RegisterMovingObjectReference(MovableReference* slot) { void HeapCompact::RegisterMovingObjectReference(MovableReference* slot) {
if (!do_compact_) if (!do_compact_)
return; return;
......
...@@ -49,6 +49,10 @@ class PLATFORM_EXPORT HeapCompact final { ...@@ -49,6 +49,10 @@ class PLATFORM_EXPORT HeapCompact final {
~HeapCompact(); ~HeapCompact();
// Remove slot from traced_slots_ when a registered slot is destructed by
// mutator
void RemoveSlot(MovableReference* slot);
// Determine if a GC for the given type and reason should also perform // Determine if a GC for the given type and reason should also perform
// additional heap compaction. // additional heap compaction.
// //
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/heap/heap_compact.h"
#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/heap/persistent_node.h" #include "third_party/blink/renderer/platform/heap/persistent_node.h"
#include "third_party/blink/renderer/platform/heap/visitor.h" #include "third_party/blink/renderer/platform/heap/visitor.h"
...@@ -686,6 +687,11 @@ class PersistentHeapCollectionBase : public Collection { ...@@ -686,6 +687,11 @@ class PersistentHeapCollectionBase : public Collection {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK_EQ(state_, state); DCHECK_EQ(state_, state);
#endif #endif
HeapCompact* compactor = state->Heap().Compaction();
if (compactor->IsCompacting()) {
compactor->RemoveSlot(
reinterpret_cast<MovableReference*>(this->GetBufferSlot()));
}
state->FreePersistentNode(state->GetPersistentRegion(), persistent_node_); state->FreePersistentNode(state->GetPersistentRegion(), persistent_node_);
persistent_node_ = nullptr; persistent_node_ = nullptr;
} }
......
...@@ -160,6 +160,9 @@ class Deque { ...@@ -160,6 +160,9 @@ class Deque {
"Cannot put raw pointers to garbage-collected classes into a " "Cannot put raw pointers to garbage-collected classes into a "
"Deque. Use HeapDeque<Member<T>> instead."); "Deque. Use HeapDeque<Member<T>> instead.");
protected:
T** GetBufferSlot() { return buffer_.BufferSlot(); }
private: private:
friend class DequeIteratorBase<T, inlineCapacity, Allocator>; friend class DequeIteratorBase<T, inlineCapacity, Allocator>;
......
...@@ -110,6 +110,11 @@ class HashCountedSet { ...@@ -110,6 +110,11 @@ class HashCountedSet {
impl_.Trace(visitor); impl_.Trace(visitor);
} }
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private: private:
ImplType impl_; ImplType impl_;
......
...@@ -31,6 +31,12 @@ namespace WTF { ...@@ -31,6 +31,12 @@ namespace WTF {
template <typename KeyTraits, typename MappedTraits> template <typename KeyTraits, typename MappedTraits>
struct HashMapValueTraits; struct HashMapValueTraits;
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
class HashCountedSet;
struct KeyValuePairKeyExtractor { struct KeyValuePairKeyExtractor {
STATIC_ONLY(KeyValuePairKeyExtractor); STATIC_ONLY(KeyValuePairKeyExtractor);
template <typename T> template <typename T>
...@@ -51,6 +57,8 @@ template <typename KeyArg, ...@@ -51,6 +57,8 @@ template <typename KeyArg,
typename Allocator = PartitionAllocator> typename Allocator = PartitionAllocator>
class HashMap { class HashMap {
USE_ALLOCATOR(HashMap, Allocator); USE_ALLOCATOR(HashMap, Allocator);
template <typename T, typename U, typename V, typename W>
friend class HashCountedSet;
private: private:
typedef KeyTraitsArg KeyTraits; typedef KeyTraitsArg KeyTraits;
...@@ -197,6 +205,9 @@ class HashMap { ...@@ -197,6 +205,9 @@ class HashMap {
impl_.Trace(visitor); impl_.Trace(visitor);
} }
protected:
ValueType** GetBufferSlot() { return impl_.GetBufferSlot(); }
private: private:
template <typename IncomingKeyType, typename IncomingMappedType> template <typename IncomingKeyType, typename IncomingMappedType>
AddResult InlineAdd(IncomingKeyType&&, IncomingMappedType&&); AddResult InlineAdd(IncomingKeyType&&, IncomingMappedType&&);
......
...@@ -138,6 +138,9 @@ class HashSet { ...@@ -138,6 +138,9 @@ class HashSet {
impl_.Trace(visitor); impl_.Trace(visitor);
} }
protected:
ValueType** GetBufferSlot() { return impl_.GetBufferSlot(); }
private: private:
HashTableType impl_; HashTableType impl_;
}; };
......
...@@ -829,6 +829,8 @@ class HashTable final { ...@@ -829,6 +829,8 @@ class HashTable final {
template <typename HashTranslator, typename T> template <typename HashTranslator, typename T>
const ValueType* Lookup(const T&) const; const ValueType* Lookup(const T&) const;
ValueType** GetBufferSlot() { return &table_; }
template <typename VisitorDispatcher, typename A = Allocator> template <typename VisitorDispatcher, typename A = Allocator>
std::enable_if_t<A::kIsGarbageCollected> Trace(VisitorDispatcher); std::enable_if_t<A::kIsGarbageCollected> Trace(VisitorDispatcher);
......
...@@ -317,6 +317,11 @@ class LinkedHashSet { ...@@ -317,6 +317,11 @@ class LinkedHashSet {
impl_.CheckModifications(mods); impl_.CheckModifications(mods);
} }
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private: private:
Node* Anchor() { return reinterpret_cast<Node*>(&anchor_); } Node* Anchor() { return reinterpret_cast<Node*>(&anchor_); }
const Node* Anchor() const { return reinterpret_cast<const Node*>(&anchor_); } const Node* Anchor() const { return reinterpret_cast<const Node*>(&anchor_); }
......
...@@ -234,6 +234,11 @@ class ListHashSet { ...@@ -234,6 +234,11 @@ class ListHashSet {
template <typename VisitorDispatcher> template <typename VisitorDispatcher>
void Trace(VisitorDispatcher); void Trace(VisitorDispatcher);
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private: private:
void Unlink(Node*); void Unlink(Node*);
void UnlinkAndDelete(Node*); void UnlinkAndDelete(Node*);
......
...@@ -1295,6 +1295,8 @@ class Vector : private VectorBuffer<T, INLINE_CAPACITY, Allocator> { ...@@ -1295,6 +1295,8 @@ class Vector : private VectorBuffer<T, INLINE_CAPACITY, Allocator> {
using Base::CheckUnusedSlots; using Base::CheckUnusedSlots;
using Base::ClearUnusedSlots; using Base::ClearUnusedSlots;
T** GetBufferSlot() { return Base::BufferSlot(); }
private: private:
void ExpandCapacity(wtf_size_t new_min_capacity); void ExpandCapacity(wtf_size_t new_min_capacity);
T* ExpandCapacity(wtf_size_t new_min_capacity, T*); T* ExpandCapacity(wtf_size_t new_min_capacity, T*);
......
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