Commit 48738fe7 authored by Anton Bikineev's avatar Anton Bikineev Committed by Commit Bot

PartitionAlloc: Encapsulate giga-cage checks in a per-root function.

This is to make it less error prone if checks are augmented in one
place but not in the other.

Bug: 11297512
Change-Id: Id5518f703bf7240f8634570996eb5ec4eda10f94
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2471332
Commit-Queue: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: default avatarTakashi Sakamoto <tasak@google.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819314}
parent e95f1520
...@@ -50,7 +50,7 @@ PartitionDirectMap(PartitionRoot<thread_safe>* root, int flags, size_t raw_size) ...@@ -50,7 +50,7 @@ PartitionDirectMap(PartitionRoot<thread_safe>* root, int flags, size_t raw_size)
// Allocate from GigaCage, if enabled. However, the exception to this is when // Allocate from GigaCage, if enabled. However, the exception to this is when
// tags aren't allowed, as CheckedPtr assumes that everything inside GigaCage // tags aren't allowed, as CheckedPtr assumes that everything inside GigaCage
// uses tags (specifically, inside the GigaCage's normal bucket pool). // uses tags (specifically, inside the GigaCage's normal bucket pool).
if (root->allow_extras && features::IsPartitionAllocGigaCageEnabled()) { if (root->UsesGigaCage()) {
ptr = internal::AddressPoolManager::GetInstance()->Alloc(GetDirectMapPool(), ptr = internal::AddressPoolManager::GetInstance()->Alloc(GetDirectMapPool(),
nullptr, map_size); nullptr, map_size);
} else { } else {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ROOT_H_ #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PARTITION_ROOT_H_
#include "base/allocator/partition_allocator/partition_alloc_constants.h" #include "base/allocator/partition_allocator/partition_alloc_constants.h"
#include "base/allocator/partition_allocator/partition_alloc_features.h"
#include "base/allocator/partition_allocator/partition_alloc_forward.h" #include "base/allocator/partition_allocator/partition_alloc_forward.h"
#include "base/allocator/partition_allocator/partition_direct_map_extent.h" #include "base/allocator/partition_allocator/partition_direct_map_extent.h"
#include "base/allocator/partition_allocator/partition_lock.h" #include "base/allocator/partition_allocator/partition_lock.h"
...@@ -220,6 +221,10 @@ struct BASE_EXPORT PartitionRoot { ...@@ -220,6 +221,10 @@ struct BASE_EXPORT PartitionRoot {
#endif #endif
} }
bool UsesGigaCage() const {
return features::IsPartitionAllocGigaCageEnabled() && allow_extras;
}
private: private:
// Allocates memory, without initializing extras. // Allocates memory, without initializing extras.
// //
......
...@@ -237,7 +237,7 @@ size_t NO_SANITIZE("thread") PCScan<thread_safe>::PCScanTask::ScanPartition() { ...@@ -237,7 +237,7 @@ size_t NO_SANITIZE("thread") PCScan<thread_safe>::PCScanTask::ScanPartition() {
#if defined(PA_HAS_64_BITS_POINTERS) #if defined(PA_HAS_64_BITS_POINTERS)
// On partitions without extras (partitions with aligned allocations), // On partitions without extras (partitions with aligned allocations),
// memory is not allocated from the GigaCage. // memory is not allocated from the GigaCage.
if (features::IsPartitionAllocGigaCageEnabled() && root_.allow_extras) { if (root_.UsesGigaCage()) {
// With GigaCage, we first do a fast bitmask check to see if the pointer // With GigaCage, we first do a fast bitmask check to see if the pointer
// points to the normal bucket pool. // points to the normal bucket pool.
if (!PartitionAddressSpace::IsInNormalBucketPool( if (!PartitionAddressSpace::IsInNormalBucketPool(
......
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