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 {
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) {
SparseHeapBitmap* range = interiors_->HasRange(from, size);
if (LIKELY(!range))
......@@ -164,7 +170,7 @@ class HeapCompact::MovableObjectFixups final {
void Relocate(Address from, Address to) {
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
// different backing store after an incremental marking traced the slot (and
// marked the old backing store as live).
......@@ -377,6 +383,13 @@ void HeapCompact::Initialize(ThreadState* state) {
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) {
if (!do_compact_)
return;
......
......@@ -49,6 +49,10 @@ class PLATFORM_EXPORT HeapCompact final {
~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
// additional heap compaction.
//
......
......@@ -7,6 +7,7 @@
#include "base/bind.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/persistent_node.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
......@@ -686,6 +687,11 @@ class PersistentHeapCollectionBase : public Collection {
#if DCHECK_IS_ON()
DCHECK_EQ(state_, state);
#endif
HeapCompact* compactor = state->Heap().Compaction();
if (compactor->IsCompacting()) {
compactor->RemoveSlot(
reinterpret_cast<MovableReference*>(this->GetBufferSlot()));
}
state->FreePersistentNode(state->GetPersistentRegion(), persistent_node_);
persistent_node_ = nullptr;
}
......
......@@ -160,6 +160,9 @@ class Deque {
"Cannot put raw pointers to garbage-collected classes into a "
"Deque. Use HeapDeque<Member<T>> instead.");
protected:
T** GetBufferSlot() { return buffer_.BufferSlot(); }
private:
friend class DequeIteratorBase<T, inlineCapacity, Allocator>;
......
......@@ -110,6 +110,11 @@ class HashCountedSet {
impl_.Trace(visitor);
}
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private:
ImplType impl_;
......
......@@ -31,6 +31,12 @@ namespace WTF {
template <typename KeyTraits, typename MappedTraits>
struct HashMapValueTraits;
template <typename Value,
typename HashFunctions,
typename Traits,
typename Allocator>
class HashCountedSet;
struct KeyValuePairKeyExtractor {
STATIC_ONLY(KeyValuePairKeyExtractor);
template <typename T>
......@@ -51,6 +57,8 @@ template <typename KeyArg,
typename Allocator = PartitionAllocator>
class HashMap {
USE_ALLOCATOR(HashMap, Allocator);
template <typename T, typename U, typename V, typename W>
friend class HashCountedSet;
private:
typedef KeyTraitsArg KeyTraits;
......@@ -197,6 +205,9 @@ class HashMap {
impl_.Trace(visitor);
}
protected:
ValueType** GetBufferSlot() { return impl_.GetBufferSlot(); }
private:
template <typename IncomingKeyType, typename IncomingMappedType>
AddResult InlineAdd(IncomingKeyType&&, IncomingMappedType&&);
......
......@@ -138,6 +138,9 @@ class HashSet {
impl_.Trace(visitor);
}
protected:
ValueType** GetBufferSlot() { return impl_.GetBufferSlot(); }
private:
HashTableType impl_;
};
......
......@@ -829,6 +829,8 @@ class HashTable final {
template <typename HashTranslator, typename T>
const ValueType* Lookup(const T&) const;
ValueType** GetBufferSlot() { return &table_; }
template <typename VisitorDispatcher, typename A = Allocator>
std::enable_if_t<A::kIsGarbageCollected> Trace(VisitorDispatcher);
......
......@@ -317,6 +317,11 @@ class LinkedHashSet {
impl_.CheckModifications(mods);
}
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private:
Node* Anchor() { return reinterpret_cast<Node*>(&anchor_); }
const Node* Anchor() const { return reinterpret_cast<const Node*>(&anchor_); }
......
......@@ -234,6 +234,11 @@ class ListHashSet {
template <typename VisitorDispatcher>
void Trace(VisitorDispatcher);
protected:
typename ImplType::ValueType** GetBufferSlot() {
return impl_.GetBufferSlot();
}
private:
void Unlink(Node*);
void UnlinkAndDelete(Node*);
......
......@@ -1295,6 +1295,8 @@ class Vector : private VectorBuffer<T, INLINE_CAPACITY, Allocator> {
using Base::CheckUnusedSlots;
using Base::ClearUnusedSlots;
T** GetBufferSlot() { return Base::BufferSlot(); }
private:
void ExpandCapacity(wtf_size_t new_min_capacity);
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