Commit 5ad725de authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Have CrossThreadPersistentRegion hold the underlying PersistentRegion as a plain member.

There's a comment justifying not using it as a base class, but nothing prevents
using it as a member, which allows this class to be initialized without dynamic
allocation.

Change-Id: I37bf13c4c7c226a88ccf488f5db7f100293fdd1d
Reviewed-on: https://chromium-review.googlesource.com/1076906Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562832}
parent ce09732e
......@@ -169,7 +169,7 @@ void CrossThreadPersistentRegion::PrepareForThreadStateTermination(
// out the underlying heap reference.
RecursiveMutexLocker lock(ProcessHeap::CrossThreadPersistentMutex());
PersistentNodeSlots* slots = persistent_region_->slots_;
PersistentNodeSlots* slots = persistent_region_.slots_;
while (slots) {
for (int i = 0; i < PersistentNodeSlots::kSlotCount; ++i) {
if (slots->slot_[i].IsUnused())
......@@ -199,7 +199,7 @@ void CrossThreadPersistentRegion::PrepareForThreadStateTermination(
void CrossThreadPersistentRegion::UnpoisonCrossThreadPersistents() {
RecursiveMutexLocker lock(ProcessHeap::CrossThreadPersistentMutex());
int persistent_count = 0;
for (PersistentNodeSlots* slots = persistent_region_->slots_; slots;
for (PersistentNodeSlots* slots = persistent_region_.slots_; slots;
slots = slots->next_) {
for (int i = 0; i < PersistentNodeSlots::kSlotCount; ++i) {
const PersistentNode& node = slots->slot_[i];
......@@ -211,7 +211,7 @@ void CrossThreadPersistentRegion::UnpoisonCrossThreadPersistents() {
}
}
#if DCHECK_IS_ON()
DCHECK_EQ(persistent_count, persistent_region_->persistent_count_);
DCHECK_EQ(persistent_count, persistent_region_.persistent_count_);
#endif
}
#endif
......
......@@ -169,15 +169,12 @@ class CrossThreadPersistentRegion final {
USING_FAST_MALLOC(CrossThreadPersistentRegion);
public:
CrossThreadPersistentRegion()
: persistent_region_(std::make_unique<PersistentRegion>()) {}
void AllocatePersistentNode(PersistentNode*& persistent_node,
void* self,
TraceCallback trace) {
RecursiveMutexLocker lock(ProcessHeap::CrossThreadPersistentMutex());
PersistentNode* node =
persistent_region_->AllocatePersistentNode(self, trace);
persistent_region_.AllocatePersistentNode(self, trace);
ReleaseStore(reinterpret_cast<void* volatile*>(&persistent_node), node);
}
......@@ -195,7 +192,7 @@ class CrossThreadPersistentRegion final {
// check for this.
if (!persistent_node)
return;
persistent_region_->FreePersistentNode(persistent_node);
persistent_region_.FreePersistentNode(persistent_node);
ReleaseStore(reinterpret_cast<void* volatile*>(&persistent_node), nullptr);
}
......@@ -204,7 +201,7 @@ class CrossThreadPersistentRegion final {
#if DCHECK_IS_ON()
DCHECK(ProcessHeap::CrossThreadPersistentMutex().Locked());
#endif
persistent_region_->TracePersistentNodes(
persistent_region_.TracePersistentNodes(
visitor, CrossThreadPersistentRegion::ShouldTracePersistentNode);
}
......@@ -222,7 +219,7 @@ class CrossThreadPersistentRegion final {
// 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_;
PersistentRegion persistent_region_;
};
} // namespace blink
......
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