Commit 13a5be8c authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

PartitionAlloc: PCScan: Perform scan only when quarantine is not empty.

Bug: 11297512
Change-Id: I7bf329df83e8ae0185578cc0bf1b68090a937b4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2547323Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMichael Lippautz <mlippautz@chromium.org>
Reviewed-by: default avatarHannes Payer <hpayer@chromium.org>
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828955}
parent 6f71665a
...@@ -610,7 +610,7 @@ template <bool thread_safe> ...@@ -610,7 +610,7 @@ template <bool thread_safe>
void PartitionRoot<thread_safe>::PurgeMemory(int flags) { void PartitionRoot<thread_safe>::PurgeMemory(int flags) {
// TODO(chromium:1129751): Change to LIKELY once PCScan is enabled by default. // TODO(chromium:1129751): Change to LIKELY once PCScan is enabled by default.
if (UNLIKELY(pcscan)) { if (UNLIKELY(pcscan)) {
pcscan->PerformScan( pcscan->PerformScanIfNeeded(
internal::PCScan<thread_safe>::InvocationMode::kBlocking); internal::PCScan<thread_safe>::InvocationMode::kBlocking);
} }
......
...@@ -484,6 +484,13 @@ void PCScan<thread_safe>::PerformScan(InvocationMode invocation_mode) { ...@@ -484,6 +484,13 @@ void PCScan<thread_safe>::PerformScan(InvocationMode invocation_mode) {
} }
} }
template <bool thread_safe>
void PCScan<thread_safe>::PerformScanIfNeeded(InvocationMode invocation_mode) {
// Perform PCScan only if quarantine is not empty.
if (quarantine_data_.size())
PerformScan(invocation_mode);
}
template class PCScan<ThreadSafe>; template class PCScan<ThreadSafe>;
template class PCScan<NotThreadSafe>; template class PCScan<NotThreadSafe>;
......
...@@ -53,7 +53,7 @@ class BASE_EXPORT PCScan final { ...@@ -53,7 +53,7 @@ class BASE_EXPORT PCScan final {
ALWAYS_INLINE void MoveToQuarantine(void* ptr, SlotSpan* slot_span); ALWAYS_INLINE void MoveToQuarantine(void* ptr, SlotSpan* slot_span);
void PerformScan(InvocationMode invocation_mode); void PerformScanIfNeeded(InvocationMode invocation_mode);
private: private:
class PCScanTask; class PCScanTask;
...@@ -82,6 +82,8 @@ class BASE_EXPORT PCScan final { ...@@ -82,6 +82,8 @@ class BASE_EXPORT PCScan final {
size_t last_size_ = 0; size_t last_size_ = 0;
}; };
void PerformScan(InvocationMode invocation_mode);
Root* root_; Root* root_;
QuarantineData quarantine_data_; QuarantineData quarantine_data_;
std::atomic<bool> in_progress_{false}; std::atomic<bool> in_progress_{false};
......
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