Commit 895ec9ea authored by Keishi Hattori's avatar Keishi Hattori Committed by Commit Bot

Revert "Oilpan: Rename to CrossThreadPersistentRegions"

This reverts commit 62bb75d3.

Reason for revert: Decided we don't need this change

Original change's description:
> Oilpan: Rename to CrossThreadPersistentRegions
> 
> Rename CrossThreadPersistentRegion to CrossThreadPersistentRegions as we will be adding a second PersistentRegion for weak persistents:
> 
> BUG=757440
> 
> Change-Id: I751747470c5ddc1481270e181cdd1edcf9ae5291
> Reviewed-on: https://chromium-review.googlesource.com/882626
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Commit-Queue: Keishi Hattori <keishi@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#531830}

TBR=haraken@chromium.org,keishi@chromium.org,hpayer@chromium.org,mlippautz@chromium.org

Change-Id: Ia1ac956e678dab92d6daab0852d0d9eafc3aa08a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 757440
Reviewed-on: https://chromium-review.googlesource.com/886162Reviewed-by: default avatarKeishi Hattori <keishi@chromium.org>
Commit-Queue: Keishi Hattori <keishi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531847}
parent eea5ec40
...@@ -197,8 +197,8 @@ void OfflineAudioDestinationHandler::DoOfflineRendering() { ...@@ -197,8 +197,8 @@ void OfflineAudioDestinationHandler::DoOfflineRendering() {
// data. Detect that condition by trying to take the cross-thread // data. Detect that condition by trying to take the cross-thread
// persistent lock which is held while a GC runs. If the lock is // persistent lock which is held while a GC runs. If the lock is
// already held, simply delay rendering until the next quantum. // already held, simply delay rendering until the next quantum.
CrossThreadPersistentRegions::LockScope gc_lock( CrossThreadPersistentRegion::LockScope gc_lock(
ProcessHeap::GetCrossThreadPersistentRegions(), true); ProcessHeap::GetCrossThreadPersistentRegion(), true);
if (!gc_lock.HasLock()) { if (!gc_lock.HasLock()) {
// To ensure that the rendering step eventually happens, repost. // To ensure that the rendering step eventually happens, repost.
GetRenderingThread()->GetWebTaskRunner()->PostTask( GetRenderingThread()->GetWebTaskRunner()->PostTask(
......
...@@ -75,10 +75,10 @@ void ProcessHeap::ResetHeapCounters() { ...@@ -75,10 +75,10 @@ void ProcessHeap::ResetHeapCounters() {
total_marked_object_size_ = 0; total_marked_object_size_ = 0;
} }
CrossThreadPersistentRegions& ProcessHeap::GetCrossThreadPersistentRegions() { CrossThreadPersistentRegion& ProcessHeap::GetCrossThreadPersistentRegion() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegions, DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion,
persistent_regions, ()); persistent_region, ());
return persistent_regions; return persistent_region;
} }
size_t ProcessHeap::total_allocated_space_ = 0; size_t ProcessHeap::total_allocated_space_ = 0;
...@@ -535,7 +535,7 @@ bool ThreadHeap::IsAddressInHeapDoesNotContainCache(Address address) { ...@@ -535,7 +535,7 @@ bool ThreadHeap::IsAddressInHeapDoesNotContainCache(Address address) {
void ThreadHeap::VisitPersistentRoots(Visitor* visitor) { void ThreadHeap::VisitPersistentRoots(Visitor* visitor) {
DCHECK(thread_state_->IsInGC()); DCHECK(thread_state_->IsInGC());
TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots"); TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots");
ProcessHeap::GetCrossThreadPersistentRegions().TracePersistentNodes(visitor); ProcessHeap::GetCrossThreadPersistentRegion().TracePersistentNodes(visitor);
thread_state_->VisitPersistents(visitor); thread_state_->VisitPersistents(visitor);
} }
...@@ -672,26 +672,26 @@ void ThreadHeap::PromptlyFreed(size_t gc_info_index) { ...@@ -672,26 +672,26 @@ void ThreadHeap::PromptlyFreed(size_t gc_info_index) {
#if defined(ADDRESS_SANITIZER) #if defined(ADDRESS_SANITIZER)
void ThreadHeap::PoisonAllHeaps() { void ThreadHeap::PoisonAllHeaps() {
CrossThreadPersistentRegions::LockScope persistent_lock( CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions()); ProcessHeap::GetCrossThreadPersistentRegion());
// Poisoning all unmarked objects in the other arenas. // Poisoning all unmarked objects in the other arenas.
for (int i = 1; i < BlinkGC::kNumberOfArenas; i++) for (int i = 1; i < BlinkGC::kNumberOfArenas; i++)
arenas_[i]->PoisonArena(); arenas_[i]->PoisonArena();
// CrossThreadPersistents in unmarked objects may be accessed from other // CrossThreadPersistents in unmarked objects may be accessed from other
// threads (e.g. in CrossThreadPersistentRegions::shouldTracePersistent) and // threads (e.g. in CrossThreadPersistentRegion::shouldTracePersistent) and
// that would be fine. // that would be fine.
ProcessHeap::GetCrossThreadPersistentRegions() ProcessHeap::GetCrossThreadPersistentRegion()
.UnpoisonCrossThreadPersistents(); .UnpoisonCrossThreadPersistents();
} }
void ThreadHeap::PoisonEagerArena() { void ThreadHeap::PoisonEagerArena() {
CrossThreadPersistentRegions::LockScope persistent_lock( CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions()); ProcessHeap::GetCrossThreadPersistentRegion());
arenas_[BlinkGC::kEagerSweepArenaIndex]->PoisonArena(); arenas_[BlinkGC::kEagerSweepArenaIndex]->PoisonArena();
// CrossThreadPersistents in unmarked objects may be accessed from other // CrossThreadPersistents in unmarked objects may be accessed from other
// threads (e.g. in CrossThreadPersistentRegions::shouldTracePersistent) and // threads (e.g. in CrossThreadPersistentRegion::shouldTracePersistent) and
// that would be fine. // that would be fine.
ProcessHeap::GetCrossThreadPersistentRegions() ProcessHeap::GetCrossThreadPersistentRegion()
.UnpoisonCrossThreadPersistents(); .UnpoisonCrossThreadPersistents();
} }
#endif #endif
......
...@@ -83,7 +83,7 @@ class PLATFORM_EXPORT HeapAllocHooks { ...@@ -83,7 +83,7 @@ class PLATFORM_EXPORT HeapAllocHooks {
static FreeHook* free_hook_; static FreeHook* free_hook_;
}; };
class CrossThreadPersistentRegions; class CrossThreadPersistentRegion;
class HeapCompact; class HeapCompact;
template <typename T> template <typename T>
class Member; class Member;
...@@ -124,7 +124,7 @@ class PLATFORM_EXPORT ProcessHeap { ...@@ -124,7 +124,7 @@ class PLATFORM_EXPORT ProcessHeap {
public: public:
static void Init(); static void Init();
static CrossThreadPersistentRegions& GetCrossThreadPersistentRegions(); static CrossThreadPersistentRegion& GetCrossThreadPersistentRegion();
static void IncreaseTotalAllocatedObjectSize(size_t delta) { static void IncreaseTotalAllocatedObjectSize(size_t delta) {
AtomicAdd(&total_allocated_object_size_, static_cast<long>(delta)); AtomicAdd(&total_allocated_object_size_, static_cast<long>(delta));
......
...@@ -185,8 +185,8 @@ class PersistentBase { ...@@ -185,8 +185,8 @@ class PersistentBase {
NO_SANITIZE_ADDRESS NO_SANITIZE_ADDRESS
void Assign(T* ptr) { void Assign(T* ptr) {
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) { if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
CrossThreadPersistentRegions::LockScope persistent_lock( CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions()); ProcessHeap::GetCrossThreadPersistentRegion());
raw_ = ptr; raw_ = ptr;
} else { } else {
raw_ = ptr; raw_ = ptr;
...@@ -222,7 +222,7 @@ class PersistentBase { ...@@ -222,7 +222,7 @@ class PersistentBase {
TraceMethodDelegate<PersistentBase, TraceMethodDelegate<PersistentBase,
&PersistentBase::TracePersistent>::Trampoline; &PersistentBase::TracePersistent>::Trampoline;
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) { if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
ProcessHeap::GetCrossThreadPersistentRegions().AllocatePersistentNode( ProcessHeap::GetCrossThreadPersistentRegion().AllocatePersistentNode(
persistent_node_, this, trace_callback); persistent_node_, this, trace_callback);
return; return;
} }
...@@ -239,7 +239,7 @@ class PersistentBase { ...@@ -239,7 +239,7 @@ class PersistentBase {
void Uninitialize() { void Uninitialize() {
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) { if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
if (AcquireLoad(reinterpret_cast<void* volatile*>(&persistent_node_))) if (AcquireLoad(reinterpret_cast<void* volatile*>(&persistent_node_)))
ProcessHeap::GetCrossThreadPersistentRegions().FreePersistentNode( ProcessHeap::GetCrossThreadPersistentRegion().FreePersistentNode(
persistent_node_); persistent_node_);
return; return;
} }
...@@ -819,8 +819,8 @@ template <typename T> ...@@ -819,8 +819,8 @@ template <typename T>
struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> { struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> {
static blink::CrossThreadPersistent<T> Unwrap( static blink::CrossThreadPersistent<T> Unwrap(
const blink::CrossThreadWeakPersistent<T>& wrapped) { const blink::CrossThreadWeakPersistent<T>& wrapped) {
blink::CrossThreadPersistentRegions::LockScope persistentLock( blink::CrossThreadPersistentRegion::LockScope persistentLock(
blink::ProcessHeap::GetCrossThreadPersistentRegions()); blink::ProcessHeap::GetCrossThreadPersistentRegion());
return blink::CrossThreadPersistent<T>(wrapped.Get()); return blink::CrossThreadPersistent<T>(wrapped.Get());
} }
}; };
......
...@@ -125,7 +125,7 @@ void PersistentRegion::TracePersistentNodes(Visitor* visitor, ...@@ -125,7 +125,7 @@ void PersistentRegion::TracePersistentNodes(Visitor* visitor,
#endif #endif
} }
bool CrossThreadPersistentRegions::ShouldTracePersistentNode( bool CrossThreadPersistentRegion::ShouldTracePersistentNode(
Visitor* visitor, Visitor* visitor,
PersistentNode* node) { PersistentNode* node) {
CrossThreadPersistent<DummyGCBase>* persistent = CrossThreadPersistent<DummyGCBase>* persistent =
...@@ -138,7 +138,7 @@ bool CrossThreadPersistentRegions::ShouldTracePersistentNode( ...@@ -138,7 +138,7 @@ bool CrossThreadPersistentRegions::ShouldTracePersistentNode(
return &visitor->Heap() == &ThreadState::FromObject(raw_object)->Heap(); return &visitor->Heap() == &ThreadState::FromObject(raw_object)->Heap();
} }
void CrossThreadPersistentRegions::PrepareForThreadStateTermination( void CrossThreadPersistentRegion::PrepareForThreadStateTermination(
ThreadState* thread_state) { ThreadState* thread_state) {
// For heaps belonging to a thread that's detaching, any cross-thread // For heaps belonging to a thread that's detaching, any cross-thread
// persistents pointing into them needs to be disabled. Do that by clearing // persistents pointing into them needs to be disabled. Do that by clearing
...@@ -175,7 +175,7 @@ void CrossThreadPersistentRegions::PrepareForThreadStateTermination( ...@@ -175,7 +175,7 @@ void CrossThreadPersistentRegions::PrepareForThreadStateTermination(
} }
#if defined(ADDRESS_SANITIZER) #if defined(ADDRESS_SANITIZER)
void CrossThreadPersistentRegions::UnpoisonCrossThreadPersistents() { void CrossThreadPersistentRegion::UnpoisonCrossThreadPersistents() {
MutexLocker lock(mutex_); MutexLocker lock(mutex_);
int persistent_count = 0; int persistent_count = 0;
for (PersistentNodeSlots* slots = persistent_region_->slots_; slots; for (PersistentNodeSlots* slots = persistent_region_->slots_; slots;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
namespace blink { namespace blink {
class CrossThreadPersistentRegions; class CrossThreadPersistentRegion;
class PersistentNode final { class PersistentNode final {
DISALLOW_NEW(); DISALLOW_NEW();
...@@ -93,7 +93,7 @@ struct PersistentNodeSlots final { ...@@ -93,7 +93,7 @@ struct PersistentNodeSlots final {
PersistentNodeSlots* next_; PersistentNodeSlots* next_;
PersistentNode slot_[kSlotCount]; PersistentNode slot_[kSlotCount];
friend class PersistentRegion; friend class PersistentRegion;
friend class CrossThreadPersistentRegions; friend class CrossThreadPersistentRegion;
}; };
// PersistentRegion provides a region of PersistentNodes. PersistentRegion // PersistentRegion provides a region of PersistentNodes. PersistentRegion
...@@ -153,7 +153,7 @@ class PLATFORM_EXPORT PersistentRegion final { ...@@ -153,7 +153,7 @@ class PLATFORM_EXPORT PersistentRegion final {
int NumberOfPersistents(); int NumberOfPersistents();
private: private:
friend CrossThreadPersistentRegions; friend CrossThreadPersistentRegion;
void EnsurePersistentNodeSlots(void*, TraceCallback); void EnsurePersistentNodeSlots(void*, TraceCallback);
...@@ -164,11 +164,11 @@ class PLATFORM_EXPORT PersistentRegion final { ...@@ -164,11 +164,11 @@ class PLATFORM_EXPORT PersistentRegion final {
#endif #endif
}; };
class CrossThreadPersistentRegions final { class CrossThreadPersistentRegion final {
USING_FAST_MALLOC(CrossThreadPersistentRegions); USING_FAST_MALLOC(CrossThreadPersistentRegion);
public: public:
CrossThreadPersistentRegions() CrossThreadPersistentRegion()
: persistent_region_(WTF::WrapUnique(new PersistentRegion)) {} : persistent_region_(WTF::WrapUnique(new PersistentRegion)) {}
void AllocatePersistentNode(PersistentNode*& persistent_node, void AllocatePersistentNode(PersistentNode*& persistent_node,
...@@ -202,7 +202,7 @@ class CrossThreadPersistentRegions final { ...@@ -202,7 +202,7 @@ class CrossThreadPersistentRegions final {
STACK_ALLOCATED(); STACK_ALLOCATED();
public: public:
LockScope(CrossThreadPersistentRegions& persistent_region, LockScope(CrossThreadPersistentRegion& persistent_region,
bool try_lock = false) bool try_lock = false)
: persistent_region_(persistent_region), locked_(true) { : persistent_region_(persistent_region), locked_(true) {
if (try_lock) if (try_lock)
...@@ -221,7 +221,7 @@ class CrossThreadPersistentRegions final { ...@@ -221,7 +221,7 @@ class CrossThreadPersistentRegions final {
bool HasLock() const { return locked_; } bool HasLock() const { return locked_; }
private: private:
CrossThreadPersistentRegions& persistent_region_; CrossThreadPersistentRegion& persistent_region_;
bool locked_; bool locked_;
}; };
...@@ -231,7 +231,7 @@ class CrossThreadPersistentRegions final { ...@@ -231,7 +231,7 @@ class CrossThreadPersistentRegions final {
DCHECK(mutex_.Locked()); DCHECK(mutex_.Locked());
#endif #endif
persistent_region_->TracePersistentNodes( persistent_region_->TracePersistentNodes(
visitor, CrossThreadPersistentRegions::ShouldTracePersistentNode); visitor, CrossThreadPersistentRegion::ShouldTracePersistentNode);
} }
void PrepareForThreadStateTermination(ThreadState*); void PrepareForThreadStateTermination(ThreadState*);
...@@ -252,14 +252,14 @@ class CrossThreadPersistentRegions final { ...@@ -252,14 +252,14 @@ class CrossThreadPersistentRegions final {
bool TryLock() { return mutex_.TryLock(); } bool TryLock() { return mutex_.TryLock(); }
// We don't make CrossThreadPersistentRegions inherit from PersistentRegion // We don't make CrossThreadPersistentRegion inherit from PersistentRegion
// because we don't want to virtualize performance-sensitive methods // because we don't want to virtualize performance-sensitive methods
// such as PersistentRegion::allocate/freePersistentNode. // such as PersistentRegion::allocate/freePersistentNode.
std::unique_ptr<PersistentRegion> persistent_region_; std::unique_ptr<PersistentRegion> persistent_region_;
// Recursive as prepareForThreadStateTermination() clears a PersistentNode's // Recursive as prepareForThreadStateTermination() clears a PersistentNode's
// associated Persistent<> -- it in turn freeing the PersistentNode. And both // associated Persistent<> -- it in turn freeing the PersistentNode. And both
// CrossThreadPersistentRegions operations need a lock on the region before // CrossThreadPersistentRegion operations need a lock on the region before
// mutating. // mutating.
RecursiveMutex mutex_; RecursiveMutex mutex_;
}; };
......
...@@ -197,7 +197,7 @@ void ThreadState::RunTerminationGC() { ...@@ -197,7 +197,7 @@ void ThreadState::RunTerminationGC() {
ReleaseStaticPersistentNodes(); ReleaseStaticPersistentNodes();
ProcessHeap::GetCrossThreadPersistentRegions() ProcessHeap::GetCrossThreadPersistentRegion()
.PrepareForThreadStateTermination(this); .PrepareForThreadStateTermination(this);
// Do thread local GC's as long as the count of thread local Persistents // Do thread local GC's as long as the count of thread local Persistents
...@@ -1265,13 +1265,13 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state, ...@@ -1265,13 +1265,13 @@ void ThreadState::CollectGarbage(BlinkGC::StackState stack_state,
GCForbiddenScope gc_forbidden_scope(this); GCForbiddenScope gc_forbidden_scope(this);
{ {
// Access to the CrossThreadPersistentRegions has to be prevented // Access to the CrossThreadPersistentRegion has to be prevented
// while in the marking phase because otherwise other threads may // while in the marking phase because otherwise other threads may
// allocate or free PersistentNodes and we can't handle // allocate or free PersistentNodes and we can't handle
// that. Grabbing this lock also prevents non-attached threads // that. Grabbing this lock also prevents non-attached threads
// from accessing any GCed heap while a GC runs. // from accessing any GCed heap while a GC runs.
CrossThreadPersistentRegions::LockScope persistent_lock( CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions()); ProcessHeap::GetCrossThreadPersistentRegion());
{ {
TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking",
......
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