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() {
// data. Detect that condition by trying to take the cross-thread
// persistent lock which is held while a GC runs. If the lock is
// already held, simply delay rendering until the next quantum.
CrossThreadPersistentRegions::LockScope gc_lock(
ProcessHeap::GetCrossThreadPersistentRegions(), true);
CrossThreadPersistentRegion::LockScope gc_lock(
ProcessHeap::GetCrossThreadPersistentRegion(), true);
if (!gc_lock.HasLock()) {
// To ensure that the rendering step eventually happens, repost.
GetRenderingThread()->GetWebTaskRunner()->PostTask(
......
......@@ -75,10 +75,10 @@ void ProcessHeap::ResetHeapCounters() {
total_marked_object_size_ = 0;
}
CrossThreadPersistentRegions& ProcessHeap::GetCrossThreadPersistentRegions() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegions,
persistent_regions, ());
return persistent_regions;
CrossThreadPersistentRegion& ProcessHeap::GetCrossThreadPersistentRegion() {
DEFINE_THREAD_SAFE_STATIC_LOCAL(CrossThreadPersistentRegion,
persistent_region, ());
return persistent_region;
}
size_t ProcessHeap::total_allocated_space_ = 0;
......@@ -535,7 +535,7 @@ bool ThreadHeap::IsAddressInHeapDoesNotContainCache(Address address) {
void ThreadHeap::VisitPersistentRoots(Visitor* visitor) {
DCHECK(thread_state_->IsInGC());
TRACE_EVENT0("blink_gc", "ThreadHeap::visitPersistentRoots");
ProcessHeap::GetCrossThreadPersistentRegions().TracePersistentNodes(visitor);
ProcessHeap::GetCrossThreadPersistentRegion().TracePersistentNodes(visitor);
thread_state_->VisitPersistents(visitor);
}
......@@ -672,26 +672,26 @@ void ThreadHeap::PromptlyFreed(size_t gc_info_index) {
#if defined(ADDRESS_SANITIZER)
void ThreadHeap::PoisonAllHeaps() {
CrossThreadPersistentRegions::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions());
CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegion());
// Poisoning all unmarked objects in the other arenas.
for (int i = 1; i < BlinkGC::kNumberOfArenas; i++)
arenas_[i]->PoisonArena();
// 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.
ProcessHeap::GetCrossThreadPersistentRegions()
ProcessHeap::GetCrossThreadPersistentRegion()
.UnpoisonCrossThreadPersistents();
}
void ThreadHeap::PoisonEagerArena() {
CrossThreadPersistentRegions::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions());
CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegion());
arenas_[BlinkGC::kEagerSweepArenaIndex]->PoisonArena();
// 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.
ProcessHeap::GetCrossThreadPersistentRegions()
ProcessHeap::GetCrossThreadPersistentRegion()
.UnpoisonCrossThreadPersistents();
}
#endif
......
......@@ -83,7 +83,7 @@ class PLATFORM_EXPORT HeapAllocHooks {
static FreeHook* free_hook_;
};
class CrossThreadPersistentRegions;
class CrossThreadPersistentRegion;
class HeapCompact;
template <typename T>
class Member;
......@@ -124,7 +124,7 @@ class PLATFORM_EXPORT ProcessHeap {
public:
static void Init();
static CrossThreadPersistentRegions& GetCrossThreadPersistentRegions();
static CrossThreadPersistentRegion& GetCrossThreadPersistentRegion();
static void IncreaseTotalAllocatedObjectSize(size_t delta) {
AtomicAdd(&total_allocated_object_size_, static_cast<long>(delta));
......
......@@ -185,8 +185,8 @@ class PersistentBase {
NO_SANITIZE_ADDRESS
void Assign(T* ptr) {
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
CrossThreadPersistentRegions::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions());
CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegion());
raw_ = ptr;
} else {
raw_ = ptr;
......@@ -222,7 +222,7 @@ class PersistentBase {
TraceMethodDelegate<PersistentBase,
&PersistentBase::TracePersistent>::Trampoline;
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
ProcessHeap::GetCrossThreadPersistentRegions().AllocatePersistentNode(
ProcessHeap::GetCrossThreadPersistentRegion().AllocatePersistentNode(
persistent_node_, this, trace_callback);
return;
}
......@@ -239,7 +239,7 @@ class PersistentBase {
void Uninitialize() {
if (crossThreadnessConfiguration == kCrossThreadPersistentConfiguration) {
if (AcquireLoad(reinterpret_cast<void* volatile*>(&persistent_node_)))
ProcessHeap::GetCrossThreadPersistentRegions().FreePersistentNode(
ProcessHeap::GetCrossThreadPersistentRegion().FreePersistentNode(
persistent_node_);
return;
}
......@@ -819,8 +819,8 @@ template <typename T>
struct BindUnwrapTraits<blink::CrossThreadWeakPersistent<T>> {
static blink::CrossThreadPersistent<T> Unwrap(
const blink::CrossThreadWeakPersistent<T>& wrapped) {
blink::CrossThreadPersistentRegions::LockScope persistentLock(
blink::ProcessHeap::GetCrossThreadPersistentRegions());
blink::CrossThreadPersistentRegion::LockScope persistentLock(
blink::ProcessHeap::GetCrossThreadPersistentRegion());
return blink::CrossThreadPersistent<T>(wrapped.Get());
}
};
......
......@@ -125,7 +125,7 @@ void PersistentRegion::TracePersistentNodes(Visitor* visitor,
#endif
}
bool CrossThreadPersistentRegions::ShouldTracePersistentNode(
bool CrossThreadPersistentRegion::ShouldTracePersistentNode(
Visitor* visitor,
PersistentNode* node) {
CrossThreadPersistent<DummyGCBase>* persistent =
......@@ -138,7 +138,7 @@ bool CrossThreadPersistentRegions::ShouldTracePersistentNode(
return &visitor->Heap() == &ThreadState::FromObject(raw_object)->Heap();
}
void CrossThreadPersistentRegions::PrepareForThreadStateTermination(
void CrossThreadPersistentRegion::PrepareForThreadStateTermination(
ThreadState* thread_state) {
// For heaps belonging to a thread that's detaching, any cross-thread
// persistents pointing into them needs to be disabled. Do that by clearing
......@@ -175,7 +175,7 @@ void CrossThreadPersistentRegions::PrepareForThreadStateTermination(
}
#if defined(ADDRESS_SANITIZER)
void CrossThreadPersistentRegions::UnpoisonCrossThreadPersistents() {
void CrossThreadPersistentRegion::UnpoisonCrossThreadPersistents() {
MutexLocker lock(mutex_);
int persistent_count = 0;
for (PersistentNodeSlots* slots = persistent_region_->slots_; slots;
......
......@@ -15,7 +15,7 @@
namespace blink {
class CrossThreadPersistentRegions;
class CrossThreadPersistentRegion;
class PersistentNode final {
DISALLOW_NEW();
......@@ -93,7 +93,7 @@ struct PersistentNodeSlots final {
PersistentNodeSlots* next_;
PersistentNode slot_[kSlotCount];
friend class PersistentRegion;
friend class CrossThreadPersistentRegions;
friend class CrossThreadPersistentRegion;
};
// PersistentRegion provides a region of PersistentNodes. PersistentRegion
......@@ -153,7 +153,7 @@ class PLATFORM_EXPORT PersistentRegion final {
int NumberOfPersistents();
private:
friend CrossThreadPersistentRegions;
friend CrossThreadPersistentRegion;
void EnsurePersistentNodeSlots(void*, TraceCallback);
......@@ -164,11 +164,11 @@ class PLATFORM_EXPORT PersistentRegion final {
#endif
};
class CrossThreadPersistentRegions final {
USING_FAST_MALLOC(CrossThreadPersistentRegions);
class CrossThreadPersistentRegion final {
USING_FAST_MALLOC(CrossThreadPersistentRegion);
public:
CrossThreadPersistentRegions()
CrossThreadPersistentRegion()
: persistent_region_(WTF::WrapUnique(new PersistentRegion)) {}
void AllocatePersistentNode(PersistentNode*& persistent_node,
......@@ -202,7 +202,7 @@ class CrossThreadPersistentRegions final {
STACK_ALLOCATED();
public:
LockScope(CrossThreadPersistentRegions& persistent_region,
LockScope(CrossThreadPersistentRegion& persistent_region,
bool try_lock = false)
: persistent_region_(persistent_region), locked_(true) {
if (try_lock)
......@@ -221,7 +221,7 @@ class CrossThreadPersistentRegions final {
bool HasLock() const { return locked_; }
private:
CrossThreadPersistentRegions& persistent_region_;
CrossThreadPersistentRegion& persistent_region_;
bool locked_;
};
......@@ -231,7 +231,7 @@ class CrossThreadPersistentRegions final {
DCHECK(mutex_.Locked());
#endif
persistent_region_->TracePersistentNodes(
visitor, CrossThreadPersistentRegions::ShouldTracePersistentNode);
visitor, CrossThreadPersistentRegion::ShouldTracePersistentNode);
}
void PrepareForThreadStateTermination(ThreadState*);
......@@ -252,14 +252,14 @@ class CrossThreadPersistentRegions final {
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
// such as PersistentRegion::allocate/freePersistentNode.
std::unique_ptr<PersistentRegion> persistent_region_;
// Recursive as prepareForThreadStateTermination() clears a PersistentNode's
// 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.
RecursiveMutex mutex_;
};
......
......@@ -197,7 +197,7 @@ void ThreadState::RunTerminationGC() {
ReleaseStaticPersistentNodes();
ProcessHeap::GetCrossThreadPersistentRegions()
ProcessHeap::GetCrossThreadPersistentRegion()
.PrepareForThreadStateTermination(this);
// 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,
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
// allocate or free PersistentNodes and we can't handle
// that. Grabbing this lock also prevents non-attached threads
// from accessing any GCed heap while a GC runs.
CrossThreadPersistentRegions::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegions());
CrossThreadPersistentRegion::LockScope persistent_lock(
ProcessHeap::GetCrossThreadPersistentRegion());
{
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