0

Use partition_alloc PA_BUILDFLAG(...) outside PA. #cleanup

This is an automated #cleanup patch.

Migrate:
- from  BUILDFLAG (legacy chromium macro)
- to PA_BUILDFLAG (new partition_alloc macro)

The first is going to be removed in favor of the second.

The previous patch modified every occurrences inside partition_alloc,
this one does the same, but outside of partition_alloc.

Follow-ups will:
- Update dawn.
- Update pdfium.

Bug: chromium:1508847
Change-Id: Icc3fa34ee376e5ae866e9d456c363cb4180d4a49
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5490530
Reviewed-by: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1294381}
This commit is contained in:
Arthur Sonzogni
2024-04-30 16:09:43 +00:00
committed by Chromium LUCI CQ
parent ef463f02db
commit 62e877adbf
90 changed files with 484 additions and 475 deletions
PRESUBMIT_test.py
base
chrome
chromeos/ash/components/memory/userspace_swap
components
content
gin
ios/chrome
media/base
third_party
blink
renderer
crashpad
ui/ozone/platform/wayland

@ -4761,7 +4761,7 @@ class VerifyDcheckParentheses(unittest.TestCase):
# own thing at their own risk.
MockFile('okay3.cc', ['PA_DCHECK_IS_ON']),
MockFile('okay4.cc', ['#if PA_DCHECK_IS_ON']),
MockFile('okay6.cc', ['BUILDFLAG(PA_DCHECK_IS_ON)']),
MockFile('okay6.cc', ['PA_BUILDFLAG(PA_DCHECK_IS_ON)']),
]
errors = PRESUBMIT.CheckDCHECK_IS_ONHasBraces(input_api, MockOutputApi())
self.assertEqual(0, len(errors))

@ -22,12 +22,13 @@
namespace base::allocator {
bool IsAllocatorInitialized() {
#if BUILDFLAG(IS_WIN) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_WIN) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// Set by allocator_shim_override_ucrt_symbols_win.h when the
// shimmed _set_new_mode() is called.
return allocator_shim::g_is_win_shim_layer_initialized;
#elif BUILDFLAG(IS_APPLE) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
!BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_ALLOCATOR_SHIM)
!PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// From allocator_interception_mac.mm.
return allocator_shim::g_replaced_default_zone;
#else

@ -15,7 +15,7 @@
#include <atomic>
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/partition_alloc_hooks.h"
#endif
@ -51,13 +51,13 @@ struct Dispatcher::Impl {
// connected. This way we prevent notifications although no observers are
// present.
static void ConnectToEmitters(const internal::DispatchData& dispatch_data) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch()) {
allocator_shim::InsertAllocatorDispatch(allocator_dispatch);
}
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
{
auto* const allocation_hook = dispatch_data.GetAllocationObserverHook();
auto* const free_hook = dispatch_data.GetFreeObserverHook();
@ -70,14 +70,14 @@ struct Dispatcher::Impl {
}
static void DisconnectFromEmitters(internal::DispatchData& dispatch_data) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (auto* const allocator_dispatch = dispatch_data.GetAllocatorDispatch()) {
allocator_shim::RemoveAllocatorDispatchForTesting(
allocator_dispatch); // IN-TEST
}
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
partition_alloc::PartitionAllocHooks::SetObserverHooks(nullptr, nullptr);
#endif
}

@ -13,11 +13,11 @@
#include "build/build_config.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/partition_alloc_for_testing.h"
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif
@ -94,7 +94,8 @@ TEST_F(BaseAllocatorDispatcherTest, VerifyInitialization) {
DispatcherInitializerGuard g(testing::CreateTupleOfPointers(observers));
}
#if BUILDFLAG(USE_PARTITION_ALLOC) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC) && \
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
// Don't enable this test when MEMORY_TOOL_REPLACES_ALLOCATOR is defined,
// because it makes PartitionAlloc take a different path that doesn't provide
// notifications to observer hooks.
@ -117,13 +118,13 @@ TEST_F(BaseAllocatorDispatcherTest, VerifyNotificationUsingPartitionAllocator) {
}
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
struct AllocatorShimAllocator {
void* Alloc(size_t size) { return allocator_shim::UncheckedAlloc(size); }
void Free(void* data) { allocator_shim::UncheckedFree(data); }
};
#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Disable the test when running on any of Apple's OSs without PartitionAlloc
// being the default allocator. In this case, all allocations are routed to
// MallocImpl, which then causes the test to terminate unexpectedly.

@ -7,7 +7,7 @@
namespace base::allocator::dispatcher::internal {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
DispatchData& DispatchData::SetAllocationObserverHooks(
AllocationObserverHook* allocation_observer_hook,
@ -28,7 +28,7 @@ DispatchData::FreeObserverHook* DispatchData::GetFreeObserverHook() const {
}
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
DispatchData& DispatchData::SetAllocatorDispatch(
AllocatorDispatch* allocator_dispatch) {
allocator_dispatch_ = allocator_dispatch;

@ -9,24 +9,24 @@
#include "build/build_config.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/partition_alloc_hooks.h"
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif
namespace base::allocator::dispatcher::internal {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
using allocator_shim::AllocatorDispatch;
#endif
// A simple utility class to pass all the information required to properly hook
// into the memory allocation subsystems from DispatcherImpl to the Dispatcher.
struct BASE_EXPORT DispatchData {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
using AllocationObserverHook =
partition_alloc::PartitionAllocHooks::AllocationObserverHook;
using FreeObserverHook =
@ -44,7 +44,7 @@ struct BASE_EXPORT DispatchData {
public:
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
DispatchData& SetAllocatorDispatch(AllocatorDispatch* allocator_dispatch);
AllocatorDispatch* GetAllocatorDispatch() const;

@ -15,11 +15,11 @@
#include "base/compiler_specific.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/partition_alloc_allocation_data.h"
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif
@ -27,7 +27,7 @@
namespace base::allocator::dispatcher::internal {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
using allocator_shim::AllocatorDispatch;
#endif
@ -83,17 +83,17 @@ struct DispatcherImpl {
private:
static DispatchData CreateDispatchData() {
return DispatchData()
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
.SetAllocationObserverHooks(&PartitionAllocatorAllocationHook,
&PartitionAllocatorFreeHook)
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
.SetAllocatorDispatch(&allocator_dispatch_)
#endif
;
}
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
static void PartitionAllocatorAllocationHook(
const partition_alloc::AllocationNotificationData& pa_notification_data) {
AllocationNotificationData dispatcher_notification_data(
@ -101,7 +101,7 @@ struct DispatcherImpl {
pa_notification_data.type_name(),
AllocationSubsystem::kPartitionAllocator);
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
dispatcher_notification_data.SetMteReportingMode(
ConvertToMTEMode(pa_notification_data.mte_reporting_mode()));
#endif
@ -115,16 +115,16 @@ struct DispatcherImpl {
pa_notification_data.address(),
AllocationSubsystem::kPartitionAllocator);
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
dispatcher_notification_data.SetMteReportingMode(
ConvertToMTEMode(pa_notification_data.mte_reporting_mode()));
#endif
DoNotifyFree(dispatcher_notification_data);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
static void* AllocFn(const AllocatorDispatch* self,
size_t size,
void* context) {
@ -286,7 +286,7 @@ struct DispatcherImpl {
}
static AllocatorDispatch allocator_dispatch_;
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
ALWAYS_INLINE static void DoNotifyAllocation(
const AllocationNotificationData& notification_data) {
@ -305,7 +305,7 @@ struct DispatcherImpl {
template <typename... ObserverTypes>
std::tuple<ObserverTypes*...> DispatcherImpl<ObserverTypes...>::s_observers;
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
template <typename... ObserverTypes>
AllocatorDispatch DispatcherImpl<ObserverTypes...>::allocator_dispatch_ = {
AllocFn, // alloc_function
@ -326,7 +326,7 @@ AllocatorDispatch DispatcherImpl<ObserverTypes...>::allocator_dispatch_ = {
AlignedFreeFn, // aligned_free_function
nullptr // next
};
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// Specialization of DispatcherImpl in case we have no observers to notify. In
// this special case we return a set of null pointers as the Dispatcher must not
@ -335,10 +335,10 @@ template <>
struct DispatcherImpl<> {
static DispatchData GetNotificationHooks(std::tuple<> /*observers*/) {
return DispatchData()
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
.SetAllocationObserverHooks(nullptr, nullptr)
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
.SetAllocatorDispatch(nullptr)
#endif
;

@ -16,7 +16,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/partition_alloc_allocation_data.h"
#endif
@ -57,14 +57,14 @@ auto FreeNotificationMatches(
std::move(subsystem_matcher)));
}
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
::partition_alloc::AllocationNotificationData CreatePAAllocationData(
void* address,
size_t size,
partition_alloc::TagViolationReportingMode mte_mode =
partition_alloc::TagViolationReportingMode::kUndefined) {
return ::partition_alloc::AllocationNotificationData(address, size, nullptr)
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
.SetMteReportingMode(mte_mode)
#endif
;
@ -75,12 +75,12 @@ auto FreeNotificationMatches(
partition_alloc::TagViolationReportingMode mte_mode =
partition_alloc::TagViolationReportingMode::kUndefined) {
return ::partition_alloc::FreeNotificationData(address)
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
.SetMteReportingMode(mte_mode)
#endif
;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
struct AllocationEventDispatcherInternalTest : public DispatcherTest {
static void* GetAllocatedAddress() {
@ -92,7 +92,7 @@ struct AllocationEventDispatcherInternalTest : public DispatcherTest {
return reinterpret_cast<void*>(0x876543210);
}
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
AllocatorDispatch* GetNextAllocatorDispatch() { return &allocator_dispatch_; }
static void* alloc_function(const AllocatorDispatch*, size_t, void*) {
return GetAllocatedAddress();
@ -197,7 +197,7 @@ TEST(AllocationEventDispatcherInternalDeathTest,
#endif // defined(GTEST_HAS_DEATH_TEST) && GTEST_HAS_DEATH_TEST &&
// DCHECK_IS_ON()
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
TEST_F(AllocationEventDispatcherInternalTest,
VerifyPartitionAllocatorHooksAreSet) {
std::array<ObserverMock, 1> observers;
@ -253,9 +253,9 @@ TEST_F(AllocationEventDispatcherInternalTest,
dispatch_data.GetFreeObserverHook()(CreatePAFreeData(this));
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
TEST_F(AllocationEventDispatcherInternalTest, VerifyAllocatorShimDataIsSet) {
std::array<ObserverMock, 1> observers;
@ -619,5 +619,5 @@ TEST_F(AllocationEventDispatcherInternalTest,
allocator_dispatch->aligned_free_function(allocator_dispatch,
GetFreedAddress(), nullptr);
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
} // namespace base::allocator::dispatcher::internal

@ -42,28 +42,28 @@ class BASE_EXPORT AllocationNotificationData {
// In the allocation observer path, it's interesting which reporting mode is
// enabled.
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
constexpr AllocationNotificationData& SetMteReportingMode(MTEMode mode) {
mte_reporting_mode_ = mode;
return *this;
}
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
constexpr MTEMode mte_reporting_mode() const {
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
return mte_reporting_mode_;
#else
return MTEMode::kUndefined;
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
}
private:
void* address_ = nullptr;
size_t size_ = 0;
const char* type_name_ = nullptr;
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
MTEMode mte_reporting_mode_ = MTEMode::kUndefined;
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
AllocationSubsystem allocation_subsystem_;
};
@ -83,26 +83,26 @@ class BASE_EXPORT FreeNotificationData {
// In the free observer path, it's interesting which reporting mode is
// enabled.
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
constexpr FreeNotificationData& SetMteReportingMode(MTEMode mode) {
mte_reporting_mode_ = mode;
return *this;
}
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
constexpr MTEMode mte_reporting_mode() const {
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
return mte_reporting_mode_;
#else
return MTEMode::kUndefined;
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
}
private:
void* address_ = nullptr;
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
MTEMode mte_reporting_mode_ = MTEMode::kUndefined;
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
AllocationSubsystem allocation_subsystem_;
};

@ -17,7 +17,7 @@
namespace partition_alloc {
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
void EarlyMallocZoneRegistration() {}
void AllowDoublePartitionAllocZoneRegistration() {}
@ -262,5 +262,5 @@ void AllowDoublePartitionAllocZoneRegistration() {
}
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
} // namespace partition_alloc

@ -42,7 +42,7 @@ const base::FeatureParam<UnretainedDanglingPtrMode>
BASE_FEATURE(kPartitionAllocDanglingPtr,
"PartitionAllocDanglingPtr",
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_FEATURE_FLAG)
FEATURE_ENABLED_BY_DEFAULT
#else
FEATURE_DISABLED_BY_DEFAULT
@ -70,15 +70,15 @@ const base::FeatureParam<DanglingPtrType> kDanglingPtrTypeParam{
&kDanglingPtrTypeOption,
};
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
// If enabled, PCScan is turned on by default for all partitions that don't
// disable it explicitly.
BASE_FEATURE(kPartitionAllocPCScan,
"PartitionAllocPCScan",
FEATURE_DISABLED_BY_DEFAULT);
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// If enabled, PCScan is turned on only for the browser's malloc partition.
BASE_FEATURE(kPartitionAllocPCScanBrowserOnly,
"PartitionAllocPCScanBrowserOnly",
@ -122,14 +122,14 @@ const base::FeatureParam<int>
BASE_FEATURE(kPartitionAllocZappingByFreeFlags,
"PartitionAllocZappingByFreeFlags",
FEATURE_DISABLED_BY_DEFAULT);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
BASE_FEATURE(kPartitionAllocBackupRefPtr,
"PartitionAllocBackupRefPtr",
#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || \
BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_CHROMEOS_LACROS) || \
(BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CASTOS)) || \
BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG)
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_FEATURE_FLAG)
FEATURE_ENABLED_BY_DEFAULT
#else
FEATURE_DISABLED_BY_DEFAULT
@ -162,7 +162,7 @@ const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{
BASE_FEATURE(kPartitionAllocMemoryTagging,
"PartitionAllocMemoryTagging",
#if BUILDFLAG(USE_FULL_MTE)
#if PA_BUILDFLAG(USE_FULL_MTE)
FEATURE_ENABLED_BY_DEFAULT
#else
FEATURE_DISABLED_BY_DEFAULT
@ -175,7 +175,7 @@ constexpr FeatureParam<MemtagMode>::Option kMemtagModeOptions[] = {
const base::FeatureParam<MemtagMode> kMemtagModeParam{
&kPartitionAllocMemoryTagging, "memtag-mode",
#if BUILDFLAG(USE_FULL_MTE)
#if PA_BUILDFLAG(USE_FULL_MTE)
MemtagMode::kSync,
#else
MemtagMode::kAsync,
@ -191,7 +191,7 @@ constexpr FeatureParam<MemoryTaggingEnabledProcesses>::Option
const base::FeatureParam<MemoryTaggingEnabledProcesses>
kMemoryTaggingEnabledProcessesParam{
&kPartitionAllocMemoryTagging, "enabled-processes",
#if BUILDFLAG(USE_FULL_MTE)
#if PA_BUILDFLAG(USE_FULL_MTE)
MemoryTaggingEnabledProcesses::kAllProcesses,
#else
MemoryTaggingEnabledProcesses::kBrowserOnly,
@ -205,7 +205,7 @@ BASE_FEATURE(kKillPartitionAllocMemoryTagging,
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPermissiveMte);
BASE_FEATURE(kPartitionAllocPermissiveMte,
"PartitionAllocPermissiveMte",
#if BUILDFLAG(USE_FULL_MTE)
#if PA_BUILDFLAG(USE_FULL_MTE)
// We want to actually crash if USE_FULL_MTE is enabled.
FEATURE_DISABLED_BY_DEFAULT
#else
@ -283,11 +283,11 @@ BASE_FEATURE(kPartitionAllocPCScanEagerClearing,
// In addition to heap, scan also the stack of the current mutator.
BASE_FEATURE(kPartitionAllocPCScanStackScanning,
"PartitionAllocPCScanStackScanning",
#if BUILDFLAG(STACK_SCAN_SUPPORTED)
#if PA_BUILDFLAG(STACK_SCAN_SUPPORTED)
FEATURE_ENABLED_BY_DEFAULT
#else
FEATURE_DISABLED_BY_DEFAULT
#endif // BUILDFLAG(STACK_SCAN_SUPPORTED)
#endif // PA_BUILDFLAG(STACK_SCAN_SUPPORTED)
);
BASE_FEATURE(kPartitionAllocDCScan,
@ -430,7 +430,7 @@ BASE_FEATURE(kPartitionAllocDisableBRPInBufferPartition,
"PartitionAllocDisableBRPInBufferPartition",
FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(USE_FREELIST_DISPATCHER)
#if PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
BASE_FEATURE(kUsePoolOffsetFreelists,
"PartitionAllocUsePoolOffsetFreelists",
base::FEATURE_DISABLED_BY_DEFAULT);
@ -469,17 +469,17 @@ void MakeFreeNoOp(WhenFreeBecomesNoOp callsite) {
// Note: For now, the DanglingPointerDetector is only enabled on 5 bots, and
// on linux non-official configuration.
// TODO(b/40802063): Reconsider this decision after the experiment.
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
if (base::FeatureList::IsEnabled(features::kPartitionAllocDanglingPtr)) {
return;
}
#endif // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (base::FeatureList::IsEnabled(kPartitionAllocMakeFreeNoOpOnShutdown) &&
kPartitionAllocMakeFreeNoOpOnShutdownParam.Get() == callsite) {
allocator_shim::InsertNoOpOnFreeAllocatorShimOnShutDown();
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
BASE_FEATURE(kPartitionAllocAdjustSizeWhenInForeground,

@ -59,10 +59,10 @@ enum class DanglingPtrType {
extern const BASE_EXPORT base::FeatureParam<DanglingPtrType>
kDanglingPtrTypeParam;
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScan);
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanBrowserOnly);
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanRendererOnly);
@ -77,7 +77,7 @@ extern const BASE_EXPORT base::FeatureParam<int>
kPartitionAllocSchedulerLoopQuarantineBranchCapacity;
BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocZappingByFreeFlags);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
enum class BackupRefPtrEnabledProcesses {
// BRP enabled only in the browser process.
@ -209,7 +209,7 @@ BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDisableBRPInBufferPartition);
// This feature is additionally gated behind a buildflag because
// pool offset freelists cannot be represented when PartitionAlloc uses
// 32-bit pointers.
#if BUILDFLAG(USE_FREELIST_DISPATCHER)
#if PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
BASE_EXPORT BASE_DECLARE_FEATURE(kUsePoolOffsetFreelists);
#endif

@ -59,23 +59,23 @@
#include "partition_alloc/stack/stack.h"
#include "partition_alloc/thread_cache.h"
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
#include "partition_alloc/shim/nonscannable_allocator.h"
#include "partition_alloc/starscan/pcscan.h"
#include "partition_alloc/starscan/pcscan_scheduling.h"
#include "partition_alloc/starscan/stats_collector.h"
#include "partition_alloc/starscan/stats_reporter.h"
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
#if BUILDFLAG(IS_ANDROID)
#include "base/system/sys_info.h"
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/memory_reclaimer.h"
#endif
#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(HAS_MEMORY_TAGGING)
#if BUILDFLAG(IS_ANDROID) && PA_BUILDFLAG(HAS_MEMORY_TAGGING)
#include <sys/system_properties.h>
#endif
@ -83,7 +83,7 @@ namespace base::allocator {
namespace {
#if BUILDFLAG(IS_ANDROID) && BUILDFLAG(HAS_MEMORY_TAGGING)
#if BUILDFLAG(IS_ANDROID) && PA_BUILDFLAG(HAS_MEMORY_TAGGING)
enum class BootloaderOverride {
kDefault,
kForceOn,
@ -119,13 +119,13 @@ constexpr base::TimeDelta kFirstPAPurgeOrReclaimDelay = base::Minutes(1);
namespace switches {
[[maybe_unused]] constexpr char kRendererProcess[] = "renderer";
constexpr char kZygoteProcess[] = "zygote";
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
constexpr char kGpuProcess[] = "gpu-process";
constexpr char kUtilityProcess[] = "utility";
#endif
} // namespace switches
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
#if BUILDFLAG(ENABLE_BASE_TRACING)
constexpr const char* ScannerIdToTracingString(
@ -226,11 +226,11 @@ class StatsReporterImpl final : public partition_alloc::StatsReporter {
static constexpr char kTraceCategory[] = "partition_alloc";
};
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
} // namespace
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
void RegisterPCScanStatsReporter() {
static StatsReporterImpl s_reporter;
static bool registered = false;
@ -240,7 +240,7 @@ void RegisterPCScanStatsReporter() {
partition_alloc::internal::PCScan::RegisterStatsReporter(&s_reporter);
registered = true;
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
namespace {
@ -379,7 +379,7 @@ void StartMemoryReclaimer(scoped_refptr<SequencedTaskRunner> task_runner) {
std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
std::map<std::string, std::string> trials;
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
trials.emplace("DanglingPointerDetector", "Enabled");
#else
trials.emplace("DanglingPointerDetector", "Disabled");
@ -389,7 +389,7 @@ std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
// manually in binary experiment patches.
trials.emplace("VectorRawPtrExperiment", "Disabled");
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocMemoryTagging)) {
bool has_mte = base::CPU::GetInstanceNoAllocation().has_mte();
@ -402,10 +402,10 @@ std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
BootloaderOverride bootloader_override = GetBootloaderOverride();
partition_alloc::TagViolationReportingMode reporting_mode =
partition_alloc::TagViolationReportingMode::kUndefined;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
reporting_mode = allocator_shim::internal::PartitionAllocMalloc::Allocator()
->memory_tagging_reporting_mode();
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
switch (bootloader_override) {
case BootloaderOverride::kDefault:
trials.emplace("MemoryTaggingBootloaderOverride", "Default");
@ -442,12 +442,12 @@ std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
}
#endif // BUILDFLAG(IS_ANDROID)
}
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
return trials;
}
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
namespace {
@ -705,7 +705,7 @@ void CheckDanglingRawPtrBufferEmpty() {
"Memory was released on:\n"
<< entry->task_trace << "\n"
<< entry->stack_trace << "\n";
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_INSTANCE_TRACER)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_INSTANCE_TRACER)
std::vector<std::array<const void*, 32>> stack_traces =
internal::InstanceTracer::GetStackTracesForDanglingRefs(entry->id);
for (const auto& raw_stack_trace : stack_traces) {
@ -786,9 +786,9 @@ void InstallDanglingRawPtrChecks() {
// is a dangling pointer, we should crash at some point. Consider providing an
// API to periodically check the buffer.
#else // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#else // PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
void InstallDanglingRawPtrChecks() {}
#endif // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#endif // PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
void UnretainedDanglingRawPtrDetectedDumpWithoutCrashing(uintptr_t id) {
PA_NO_CODE_FOLDING();
@ -834,7 +834,7 @@ void InstallUnretainedDanglingRawPtrChecks() {
namespace {
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
void SetProcessNameForPCScan(const std::string& process_type) {
const char* name = [&process_type] {
if (process_type.empty()) {
@ -859,7 +859,7 @@ void SetProcessNameForPCScan(const std::string& process_type) {
}
bool EnablePCScanForMallocPartitionsIfNeeded() {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::base::PlatformThread::SetThreadNameHook(
&base::PlatformThread::SetName);
@ -871,12 +871,12 @@ bool EnablePCScanForMallocPartitionsIfNeeded() {
base::allocator::RegisterPCScanStatsReporter();
return true;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return false;
}
bool EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded() {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
using Config = partition_alloc::internal::PCScan::InitConfig;
DCHECK(base::FeatureList::GetInstance());
if (base::FeatureList::IsEnabled(
@ -893,12 +893,12 @@ bool EnablePCScanForMallocPartitionsInBrowserProcessIfNeeded() {
base::allocator::RegisterPCScanStatsReporter();
return true;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return false;
}
bool EnablePCScanForMallocPartitionsInRendererProcessIfNeeded() {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
using Config = partition_alloc::internal::PCScan::InitConfig;
DCHECK(base::FeatureList::GetInstance());
if (base::FeatureList::IsEnabled(
@ -915,10 +915,10 @@ bool EnablePCScanForMallocPartitionsInRendererProcessIfNeeded() {
base::allocator::RegisterPCScanStatsReporter();
return true;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return false;
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
} // namespace
@ -981,9 +981,9 @@ PartitionAllocSupport::GetBrpConfiguration(const std::string& process_type) {
CHECK(base::FeatureList::GetInstance());
bool process_affected_by_brp_flag = false;
#if (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) || \
BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) || \
PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocBackupRefPtr)) {
// No specified process type means this is the Browser process.
@ -1005,13 +1005,13 @@ PartitionAllocSupport::GetBrpConfiguration(const std::string& process_type) {
break;
}
}
#endif // (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) ||
// BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) ||
// PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
const bool enable_brp =
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
// kDisabled is equivalent to !IsEnabled(kPartitionAllocBackupRefPtr).
process_affected_by_brp_flag &&
base::features::kBackupRefPtrModeParam.Get() !=
@ -1054,9 +1054,9 @@ void PartitionAllocSupport::ReconfigureEarlyish(
// These initializations are only relevant for PartitionAlloc-Everywhere
// builds.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
allocator_shim::EnablePartitionAllocMemoryReclaimer();
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
void PartitionAllocSupport::ReconfigureAfterZygoteFork(
@ -1125,7 +1125,7 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
[[maybe_unused]] BrpConfiguration brp_config =
GetBrpConfiguration(process_type);
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
if (brp_config.process_affected_by_brp_flag) {
base::RawPtrAsanService::GetInstance().Configure(
base::EnableDereferenceCheck(
@ -1140,9 +1140,9 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
base::EnableDereferenceCheck(false), base::EnableExtractionCheck(false),
base::EnableInstantiationCheck(false));
}
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
auto bucket_distribution = allocator_shim::BucketDistribution::kNeutral;
// No specified type means we are in the browser.
switch (process_type == ""
@ -1164,18 +1164,18 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
const bool zapping_by_free_flags = base::FeatureList::IsEnabled(
base::features::kPartitionAllocZappingByFreeFlags);
#if BUILDFLAG(USE_FREELIST_DISPATCHER)
#if PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
const bool use_pool_offset_freelists =
base::FeatureList::IsEnabled(base::features::kUsePoolOffsetFreelists);
#else
const bool use_pool_offset_freelists = false;
#endif // BUILDFLAG(USE_FREELIST_DISPATCHER)
#endif // PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
bool enable_memory_tagging = false;
partition_alloc::TagViolationReportingMode memory_tagging_reporting_mode =
partition_alloc::TagViolationReportingMode::kUndefined;
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
// ShouldEnableMemoryTagging() checks kKillPartitionAllocMemoryTagging but
// check here too to wrap the GetMemoryTaggingModeForCurrentThread() call.
if (!base::FeatureList::IsEnabled(
@ -1222,7 +1222,7 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
#endif // BUILDFLAG(IS_ANDROID)
}
}
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
if (enable_memory_tagging) {
CHECK((memory_tagging_reporting_mode ==
@ -1251,11 +1251,11 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
// 100 is a reasonable cap for this value.
UmaHistogramCounts100("Memory.PartitionAlloc.PartitionRoot.ExtrasSize",
int(extras_size));
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// If BRP is not enabled, check if any of PCScan flags is enabled.
[[maybe_unused]] bool scan_enabled = false;
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
if (!brp_config.enable_brp) {
scan_enabled = EnablePCScanForMallocPartitionsIfNeeded();
// No specified process type means this is the Browser process.
@ -1270,9 +1270,9 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
if (scan_enabled) {
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocPCScanStackScanning)) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::PCScan::EnableStackScanning();
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocPCScanImmediateFreeing)) {
@ -1286,13 +1286,13 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
SetProcessNameForPCScan(process_type);
}
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::StackTopRegistry::Get().NotifyThreadCreated(
partition_alloc::internal::GetStackTop());
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
// Non-quarantinable partition is dealing with hot V8's zone allocations.
// In case PCScan is enabled in Renderer, enable thread cache on this
// partition. At the same time, thread cache on the main(malloc) partition
@ -1302,7 +1302,7 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
.root()
->EnableThreadCacheIfSupported();
} else
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
{
allocator_shim::internal::PartitionAllocMalloc::Allocator()
->EnableThreadCacheIfSupported();
@ -1313,7 +1313,7 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
allocator_shim::internal::PartitionAllocMalloc::Allocator()
->EnableLargeEmptySlotSpanRing();
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if BUILDFLAG(IS_WIN)
// Browser process only, since this is the one we want to prevent from
@ -1345,7 +1345,7 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
}
#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// This should be called in specific processes, as the main thread is
// initialized later.
DCHECK(process_type != switches::kZygoteProcess);
@ -1406,9 +1406,9 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size_);
}
#endif // PA_CONFIG(THREAD_CACHE_SUPPORTED) &&
// BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocPCScanMUAwareScheduler)) {
// Assign PCScan a task-based scheduling backend.
@ -1420,9 +1420,9 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
partition_alloc::internal::PCScan::scheduler().SetNewSchedulingBackend(
*mu_aware_task_based_backend.get());
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
base::allocator::StartMemoryReclaimer(
base::SingleThreadTaskRunner::GetCurrentDefault());
#endif
@ -1441,7 +1441,7 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
}
void PartitionAllocSupport::OnForegrounded(bool has_main_frame) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
{
base::AutoLock scoped_lock(lock_);
if (established_process_type_ != switches::kRendererProcess) {
@ -1459,13 +1459,13 @@ void PartitionAllocSupport::OnForegrounded(bool has_main_frame) {
features::kPartitionAllocAdjustSizeWhenInForeground)) {
allocator_shim::AdjustDefaultAllocatorForForeground();
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
MemoryReclaimerSupport::Instance().SetForegrounded(true);
}
void PartitionAllocSupport::OnBackgrounded() {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
{
base::AutoLock scoped_lock(lock_);
if (established_process_type_ != switches::kRendererProcess) {
@ -1498,12 +1498,12 @@ void PartitionAllocSupport::OnBackgrounded() {
features::kPartitionAllocAdjustSizeWhenInForeground)) {
allocator_shim::AdjustDefaultAllocatorForBackground();
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
MemoryReclaimerSupport::Instance().SetForegrounded(false);
}
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
std::string PartitionAllocSupport::ExtractDanglingPtrSignatureForTests(
std::string stacktrace) {
return ExtractDanglingPtrSignature(stacktrace);

@ -20,7 +20,7 @@
namespace base::allocator {
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
BASE_EXPORT void RegisterPCScanStatsReporter();
#endif
@ -84,7 +84,7 @@ class BASE_EXPORT PartitionAllocSupport {
void OnForegrounded(bool has_main_frame);
void OnBackgrounded();
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
static std::string ExtractDanglingPtrSignatureForTests(
std::string stacktrace);
#endif
@ -112,7 +112,7 @@ class BASE_EXPORT PartitionAllocSupport {
std::string established_process_type_ GUARDED_BY(lock_) = "INVALID";
#if PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
size_t largest_cached_size_ =
::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold;
#endif

@ -30,7 +30,7 @@ TEST(PartitionAllocSupportTest,
std::string dpd_group =
ProposeSyntheticFinchTrials()["DanglingPointerDetector"];
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
EXPECT_EQ(dpd_group, "Enabled");
#else
EXPECT_EQ(dpd_group, "Disabled");
@ -38,7 +38,7 @@ TEST(PartitionAllocSupportTest,
}
// - Death tests misbehave on Android, http://crbug.com/643760.
#if BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS) && !BUILDFLAG(IS_ANDROID) && \
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS) && !BUILDFLAG(IS_ANDROID) && \
defined(GTEST_HAS_DEATH_TEST)
namespace {
@ -254,7 +254,7 @@ TEST(PartitionAllocDanglingPtrChecks,
#endif
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
TEST(PartitionAllocSupportTest,
ProposeSyntheticFinchTrials_MemoryTaggingDogfood) {
{
@ -283,7 +283,7 @@ TEST(PartitionAllocSupportTest,
EXPECT_EQ(group_iter->second, expectation);
}
}
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
class MemoryReclaimerSupportTest : public ::testing::Test {
public:

@ -86,7 +86,7 @@ class AllocationTraceRecorderTest : public Test {
MTEMode mte_mode = MTEMode::kUndefined) {
return AllocationNotificationData(address, size, nullptr,
AllocationSubsystem::kPartitionAllocator)
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
.SetMteReportingMode(mte_mode)
#endif
;
@ -96,7 +96,7 @@ class AllocationTraceRecorderTest : public Test {
MTEMode mte_mode = MTEMode::kUndefined) {
return FreeNotificationData(address,
AllocationSubsystem::kPartitionAllocator)
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
.SetMteReportingMode(mte_mode)
#endif
;

@ -29,7 +29,7 @@
#include "base/allocator/buildflags.h"
#include "partition_alloc/partition_alloc.h"
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif
@ -169,7 +169,7 @@ TEST_F(StackTraceTest, DebugOutputToStreamWithNullPrefix) {
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
// Since Mac's base::debug::StackTrace().Print() is not malloc-free, skip
// StackDumpSignalHandlerIsMallocFree if BUILDFLAG(IS_MAC).
#if BUILDFLAG(USE_ALLOCATOR_SHIM) && !BUILDFLAG(IS_MAC)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM) && !BUILDFLAG(IS_MAC)
namespace {
@ -252,7 +252,7 @@ TEST_F(StackTraceDeathTest, StackDumpSignalHandlerIsMallocFree) {
}(),
"\\[end of stack trace\\]\n");
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
namespace {

@ -1042,12 +1042,12 @@ struct Invoker<Traits, StorageType, R(UnboundArgs...)> {
BoundArgsTuple&& bound,
std::index_sequence<indices...>,
UnboundArgs&&... unbound_args) {
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
RawPtrAsanBoundArgTracker raw_ptr_asan_bound_arg_tracker;
raw_ptr_asan_bound_arg_tracker.AddArgs(
std::get<indices>(std::forward<BoundArgsTuple>(bound))...,
std::forward<UnboundArgs>(unbound_args)...);
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
using DecayedArgsTuple = std::decay_t<BoundArgsTuple>;
static constexpr bool kIsWeakCall =

@ -1898,8 +1898,8 @@ TEST(BindDeathTest, BanFirstOwnerOfRefCountedType) {
});
}
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
PA_BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
void HandleOOM(size_t unused_size) {
LOG(FATAL) << "Out of memory";
@ -2143,8 +2143,8 @@ TEST_F(BindUnretainedDanglingDeathTest, UnretainedWeakReceiverDangling) {
#endif // defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID)
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) &&
// BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) &&
// PA_BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
} // namespace
} // namespace base

@ -6,7 +6,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/shim/nonscannable_allocator.h"
#else
#include <stdlib.h>
@ -15,7 +15,7 @@
namespace base {
void* AllocNonScannable(size_t size) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return allocator_shim::NonScannableAllocator::Instance().Alloc(size);
#else
return ::malloc(size);
@ -23,7 +23,7 @@ void* AllocNonScannable(size_t size) {
}
void FreeNonScannable(void* ptr) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
allocator_shim::NonScannableAllocator::Instance().Free(ptr);
#else
return ::free(ptr);
@ -31,7 +31,7 @@ void FreeNonScannable(void* ptr) {
}
void* AllocNonQuarantinable(size_t size) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return allocator_shim::NonQuarantinableAllocator::Instance().Alloc(size);
#else
return ::malloc(size);
@ -39,7 +39,7 @@ void* AllocNonQuarantinable(size_t size) {
}
void FreeNonQuarantinable(void* ptr) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
allocator_shim::NonQuarantinableAllocator::Instance().Free(ptr);
#else
return ::free(ptr);

@ -6,7 +6,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <sanitizer/allocator_interface.h>
#include <sanitizer/asan_interface.h>
@ -67,4 +67,4 @@ void RawPtrAsanBoundArgTracker::Add(uintptr_t ptr) {
} // namespace base
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)

@ -7,7 +7,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <cstddef>
#include <cstdint>
#include <memory>
@ -119,5 +119,5 @@ class BASE_EXPORT RawPtrAsanBoundArgTracker {
} // namespace base
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // BASE_MEMORY_RAW_PTR_ASAN_BOUND_ARG_TRACKER_H_

@ -4,7 +4,7 @@
#include "base/memory/raw_ptr_asan_hooks.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <cstring>
@ -125,4 +125,4 @@ const RawPtrHooks* GetRawPtrAsanHooks() {
} // namespace base::internal
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)

@ -7,7 +7,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include "base/memory/raw_ptr.h"
@ -17,6 +17,6 @@ const RawPtrHooks* GetRawPtrAsanHooks();
}
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // BASE_MEMORY_RAW_PTR_ASAN_HOOKS_H_

@ -9,7 +9,7 @@
#include "base/memory/raw_ptr_asan_service.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <sanitizer/allocator_interface.h>
#include <sanitizer/asan_interface.h>
@ -368,4 +368,4 @@ void RawPtrAsanService::CrashOnDanglingInstantiation(
} // namespace base
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)

@ -7,7 +7,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <cstddef>
#include <cstdint>
@ -97,5 +97,5 @@ class BASE_EXPORT RawPtrAsanService {
} // namespace base
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // BASE_MEMORY_RAW_PTR_ASAN_SERVICE_H_

@ -4,7 +4,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#if PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#include <sanitizer/asan_interface.h>
#include <thread>
@ -450,4 +450,4 @@ TEST_F(AsanBackupRefPtrTest, DanglingUnretained) {
} // namespace base::internal
#endif // BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
#endif // PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)

@ -13,9 +13,9 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#include "partition_alloc/partition_alloc_constants.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// This header defines `ADVANCED_MEMORY_SAFETY_CHECKS()` macro.
// They can be used to specify a class/struct that is targeted to perform
@ -92,14 +92,14 @@ namespace {
// Allocator type traits.
constexpr bool ShouldUsePartitionAlloc(MemorySafetyCheck checks) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return static_cast<bool>(checks &
(MemorySafetyCheck::kForcePartitionAlloc |
MemorySafetyCheck::kSchedulerLoopQuarantine |
MemorySafetyCheck::kZapOnFree));
#else
return false;
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
// Returns |partition_alloc::AllocFlags| corresponding to |checks|.
@ -137,21 +137,21 @@ inline constexpr bool is_memory_safety_checked =
(get_memory_safety_checks<T> & c) == c;
// Allocator functions.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
ALWAYS_INLINE partition_alloc::PartitionRoot*
GetPartitionRootForMemorySafetyCheckedAllocation() {
return allocator_shim::internal::PartitionAllocMalloc::Allocator();
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
template <MemorySafetyCheck checks>
NOINLINE void* HandleMemorySafetyCheckedOperatorNew(std::size_t count) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if constexpr (ShouldUsePartitionAlloc(checks)) {
return GetPartitionRootForMemorySafetyCheckedAllocation()
->AllocInline<GetAllocFlags(checks)>(count);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return ::operator new(count);
}
@ -159,25 +159,25 @@ template <MemorySafetyCheck checks>
NOINLINE void* HandleMemorySafetyCheckedOperatorNew(
std::size_t count,
std::align_val_t alignment) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if constexpr (ShouldUsePartitionAlloc(checks)) {
return GetPartitionRootForMemorySafetyCheckedAllocation()
->AlignedAlloc<GetAllocFlags(checks)>(static_cast<size_t>(alignment),
count);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return ::operator new(count, alignment);
}
template <MemorySafetyCheck checks>
NOINLINE void HandleMemorySafetyCheckedOperatorDelete(void* ptr) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if constexpr (ShouldUsePartitionAlloc(checks)) {
GetPartitionRootForMemorySafetyCheckedAllocation()
->Free<GetFreeFlags(checks)>(ptr);
return;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
::operator delete(ptr);
}
@ -185,13 +185,13 @@ template <MemorySafetyCheck checks>
NOINLINE void HandleMemorySafetyCheckedOperatorDelete(
void* ptr,
std::align_val_t alignment) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if constexpr (ShouldUsePartitionAlloc(checks)) {
GetPartitionRootForMemorySafetyCheckedAllocation()
->Free<GetFreeFlags(checks)>(ptr);
return;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
::operator delete(ptr, alignment);
}

@ -113,10 +113,10 @@ TEST(MemorySafetyCheckTest, AllocatorFunctions) {
EXPECT_NE(ptr2, nullptr);
// AdvancedChecks is kForcePartitionAlloc.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
EXPECT_TRUE(partition_alloc::IsManagedByPartitionAlloc(
reinterpret_cast<uintptr_t>(ptr2)));
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// void operator delete(void* ptr);
delete ptr1;
@ -129,10 +129,10 @@ TEST(MemorySafetyCheckTest, AllocatorFunctions) {
EXPECT_NE(ptr2, nullptr);
// AdvancedChecks is kForcePartitionAlloc.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
EXPECT_TRUE(partition_alloc::IsManagedByPartitionAlloc(
reinterpret_cast<uintptr_t>(ptr2)));
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// void operator delete(void* ptr, std::align_val_t alignment)
::operator delete(ptr1, std::align_val_t(64));
@ -143,10 +143,10 @@ TEST(MemorySafetyCheckTest, AllocatorFunctions) {
EXPECT_NE(ptr3, nullptr);
// AlignedAdvancedChecks is kForcePartitionAlloc.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
EXPECT_TRUE(partition_alloc::IsManagedByPartitionAlloc(
reinterpret_cast<uintptr_t>(ptr3)));
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// void operator delete(void* ptr, std::align_val_t alignment)
delete ptr3;
@ -158,7 +158,7 @@ TEST(MemorySafetyCheckTest, AllocatorFunctions) {
ptr3 = new (data) AlignedAdvancedChecks();
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
TEST(MemorySafetyCheckTest, SchedulerLoopQuarantine) {
// The check is performed only if `kPartitionAllocSchedulerLoopQuarantine` is
@ -224,13 +224,13 @@ TEST(MemorySafetyCheckTest, ZapOnFree) {
// Dereferencing `ptr` is still undefiner behavior, but we can say it is
// somewhat defined as this test is gated behind
// `BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)`.
// `PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)`.
// I believe behavior here is concrete enough to be tested, but it can be
// affected by changes in PA. Please disable this test if it flakes.
EXPECT_NE(ptr->data[0], 'A');
}
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
} // namespace

@ -13,7 +13,7 @@
#include "build/build_config.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "partition_alloc/page_allocator.h"
#endif
@ -28,7 +28,7 @@ namespace base {
// Defined in memory_mac.mm for macOS + use_partition_alloc_as_malloc=false.
// In case of use_partition_alloc_as_malloc=true, no need to route the call to
// the system default calloc of macOS.
#if !BUILDFLAG(IS_APPLE) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !BUILDFLAG(IS_APPLE) || PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
const size_t alloc_size = num_items * size;
@ -46,11 +46,11 @@ bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
return true;
}
#endif // !BUILDFLAG(IS_APPLE) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // !BUILDFLAG(IS_APPLE) || PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
namespace internal {
bool ReleaseAddressSpaceReservation() {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
return partition_alloc::ReleaseReservation();
#else
return false;

@ -6,7 +6,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif
@ -23,7 +23,7 @@ void EnableTerminationOnHeapCorruption() {
}
bool UncheckedMalloc(size_t size, void** result) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
*result = allocator_shim::UncheckedAlloc(size);
#else
*result = malloc(size);
@ -32,7 +32,7 @@ bool UncheckedMalloc(size_t size, void** result) {
}
void UncheckedFree(void* ptr) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::UncheckedFree(ptr);
#else
free(ptr);

@ -18,7 +18,7 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#include "partition_alloc/shim/allocator_shim.h"
#if !BUILDFLAG(USE_ALLOCATOR_SHIM) && \
#if !PA_BUILDFLAG(USE_ALLOCATOR_SHIM) && \
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && defined(LIBC_GLIBC)
extern "C" {
void* __libc_malloc(size_t);
@ -48,7 +48,7 @@ void EnableTerminationOnOutOfMemory() {
// If we're using glibc's allocator, the above functions will override
// malloc and friends and make them die on out of memory.
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::SetCallNewHandlerOnMallocFailure(true);
#endif
}
@ -114,7 +114,7 @@ bool AdjustOOMScore(ProcessId process, int score) {
}
bool UncheckedMalloc(size_t size, void** result) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
*result = allocator_shim::UncheckedAlloc(size);
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
*result = malloc(size);
@ -125,7 +125,7 @@ bool UncheckedMalloc(size_t size, void** result) {
}
void UncheckedFree(void* ptr) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::UncheckedFree(ptr);
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
free(ptr);

@ -27,7 +27,7 @@ void EnableTerminationOnHeapCorruption() {
}
bool UncheckedMalloc(size_t size, void** result) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Unchecked allocations can happen before the default malloc() zone is
// registered. In this case, going straight to the shim may explode, since the
// memory will come from a zone which is unknown to the dispatching code in
@ -59,28 +59,28 @@ bool UncheckedMalloc(size_t size, void** result) {
// replaced with PartitionAlloc, so the allocator shim functions work best.
*result = allocator_shim::UncheckedAlloc(size);
return *result != nullptr;
#elif BUILDFLAG(USE_ALLOCATOR_SHIM)
#elif PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
return allocator_shim::UncheckedMallocMac(size, result);
#else // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// !BUILDFLAG(USE_ALLOCATOR_SHIM)
#else // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// !PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
*result = malloc(size);
return *result != nullptr;
#endif // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// !BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// !PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
// The standard version is defined in memory.cc in case of
// USE_PARTITION_ALLOC_AS_MALLOC.
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
bool UncheckedCalloc(size_t num_items, size_t size, void** result) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
return allocator_shim::UncheckedCallocMac(num_items, size, result);
#else
*result = calloc(num_items, size);
return *result != nullptr;
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
#endif // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
void EnableTerminationOnOutOfMemory() {
// Step 1: Enable OOM killer on C++ failures.
@ -88,23 +88,23 @@ void EnableTerminationOnOutOfMemory() {
// Step 2: Enable OOM killer on C-malloc failures for the default zone (if we
// have a shim).
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::SetCallNewHandlerOnMallocFailure(true);
// Step 3: Enable OOM killer on all other malloc zones (or just "all" without
// "other" if shim is disabled).
allocator_shim::InterceptAllocationsMac();
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
void UncheckedFree(void* ptr) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Important: might be different from free(), because in some cases, free()
// does not necessarily know about allocator_shim::* functions.
allocator_shim::UncheckedFree(ptr);
#else // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#else // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
free(ptr);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
} // namespace base

@ -78,7 +78,7 @@ static void callFree(void *ptr) {
}
TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::InitializeAllocatorShim();
#endif
// Assert that freeing an unallocated pointer will crash the process.
@ -97,14 +97,14 @@ TEST(ProcessMemoryTest, MacTerminateOnHeapCorruption) {
ADD_FAILURE() << "This test is not supported in this build configuration.";
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::UninterceptMallocZonesForTesting();
#endif
}
#endif // BUILDFLAG(IS_MAC)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
TEST(MemoryTest, AllocatorShimWorking) {
#if BUILDFLAG(IS_MAC)
allocator_shim::InitializeAllocatorShim();
@ -116,11 +116,11 @@ TEST(MemoryTest, AllocatorShimWorking) {
allocator_shim::UninterceptMallocZonesForTesting();
#endif
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// OpenBSD does not support these tests. Don't test these on ASan/TSan/MSan
// configurations: only test the real allocator.
#if !BUILDFLAG(IS_OPENBSD) && BUILDFLAG(USE_ALLOCATOR_SHIM) && \
#if !BUILDFLAG(IS_OPENBSD) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM) && \
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
namespace {
@ -161,7 +161,7 @@ class OutOfMemoryTest : public testing::Test {
class OutOfMemoryDeathTest : public OutOfMemoryTest {
public:
void SetUpInDeathAssert() {
#if BUILDFLAG(IS_MAC) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_MAC) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::InitializeAllocatorShim();
#endif
@ -495,7 +495,7 @@ TEST_F(OutOfMemoryDeathTest, CFAllocatorMalloc) {
});
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// PartitionAlloc-Everywhere does not intercept other malloc zones than the
// default (the top) malloc zone. Plus,
// CFAllocatorAllocate(kCFAllocatorSystemDefault, size, 0) does not call the
@ -515,7 +515,7 @@ TEST_F(OutOfMemoryDeathTest, MAYBE_CFAllocatorSystemDefault) {
});
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// PartitionAlloc-Everywhere does not intercept other malloc zones than the
// default (the top) malloc zone. Plus,
// CFAllocatorAllocate(kCFAllocatorMallocZone, size, 0) does not call the
@ -712,10 +712,10 @@ TEST_F(OutOfMemoryHandledTest, UncheckedCalloc) {
}
#endif // BUILDFLAG(IS_ANDROID)
#endif // !BUILDFLAG(IS_OPENBSD) && BUILDFLAG(USE_ALLOCATOR_SHIM) &&
#endif // !BUILDFLAG(IS_OPENBSD) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM) &&
// !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
#if BUILDFLAG(IS_MAC) && BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if BUILDFLAG(IS_MAC) && PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Not a proper test because it needs to be in a static initializer, see the
// comment in UncheckedMalloc() in memory_mac.mm.
@ -735,4 +735,4 @@ size_t need_a_static_initializer = []() {
return actual_size;
}();
#endif // BUILDFLAG(IS_MAC) && BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // BUILDFLAG(IS_MAC) && PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)

@ -6,9 +6,9 @@
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "partition_alloc/shim/allocator_shim.h"
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include <windows.h> // Must be in front of other Windows header files.
@ -44,23 +44,23 @@ void EnableTerminationOnOutOfMemory() {
}
bool UncheckedMalloc(size_t size, void** result) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
*result = allocator_shim::UncheckedAlloc(size);
#else
// malloc_unchecked is required to implement UncheckedMalloc properly.
// It's provided by allocator_shim_win.cc but since that's not always present,
// In the case, use regular malloc instead.
*result = malloc(size);
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
return *result != NULL;
}
void UncheckedFree(void* ptr) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::UncheckedFree(ptr);
#else
free(ptr);
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
} // namespace base

@ -66,7 +66,7 @@ void OverflowTestsSoftExpectTrue(bool overflow_detected) {
#if BUILDFLAG(IS_APPLE) || defined(ADDRESS_SANITIZER) || \
defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \
BUILDFLAG(IS_HWASAN) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
BUILDFLAG(IS_HWASAN) || PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#define MAYBE_NewOverflow DISABLED_NewOverflow
#else
#define MAYBE_NewOverflow NewOverflow

@ -36,7 +36,7 @@
#include "base/apple/scoped_nsautorelease_pool.h"
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
#include "partition_alloc/thread_cache.h"
#endif
@ -66,7 +66,7 @@ void WorkerThread::Delegate::WaitForWork() {
// that point, and go to sleep for the remaining of the time. This ensures
// that we do no work for short sleeps, and that threads do not get awaken
// many times.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
const TimeDelta sleep_duration_before_purge =
GetSleepDurationBeforePurge(base::TimeTicks::Now());
@ -88,7 +88,7 @@ void WorkerThread::Delegate::WaitForWork() {
}
#else
TimedWait(sleep_duration_before_worker_reclaim);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED)
}
@ -97,7 +97,7 @@ bool WorkerThread::Delegate::IsDelayFirstWorkerSleepEnabled() {
return state;
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
TimeDelta WorkerThread::Delegate::GetSleepDurationBeforePurge(TimeTicks now) {
base::TimeDelta sleep_duration_before_purge = kPurgeThreadCacheIdleDelay;
@ -136,7 +136,7 @@ TimeDelta WorkerThread::Delegate::GetSleepDurationBeforePurge(TimeTicks now) {
return snapped_purge_time - now;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED)
WorkerThread::WorkerThread(ThreadType thread_type_hint,

@ -113,7 +113,7 @@ class BASE_EXPORT WorkerThread : public RefCountedThreadSafe<WorkerThread>,
// mechanism. Returns |true| if signaled, and |false| if the call timed out.
virtual bool TimedWait(TimeDelta timeout) = 0;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
// Returns the desired sleep time before the worker has to wake up to purge
// the cache thread or reclaim itself.
@ -126,7 +126,7 @@ class BASE_EXPORT WorkerThread : public RefCountedThreadSafe<WorkerThread>,
// Simulated time at which the worker first attempts to go to sleep.
TimeTicks first_sleep_time_for_testing_;
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED)
};

@ -15,7 +15,7 @@
#include "base/apple/scoped_nsautorelease_pool.h"
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
#include "partition_alloc/thread_cache.h"
#endif

@ -43,11 +43,11 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
#include "partition_alloc/extended_api.h"
#include "partition_alloc/thread_cache.h"
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED)
using testing::_;
@ -993,7 +993,7 @@ TYPED_TEST(ThreadPoolWorkerTest, WorkerThreadObserver) {
Mock::VerifyAndClear(observer);
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED)
namespace {
NOINLINE void FreeForTest(void* data) {
@ -1149,7 +1149,7 @@ TYPED_TEST(ThreadPoolWorkerTest, PurgeOnUninteruptedSleep) {
delegate->wakeup_done_.Wait();
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED)
} // namespace internal

@ -27,11 +27,11 @@ DanglingPtrInstrumentation::Create() {
// because this does provide an alternative "implementation", by incrementing
// the two counters.
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
return base::unexpected(
"DanglingPtrInstrumentation requires the binary flag "
"'use_partition_alloc_as_malloc' to be on.");
#elif !BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#elif !PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
return base::unexpected(
"DanglingPtrInstrumentation requires the binary flag "
"'enable_dangling_raw_ptr_checks' to be on.");

@ -97,9 +97,9 @@
#include "base/debug/handle_hooks_win.h"
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "base/allocator/partition_alloc_support.h"
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#if GTEST_HAS_DEATH_TEST
#include "base/gtest_prod_util.h"
@ -202,7 +202,7 @@ class FeatureListScopedToEachTest : public testing::EmptyTestEventListener {
// TODO(crbug.com/40255771): Enable PartitionAlloc in unittests with
// ASAN.
#if BUILDFLAG(USE_PARTITION_ALLOC) && !defined(ADDRESS_SANITIZER)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC) && !defined(ADDRESS_SANITIZER)
allocator::PartitionAllocSupport::Get()->ReconfigureAfterFeatureListInit(
"",
/*configure_dangling_pointer_detector=*/true);
@ -567,7 +567,7 @@ void TestSuite::Initialize() {
// Android too. Same for ASAN.
// TODO(crbug.com/40255771): Enable PartitionAlloc in unittests with
// ASAN.
#if BUILDFLAG(USE_PARTITION_ALLOC) && !defined(ADDRESS_SANITIZER)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC) && !defined(ADDRESS_SANITIZER)
allocator::PartitionAllocSupport::Get()->ReconfigureForTests();
#endif // BUILDFLAG(IS_WIN)

@ -45,7 +45,7 @@
#include <sys/resource.h>
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/stack/stack.h"
#endif
@ -77,7 +77,7 @@ void* ThreadFunc(void* params) {
if (!thread_params->joinable)
base::DisallowSingleton();
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::StackTopRegistry::Get().NotifyThreadCreated();
#endif
@ -104,7 +104,7 @@ void* ThreadFunc(void* params) {
PlatformThread::CurrentHandle().platform_handle(),
PlatformThread::CurrentId());
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::StackTopRegistry::Get().NotifyThreadDestroyed();
#endif

@ -31,7 +31,7 @@
#include "build/build_config.h"
#include "partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/stack/stack.h"
#endif
@ -122,7 +122,7 @@ DWORD __stdcall ThreadFunc(void* params) {
FALSE,
DUPLICATE_SAME_ACCESS);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::StackTopRegistry::Get().NotifyThreadCreated();
#endif
@ -142,7 +142,7 @@ DWORD __stdcall ThreadFunc(void* params) {
PlatformThread::CurrentId());
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partition_alloc::internal::StackTopRegistry::Get().NotifyThreadDestroyed();
#endif

@ -49,7 +49,7 @@ class TRIVIAL_ABI SetOnDestroy {
}
private:
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_INSTANCE_TRACER)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_INSTANCE_TRACER)
// In instance tracer mode, raw_ptr is larger than a void*, but values stored
// inline in a SequenceLocalStorageMap must be at most sizeof(void*).
RAW_PTR_EXCLUSION bool* was_destroyed_ptr_;

@ -37,59 +37,60 @@ class AddressSpaceStatsDumperImpl final
address_space_stats->regular_pool_stats.usage * kSuperPageSize);
// BRP pool usage is applicable with the appropriate buildflag.
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
dump->AddScalar("brp_pool_usage", MemoryAllocatorDump::kUnitsBytes,
address_space_stats->brp_pool_stats.usage * kSuperPageSize);
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
// The configurable pool is only available on 64-bit platforms.
#if BUILDFLAG(HAS_64_BIT_POINTERS)
#if PA_BUILDFLAG(HAS_64_BIT_POINTERS)
dump->AddScalar(
"configurable_pool_usage", MemoryAllocatorDump::kUnitsBytes,
address_space_stats->configurable_pool_stats.usage * kSuperPageSize);
#endif // BUILDFLAG(HAS_64_BIT_POINTERS)
#endif // PA_BUILDFLAG(HAS_64_BIT_POINTERS)
// Thread isolated pool usage is applicable with the appropriate buildflag.
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
dump->AddScalar(
"thread_isolated_pool_usage", MemoryAllocatorDump::kUnitsBytes,
address_space_stats->thread_isolated_pool_stats.usage * kSuperPageSize);
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
// Additionally, largest possible reservation is also available on
// 64-bit platforms.
#if BUILDFLAG(HAS_64_BIT_POINTERS)
#if PA_BUILDFLAG(HAS_64_BIT_POINTERS)
dump->AddScalar(
"regular_pool_largest_reservation", MemoryAllocatorDump::kUnitsBytes,
address_space_stats->regular_pool_stats.largest_available_reservation *
kSuperPageSize);
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
dump->AddScalar(
"brp_pool_largest_reservation", MemoryAllocatorDump::kUnitsBytes,
address_space_stats->brp_pool_stats.largest_available_reservation *
kSuperPageSize);
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
dump->AddScalar("configurable_pool_largest_reservation",
MemoryAllocatorDump::kUnitsBytes,
address_space_stats->configurable_pool_stats
.largest_available_reservation *
kSuperPageSize);
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
dump->AddScalar("thread_isolated_pool_largest_reservation",
MemoryAllocatorDump::kUnitsBytes,
address_space_stats->thread_isolated_pool_stats
.largest_available_reservation *
kSuperPageSize);
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // BUILDFLAG(HAS_64_BIT_POINTERS)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(HAS_64_BIT_POINTERS)
#if !BUILDFLAG(HAS_64_BIT_POINTERS) && BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if !PA_BUILDFLAG(HAS_64_BIT_POINTERS) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
dump->AddScalar("blocklist_size", MemoryAllocatorDump::kUnitsObjects,
address_space_stats->blocklist_size);
dump->AddScalar("blocklist_hit_count", MemoryAllocatorDump::kUnitsObjects,
address_space_stats->blocklist_hit_count);
#endif // !BUILDFLAG(HAS_64_BIT_POINTERS) &&
// BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // !PA_BUILDFLAG(HAS_64_BIT_POINTERS) &&
// PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
return;
}

@ -40,7 +40,7 @@
#include <features.h>
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
#endif
@ -114,7 +114,7 @@ void ReportWinHeapStats(MemoryDumpLevelOfDetail level_of_detail,
}
#endif // BUILDFLAG(IS_WIN)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
void ReportPartitionAllocStats(ProcessMemoryDump* pmd,
MemoryDumpLevelOfDetail level_of_detail,
size_t* total_virtual_size,
@ -151,16 +151,16 @@ void ReportPartitionAllocStats(ProcessMemoryDump* pmd,
*allocated_objects_size += partition_stats_dumper.total_active_bytes();
*allocated_objects_count += partition_stats_dumper.total_active_count();
*syscall_count += partition_stats_dumper.syscall_count();
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
*cumulative_brp_quarantined_size +=
partition_stats_dumper.cumulative_brp_quarantined_bytes();
*cumulative_brp_quarantined_count +=
partition_stats_dumper.cumulative_brp_quarantined_count();
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_APPLE)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_APPLE)
void ReportAppleAllocStats(size_t* total_virtual_size,
size_t* resident_size,
size_t* allocated_objects_size) {
@ -184,8 +184,8 @@ void ReportAppleAllocStats(size_t* total_virtual_size,
}
#endif
#if (BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_ANDROID)) || \
(!BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && !BUILDFLAG(IS_WIN) && \
#if (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(IS_ANDROID)) || \
(!PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && !BUILDFLAG(IS_WIN) && \
!BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_FUCHSIA))
void ReportMallinfoStats(ProcessMemoryDump* pmd,
size_t* total_virtual_size,
@ -222,7 +222,7 @@ void ReportMallinfoStats(ProcessMemoryDump* pmd,
}
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
void ReportPartitionAllocThreadCacheStats(
ProcessMemoryDump* pmd,
MemoryAllocatorDump* dump,
@ -303,7 +303,7 @@ void ReportPartitionAllocLightweightQuarantineStats(
dump->AddScalar("quarantine_miss_count", MemoryAllocatorDump::kUnitsObjects,
stats.quarantine_miss_count);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
} // namespace
@ -316,7 +316,7 @@ MallocDumpProvider* MallocDumpProvider::GetInstance() {
LeakySingletonTraits<MallocDumpProvider>>::get();
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// static
MallocDumpProvider::ExtremeLUDGetStatsCallback
MallocDumpProvider::extreme_lud_get_stats_callback_ = nullptr;
@ -328,7 +328,7 @@ void MallocDumpProvider::SetExtremeLUDGetStatsCallback(
DCHECK(!extreme_lud_get_stats_callback_);
extreme_lud_get_stats_callback_ = callback;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
MallocDumpProvider::MallocDumpProvider() = default;
MallocDumpProvider::~MallocDumpProvider() = default;
@ -351,12 +351,12 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
uint64_t syscall_count = 0;
size_t cumulative_brp_quarantined_size = 0;
size_t cumulative_brp_quarantined_count = 0;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
uint64_t pa_only_resident_size;
uint64_t pa_only_allocated_objects_size;
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
ReportPartitionAllocStats(
pmd, args.level_of_detail, &total_virtual_size, &resident_size,
&allocated_objects_size, &allocated_objects_count, &syscall_count,
@ -415,7 +415,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
//
// Still report waste, as on some platforms, PartitionAlloc doesn't capture
// all of malloc()'s memory footprint.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
int64_t pa_waste = static_cast<int64_t>(pa_only_resident_size -
pa_only_allocated_objects_size);
waste -= pa_waste;
@ -434,7 +434,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
base::trace_event::MemoryAllocatorDump* partitions_dump = nullptr;
base::trace_event::MemoryAllocatorDump* elud_dump = nullptr;
ExtremeLUDStats elud_stats;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
partitions_dump = pmd->CreateAllocatorDump("malloc/partitions");
pmd->AddOwnershipEdge(inner_dump->guid(), partitions_dump->guid());
@ -444,7 +444,7 @@ bool MallocDumpProvider::OnMemoryDump(const MemoryDumpArgs& args,
ReportPartitionAllocLightweightQuarantineStats(elud_dump,
elud_stats.lq_stats);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
ReportPerMinuteStats(syscall_count, cumulative_brp_quarantined_size,
cumulative_brp_quarantined_count, elud_stats, outer_dump,
@ -461,7 +461,7 @@ void MallocDumpProvider::ReportPerMinuteStats(
MemoryAllocatorDump* malloc_dump,
MemoryAllocatorDump* partition_alloc_dump,
MemoryAllocatorDump* elud_dump) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
uint64_t new_syscalls = syscall_count - last_syscall_count_;
size_t new_brp_quarantined_bytes =
cumulative_brp_quarantined_bytes - last_cumulative_brp_quarantined_bytes_;
@ -536,10 +536,10 @@ void MallocDumpProvider::ReportPerMinuteStats(
last_syscall_count_ = syscall_count;
last_cumulative_brp_quarantined_bytes_ = cumulative_brp_quarantined_bytes;
last_cumulative_brp_quarantined_count_ = cumulative_brp_quarantined_count;
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
std::string GetPartitionDumpName(const char* root_name,
const char* partition_name) {
return base::StringPrintf("%s/%s/%s", root_name,
@ -563,12 +563,12 @@ void MemoryDumpPartitionStatsDumper::PartitionDumpTotals(
total_active_bytes_ += memory_stats->total_active_bytes;
total_active_count_ += memory_stats->total_active_count;
syscall_count_ += memory_stats->syscall_count;
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
cumulative_brp_quarantined_bytes_ +=
memory_stats->cumulative_brp_quarantined_bytes;
cumulative_brp_quarantined_count_ +=
memory_stats->cumulative_brp_quarantined_count;
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
std::string dump_name = GetPartitionDumpName(root_name_, partition_name);
MemoryAllocatorDump* allocator_dump =
@ -608,13 +608,13 @@ void MemoryDumpPartitionStatsDumper::PartitionDumpTotals(
allocator_dump->AddScalar("discardable_size",
MemoryAllocatorDump::kUnitsBytes,
memory_stats->total_discardable_bytes);
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
allocator_dump->AddScalar("brp_quarantined_size",
MemoryAllocatorDump::kUnitsBytes,
memory_stats->total_brp_quarantined_bytes);
allocator_dump->AddScalar("brp_quarantined_count", "count",
memory_stats->total_brp_quarantined_count);
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
allocator_dump->AddScalar("syscall_count", "count",
memory_stats->syscall_count);
allocator_dump->AddScalar("syscall_total_time_ms", "ms",
@ -694,7 +694,7 @@ void MemoryDumpPartitionStatsDumper::PartitionsDumpBucketStats(
MemoryAllocatorDump::kUnitsObjects,
memory_stats->num_decommitted_slot_spans);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
} // namespace trace_event
} // namespace base

@ -43,11 +43,11 @@ class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider {
partition_alloc::LightweightQuarantineStats lq_stats{0};
size_t capacity_in_bytes = 0;
};
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
using ExtremeLUDGetStatsCallback = ExtremeLUDStats (*)();
static void SetExtremeLUDGetStatsCallback(
ExtremeLUDGetStatsCallback callback);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
MallocDumpProvider(const MallocDumpProvider&) = delete;
MallocDumpProvider& operator=(const MallocDumpProvider&) = delete;
@ -74,7 +74,7 @@ class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider {
GUARDED_BY(emit_metrics_on_memory_dump_lock_) = true;
base::Lock emit_metrics_on_memory_dump_lock_;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// The injected stats-report function of the Extreme LUD. Non-null iff the
// Extreme LUD is enabled.
static ExtremeLUDGetStatsCallback extreme_lud_get_stats_callback_;
@ -91,7 +91,7 @@ class BASE_EXPORT MallocDumpProvider : public MemoryDumpProvider {
#endif
};
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
// This class is used to invert the dependency of PartitionAlloc on the
// PartitionAllocMemoryDumpProvider. This implements an interface that will
// be called with memory statistics for each bucket in the allocator.
@ -138,7 +138,7 @@ class BASE_EXPORT MemoryDumpPartitionStatsDumper final
bool detailed_;
};
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
} // namespace trace_event
} // namespace base

@ -49,7 +49,7 @@
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "base/trace_event/address_space_dump_provider.h"
#endif
@ -142,7 +142,7 @@ void MemoryDumpManager::Initialize(
RegisterDumpProvider(MallocDumpProvider::GetInstance(), "Malloc", nullptr);
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
RegisterDumpProvider(AddressSpaceDumpProvider::GetInstance(),
"PartitionAlloc.AddressSpace", nullptr);
#endif

@ -191,11 +191,11 @@ constexpr auto kAllocatorDumpNameAllowlist =
"leveldatabase/memenv_0x?",
"malloc",
"malloc/allocated_objects",
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
"malloc/extreme_lud",
#endif
"malloc/metadata_fragmentation_caches",
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
"malloc/partitions",
"malloc/partitions/allocator",
"malloc/partitions/allocator/scheduler_loop_quarantine",
@ -207,7 +207,7 @@ constexpr auto kAllocatorDumpNameAllowlist =
"malloc/partitions/nonquarantinable",
"malloc/sys_malloc",
"malloc/win_heap",
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
"media/webmediaplayer/audio/player_0x?",
"media/webmediaplayer/data_source/player_0x?",
"media/webmediaplayer/demuxer/player_0x?",
@ -241,7 +241,7 @@ constexpr auto kAllocatorDumpNameAllowlist =
"partition_alloc/partitions/array_buffer",
"partition_alloc/partitions/buffer",
"partition_alloc/partitions/fast_malloc",
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
"partition_alloc/partitions/fast_malloc/thread_cache",
"partition_alloc/partitions/fast_malloc/thread_cache/main_thread",
#endif

@ -295,7 +295,7 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
{"malloc/partitions/allocator", "Malloc.Allocator.ObjectCount",
MetricSize::kTiny, MemoryAllocatorDump::kNameObjectCount,
EmitTo::kSizeInUmaOnly, nullptr},
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
{"malloc/partitions/allocator", "Malloc.BRPQuarantined", MetricSize::kSmall,
"brp_quarantined_size", EmitTo::kSizeInUmaOnly, nullptr},
{"malloc/partitions/allocator", "Malloc.BRPQuarantinedCount",
@ -325,14 +325,14 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
{"partition_alloc/partitions/array_buffer",
"PartitionAlloc.BRPQuarantinedCount.ArrayBuffer", MetricSize::kTiny,
"brp_quarantined_count", EmitTo::kSizeInUmaOnly, nullptr},
#endif // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#endif // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
{"malloc/partitions", "Malloc.BRPQuarantinedBytesPerMinute",
MetricSize::kSmall, "brp_quarantined_bytes_per_minute",
EmitTo::kSizeInUmaOnly, nullptr},
{"malloc/partitions", "Malloc.BRPQuarantinedCountPerMinute",
MetricSize::kTiny, "brp_quarantined_count_per_minute",
EmitTo::kSizeInUmaOnly, nullptr},
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
{"malloc/partitions/allocator/scheduler_loop_quarantine",
"Malloc.SchedulerLoopQuarantine.Count", MetricSize::kTiny, "count",
EmitTo::kSizeInUmaOnly, nullptr},
@ -362,7 +362,7 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
MetricSize::kPercentage, "fragmentation", EmitTo::kSizeInUmaOnly, nullptr},
{"malloc", "Malloc.SyscallsPerMinute", MetricSize::kTiny,
"syscalls_per_minute", EmitTo::kSizeInUmaOnly, nullptr},
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
{"mojo", "NumberOfMojoHandles", MetricSize::kSmall,
MemoryAllocatorDump::kNameObjectCount, EmitTo::kCountsInUkmOnly,
&Memory_Experimental::SetNumberOfMojoHandles},
@ -448,7 +448,7 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
{"partition_alloc/partitions/fast_malloc",
"PartitionAlloc.Wasted.FastMalloc", MetricSize::kLarge, "wasted",
EmitTo::kSizeInUmaOnly, nullptr},
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
{"partition_alloc/partitions/fast_malloc/thread_cache",
"PartitionAlloc.Partitions.FastMalloc.ThreadCache", MetricSize::kSmall,
kSize, EmitTo::kSizeInUmaOnly, nullptr},
@ -637,7 +637,7 @@ const Metric kAllocatorDumpNamesForMetrics[] = {
#endif
};
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Metrics specific to PartitionAlloc's address space stats (cf.
// kAllocatorDumpNamesForMetrics above). All of these metrics come in
// three variants: bare, after 1 hour, and after 24 hours. These metrics
@ -698,7 +698,7 @@ const Metric kPartitionAllocAddressSpaceMetrics[] = {
.metric = "thread_isolated_pool_usage",
},
};
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// Record a memory size in megabytes, over a potential interval up to 32 GB.
#define UMA_HISTOGRAM_LARGE_MEMORY_MB(name, sample) \
@ -806,9 +806,9 @@ void EmitPartitionAllocWastedStat(const GlobalMemoryDump::ProcessDump& pmd,
void EmitMallocStats(const GlobalMemoryDump::ProcessDump& pmd,
HistogramProcessType process_type,
const std::optional<base::TimeDelta>& uptime) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
const char* const kMallocDumpName = "malloc/partitions/allocator";
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
static constexpr int kRecordHours[] = {1, 24};
// First element of the pair is the name as found in memory dumps, second
@ -823,14 +823,14 @@ void EmitMallocStats(const GlobalMemoryDump::ProcessDump& pmd,
if (uptime <= base::Hours(hours))
continue;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
EmitPartitionAllocFragmentationStat(
pmd, process_type, kMallocDumpName,
base::StringPrintf("Malloc.Fragmentation.After%dH", hours).c_str());
EmitPartitionAllocWastedStat(
pmd, process_type, kMallocDumpName,
base::StringPrintf("Malloc.Wasted.After%dH", hours).c_str());
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
for (const auto& partition_name : kPartitionNames) {
const auto* dump_name = partition_name.first;
@ -849,7 +849,7 @@ void EmitMallocStats(const GlobalMemoryDump::ProcessDump& pmd,
}
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
void EmitPartitionAllocAddressSpaceStatVariants(
const Metric& metric,
const uint64_t metric_value,
@ -894,7 +894,7 @@ void EmitPartitionAllocAddressSpaceStats(
process_type, uptime);
}
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
void EmitProcessUmaAndUkm(const GlobalMemoryDump::ProcessDump& pmd,
HistogramProcessType process_type,
@ -964,9 +964,9 @@ void EmitProcessUmaAndUkm(const GlobalMemoryDump::ProcessDump& pmd,
if (record_uma) {
EmitMallocStats(pmd, process_type, uptime);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
EmitPartitionAllocAddressSpaceStats(pmd, process_type, uptime);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
}
@ -1177,9 +1177,9 @@ void ProcessMemoryMetricsEmitter::FetchAndEmitProcessMemoryMetrics() {
std::vector<std::string> mad_list;
for (const auto& metric : kAllocatorDumpNamesForMetrics)
mad_list.push_back(metric.dump_name);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
mad_list.push_back("partition_alloc/address_space");
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if (pid_scope_ != base::kNullProcessId) {
instrumentation->RequestGlobalDumpForPid(pid_scope_, mad_list,
std::move(callback));

@ -190,7 +190,7 @@ void CheckExperimentalMemoryMetricsForProcessType(
histogram_tester, count, ValueRestriction::NONE,
number_of_processes);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// It's a small metric, so should not be strictly zero in theory, but could be
// if purge comes at the wrong time, or the thread cache is not available on
// this platform.
@ -218,7 +218,7 @@ void CheckExperimentalMemoryMetricsForProcessType(
"2.Tiny.Malloc.SyscallsPerMinute",
histogram_tester, count, ValueRestriction::ABOVE_ZERO,
number_of_processes);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
void CheckExperimentalMemoryMetrics(

@ -19,7 +19,7 @@
#endif
// Some builds don't support memlog in which case the tests won't function.
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
namespace heap_profiling {
@ -105,4 +105,4 @@ INSTANTIATE_TEST_SUITE_P(Memlog,
} // namespace heap_profiling
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)

@ -56,7 +56,7 @@ namespace {
// Returns the string to display at the top of the page for help.
std::string GetMessageString() {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
Mode mode = Mode::kNone;
if (heap_profiling::Supervisor::GetInstance()->HasStarted()) {
mode = heap_profiling::Supervisor::GetInstance()->GetMode();

@ -15,7 +15,7 @@
#include "base/allocator/allocator_interception_mac.h"
#endif
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// Test that the allocator shim is in-place so that base::UncheckedMalloc works.
TEST(OutOfMemoryHandledTest, UncheckedMalloc) {
// Enable termination on OOM - just as setup.exe does at early initialization
@ -42,4 +42,4 @@ TEST(OutOfMemoryHandledTest, UncheckedMalloc) {
base::allocator::UninterceptMallocZonesForTesting();
#endif
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)

@ -414,7 +414,8 @@ std::ostream& operator<<(std::ostream& out, const UserspaceSwapConfig& c) {
// KernelSupportsUserspaceSwap will test for all features necessary to enable
// userspace swap.
COMPONENT_EXPORT(USERSPACE_SWAP) bool KernelSupportsUserspaceSwap() {
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || !BUILDFLAG(HAS_64_BIT_POINTERS)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
!PA_BUILDFLAG(HAS_64_BIT_POINTERS)
// We currently only support 64bit PartitionAlloc.
return false;
#else
@ -446,8 +447,8 @@ COMPONENT_EXPORT(USERSPACE_SWAP) bool KernelSupportsUserspaceSwap() {
}();
return userfault_fd_supported && mremap_dontunmap_supported;
#endif // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) ||
// !BUILDFLAG(HAS_64_BIT_POINTERS)
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) ||
// !PA_BUILDFLAG(HAS_64_BIT_POINTERS)
}
RendererSwapData::RendererSwapData() = default;
@ -485,7 +486,8 @@ bool GetPartitionAllocSuperPagesInUse(
int32_t max_superpages,
std::vector<::userspace_swap::mojom::MemoryRegionPtr>& regions) {
regions.clear();
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || !BUILDFLAG(HAS_64_BIT_POINTERS)
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
!PA_BUILDFLAG(HAS_64_BIT_POINTERS)
return false;
#else
@ -534,8 +536,8 @@ bool GetPartitionAllocSuperPagesInUse(
}
return true;
#endif // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) ||
// !BUILDFLAG(HAS_64_BIT_POINTERS)
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) ||
// !PA_BUILDFLAG(HAS_64_BIT_POINTERS)
}
COMPONENT_EXPORT(USERSPACE_SWAP) uint64_t GetGlobalMemoryReclaimed() {

@ -15,7 +15,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "base/allocator/partition_allocator/src/partition_alloc/page_allocator.h"
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h"
#endif
@ -24,7 +24,8 @@ namespace ash {
namespace memory {
namespace userspace_swap {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(HAS_64_BIT_POINTERS)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(HAS_64_BIT_POINTERS)
// InRange matches if the range specified by [start,end] is in [address,
// address+length] of a region.
MATCHER_P2(InRange, start, end, "") {
@ -91,8 +92,8 @@ TEST(UserspaceSwap, LimitSuperpagesReturned) {
free(reinterpret_cast<void*>(mem_area[i]));
}
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// BUILDFLAG(HAS_64_BIT_POINTERS)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(HAS_64_BIT_POINTERS)
} // namespace userspace_swap
} // namespace memory

@ -710,12 +710,12 @@ bool PlatformCrashpadInitialization(
if (browser_process) {
HandlerStarter* starter = HandlerStarter::Get();
*database_path = starter->Initialize(dump_at_crash);
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
// Handler gets called in SignalHandler::HandleOrReraiseSignal() after
// reporting the crash.
crashpad::CrashpadClient::SetLastChanceExceptionHandler(
partition_alloc::PermissiveMte::HandleCrash);
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
return true;
}
@ -723,10 +723,10 @@ bool PlatformCrashpadInitialization(
bool result = handler->Initialize(dump_at_crash);
DCHECK(result);
#if BUILDFLAG(HAS_MEMORY_TAGGING)
#if PA_BUILDFLAG(HAS_MEMORY_TAGGING)
handler->SetLastChanceExceptionHandler(
partition_alloc::PermissiveMte::HandleCrash);
#endif // BUILDFLAG(HAS_MEMORY_TAGGING)
#endif // PA_BUILDFLAG(HAS_MEMORY_TAGGING)
*database_path = base::FilePath();
return true;

@ -79,8 +79,9 @@ TEST_F(BufferTest, TestInitWithAlloc) {
#if defined(ARCH_CPU_64_BITS) && \
(defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
defined(THREAD_SANITIZER) || BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_FUCHSIA))
defined(THREAD_SANITIZER) || \
PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || BUILDFLAG(IS_CHROMEOS) || \
BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_FUCHSIA))
// - ASAN and MSAN malloc by default triggers crash instead of returning null on
// failure.
// - PartitionAlloc malloc also crashes on allocation failure by design.

@ -240,10 +240,10 @@ void InstallExtremeLightweightDetectorHooks(
sampling_state.Init(init_options.sampling_frequency);
allocator_shim::InsertAllocatorDispatch(&allocator_dispatch);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
base::trace_event::MallocDumpProvider::SetExtremeLUDGetStatsCallback(
GetStats);
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
partition_alloc::internal::LightweightQuarantineBranch&

@ -4,7 +4,7 @@
#include "components/gwp_asan/client/extreme_lightweight_detector_malloc_shims.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
@ -84,4 +84,4 @@ TEST_F(ExtremeLightweightDetectorMallocShimsTest, Basic) {
} // namespace gwp_asan::internal
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)

@ -31,15 +31,15 @@
#include "components/gwp_asan/client/sampling_helpers.h"
#include "components/gwp_asan/common/crash_key_name.h"
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "components/gwp_asan/client/lightweight_detector/malloc_shims.h"
#include "components/gwp_asan/client/sampling_malloc_shims.h"
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "components/gwp_asan/client/lightweight_detector/partitionalloc_shims.h"
#include "components/gwp_asan/client/sampling_partitionalloc_shims.h"
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
namespace gwp_asan {
@ -107,7 +107,7 @@ constexpr int kDefaultProcessSamplingBoost2 = 10;
// The memory overhead of Lightweight UAF detector is:
// sizeof(LightweightSlotMetadata) * kDefaultMaxLightweightMetadata
constexpr int kDefaultMaxLightweightMetadata = 3000;
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
constexpr int kDefaultMaxTotalSize = 65536;
// A set of parameters temporarily used by the random sampling LUD experiment.
@ -119,7 +119,7 @@ constexpr int kDefaultEvictionTaskIntervalMs = 1000;
constexpr int kMaxMaxTotalSize = 2 * 1024 * 1024;
constexpr int kMaxEvictionChunkSize = 1024;
constexpr int kMaxEvictionTaskIntervalMs = 10000;
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // defined(ARCH_CPU_64_BITS)
BASE_FEATURE(kLightweightUafDetector,
@ -332,7 +332,7 @@ bool MaybeEnableLightweightDetectorInternal(bool boost_sampling,
}
switch (kLightweightUafDetectorModeParam.Get()) {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
case LightweightDetectorMode::kBrpQuarantine: {
if (!base::allocator::PartitionAllocSupport::GetBrpConfiguration(
process_type)
@ -348,9 +348,9 @@ bool MaybeEnableLightweightDetectorInternal(bool boost_sampling,
lud::InstallPartitionAllocHooks();
return true;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
case LightweightDetectorMode::kRandom: {
int max_allocations = GetFieldTrialParamByFeatureAsInt(
feature, "MaxAllocations", kDefaultMaxAllocations);
@ -427,7 +427,7 @@ bool MaybeEnableLightweightDetectorInternal(bool boost_sampling,
alloc_sampling_freq);
return true;
}
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
default: {
DLOG(ERROR) << "Unsupported Lightweight UAF Detector mode.";
@ -445,7 +445,7 @@ bool MaybeEnableLightweightDetectorInternal(bool boost_sampling,
} // namespace internal
void EnableForMalloc(bool boost_sampling, std::string_view process_type) {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
static bool init_once = [&]() -> bool {
auto settings = internal::GetAllocatorSettings(internal::kGwpAsanMalloc,
boost_sampling);
@ -465,12 +465,12 @@ void EnableForMalloc(bool boost_sampling, std::string_view process_type) {
#else
std::ignore = internal::kGwpAsanMalloc;
DLOG(WARNING) << "base::allocator shims are unavailable for GWP-ASan.";
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
}
void EnableForPartitionAlloc(bool boost_sampling,
std::string_view process_type) {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
static bool init_once = [&]() -> bool {
auto settings = internal::GetAllocatorSettings(
internal::kGwpAsanPartitionAlloc, boost_sampling);
@ -490,7 +490,7 @@ void EnableForPartitionAlloc(bool boost_sampling,
#else
std::ignore = internal::kGwpAsanPartitionAlloc;
DLOG(WARNING) << "PartitionAlloc hooks are unavailable for GWP-ASan.";
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
}
void MaybeEnableLightweightDetector(bool boost_sampling,
@ -502,7 +502,7 @@ void MaybeEnableLightweightDetector(bool boost_sampling,
void MaybeEnableExtremeLightweightDetector(bool boost_sampling,
const char* process_type) {
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if (!base::FeatureList::IsEnabled(internal::kExtremeLightweightUAFDetector)) {
return;
}
@ -529,7 +529,7 @@ void MaybeEnableExtremeLightweightDetector(bool boost_sampling,
.quarantine_capacity_in_bytes = quarantine_capacity_in_bytes});
return true;
}();
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
} // namespace gwp_asan

@ -18,9 +18,9 @@
// PartitionAlloc (and hence hooking) are disabled with sanitizers that replace
// allocation routines.
#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
#if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
PA_BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
// These tests install global PartitionAlloc hooks so they are not safe to run
// in multi-threaded contexts. Instead they're implemented as multi-process
@ -85,5 +85,5 @@ TEST_F(PartitionAllocShimsTest, Basic) {
} // namespace gwp_asan::internal::lud
#endif // !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) &&
// BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) &&
// BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)
// PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) &&
// PA_BUILDFLAG(USE_RAW_PTR_BACKUP_REF_IMPL)

@ -300,7 +300,7 @@ TEST_F(SamplingMallocShimsTest, AlignedRealloc) {
#endif // BUILDFLAG(IS_WIN)
// PartitionAlloc-Everywhere does not support batch_malloc / batch_free.
#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
BatchFree,
SamplingMallocShimsTest::multiprocessTestSetup) {
@ -328,7 +328,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP(
TEST_F(SamplingMallocShimsTest, BatchFree) {
runTest("BatchFree");
}
#endif // BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#endif // BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
} // namespace

@ -21,7 +21,7 @@
#endif
#endif
#if BUILDFLAG(IS_IOS) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_IOS) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.h"
#include "base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h"
#include "base/ios/ios_util.h"
@ -30,7 +30,7 @@
// HeapProfilerController's dependencies are not compiled on iOS unless
// AllocatorShim is enabled.
#if !BUILDFLAG(IS_IOS) || BUILDFLAG(USE_ALLOCATOR_SHIM)
#if !BUILDFLAG(IS_IOS) || PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#define HEAP_PROFILING_SUPPORTED 1
#else
#define HEAP_PROFILING_SUPPORTED 0
@ -60,7 +60,7 @@
namespace memory_system {
namespace {
#if BUILDFLAG(IS_IOS) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_IOS) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// Do not install allocator shim on iOS 13.4 due to high crash volume on this
// particular version of OS. TODO(crbug.com/40707342): Remove this workaround
// when/if the bug gets fixed.
@ -128,7 +128,7 @@ struct MemorySystem::Impl {
heap_profiler_controller_;
#endif
#if BUILDFLAG(IS_IOS) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_IOS) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
const bool should_install_allocator_shim_ = ShouldInstallAllocatorShim();
#endif
@ -151,7 +151,7 @@ struct MemorySystem::Impl {
};
MemorySystem::Impl::Impl() {
#if BUILDFLAG(IS_IOS) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_IOS) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (should_install_allocator_shim_) {
allocator_shim::InitializeAllocatorShim();
}
@ -209,7 +209,7 @@ void MemorySystem::Impl::Initialize(
}
bool MemorySystem::Impl::IsAllocatorShimInitialized() {
#if BUILDFLAG(IS_IOS) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_IOS) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (!should_install_allocator_shim_) {
return false;
}

@ -24,11 +24,11 @@
#include "components/services/heap_profiling/public/cpp/heap_profiling_trace_source.h"
#endif
#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.h"
#endif // BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
using base::allocator::dispatcher::AllocationSubsystem;
@ -42,8 +42,8 @@ void ProfilingClient::BindToInterface(
receivers_.Add(this, std::move(receiver));
}
#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
void ShimNewMallocZonesAndReschedule(base::Time end_time,
base::TimeDelta delay) {
allocator_shim::ShimNewMallocZones();
@ -58,8 +58,8 @@ void ShimNewMallocZonesAndReschedule(base::Time end_time,
base::BindOnce(&ShimNewMallocZonesAndReschedule, end_time, next_delay),
delay);
}
#endif // BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// BULDFLAG(USE_ALLOCATOR_SHIM)
#endif // BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// && BULDFLAG(USE_ALLOCATOR_SHIM)
void ProfilingClient::StartProfiling(mojom::ProfilingParamsPtr params,
StartProfilingCallback callback) {
@ -67,8 +67,8 @@ void ProfilingClient::StartProfiling(mojom::ProfilingParamsPtr params,
return;
started_profiling_ = true;
#if BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// On macOS, this call is necessary to shim malloc zones that were created
// after startup. This cannot be done during shim initialization because the
// task scheduler has not yet been initialized.
@ -78,8 +78,8 @@ void ProfilingClient::StartProfiling(mojom::ProfilingParamsPtr params,
base::Time end_time = base::Time::Now() + base::Minutes(1);
base::TimeDelta initial_delay = base::Seconds(1);
ShimNewMallocZonesAndReschedule(end_time, initial_delay);
#endif // BUILDFLAG(IS_APPLE) && !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // BUILDFLAG(IS_APPLE) && !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
// && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
StartProfilingInternal(std::move(params), std::move(callback));

@ -16,7 +16,7 @@ namespace heap_profiling {
Mode GetModeForStartup() {
const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
if (cmdline->HasSwitch("enable-heap-profiling")) {
LOG(ERROR) << "--enable-heap-profiling is no longer supported. Use "
"--memlog instead. See documentation at "

@ -12,7 +12,7 @@
namespace heap_profiling {
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
TEST(HeapProfilingSwitches, GetModeForStartup_Default) {
EXPECT_EQ(Mode::kNone, GetModeForStartup());

@ -73,7 +73,7 @@
#endif
#if BUILDFLAG(IS_APPLE)
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#include "base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h"
#endif
#endif // BUILDFLAG(IS_MAC)
@ -201,7 +201,7 @@ RunContentProcess(ContentMainParams params,
content_main_runner->ReInitializeParams(std::move(params));
} else {
is_initialized = true;
#if BUILDFLAG(IS_APPLE) && BUILDFLAG(USE_ALLOCATOR_SHIM)
#if BUILDFLAG(IS_APPLE) && PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
allocator_shim::InitializeAllocatorShim();
#endif
base::EnableTerminationOnOutOfMemory();

@ -1006,13 +1006,13 @@ int ContentMainRunnerImpl::Initialize(ContentMainParams params) {
delegate_->PreSandboxStartup();
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
// instantiate the ThreadIsolatedAllocator before we spawn threads
if (process_type == switches::kRendererProcess ||
process_type == switches::kZygoteProcess) {
gin::GetThreadIsolationData().InitializeBeforeThreadCreation();
}
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if BUILDFLAG(IS_WIN)
if (!sandbox::policy::Sandbox::Initialize(

@ -230,7 +230,7 @@
#include "ui/wm/core/window_util.h"
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
#include "base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan.h"
#include "content/browser/starscan_load_observer.h"
#endif
@ -1210,13 +1210,14 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context)
SharedStorageBudgetCharger::CreateForWebContents(this);
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
// TODO(crbug.com/40190798): Remove or move to another place after finishing
// the PCScan experiment.
if (partition_alloc::internal::PCScan::IsInitialized()) {
star_scan_load_observer_ = std::make_unique<StarScanLoadObserver>(this);
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(USE_STARSCAN)
}
WebContentsImpl::~WebContentsImpl() {

@ -93,7 +93,7 @@
#include "content/public/browser/android/child_process_importance.h"
#endif
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
#include "content/browser/starscan_load_observer.h"
#endif
@ -2445,7 +2445,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
// color or if the page does not set a background color.
std::optional<SkColor> page_base_background_color_;
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
// TODO(crbug.com/40190798): Remove/reevaluate after the PCScan experiment is
// finished.
std::unique_ptr<StarScanLoadObserver> star_scan_load_observer_;

@ -118,7 +118,7 @@
#include "ui/display/screen.h"
#include "url/gurl.h"
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
#include "base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan.h"
#endif
@ -6158,7 +6158,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsFencedFrameBrowserTest,
}
}
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_BUILDFLAG(USE_STARSCAN)
namespace {
@ -6411,6 +6411,7 @@ IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest,
}
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(USE_STARSCAN)
} // namespace content

@ -26,13 +26,13 @@ class GIN_EXPORT V8Platform : public v8::Platform {
// v8::Platform implementation.
// Some configurations do not use page_allocator.
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
// GetPageAllocator returns gin::PageAllocator instead of v8::PageAllocator,
// so we can be sure that the allocator used employs security features such as
// enabling Arm's Branch Target Instructions for executable pages. This is
// verified in the tests for gin::PageAllocator.
PageAllocator* GetPageAllocator() override;
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
ThreadIsolatedAllocator* GetThreadIsolatedAllocator() override;
#endif
void OnCriticalMemoryPressure() override;

@ -4,7 +4,7 @@
#include "gin/thread_isolation.h"
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#include <sys/mman.h>
#include <sys/utsname.h>
@ -112,4 +112,4 @@ ThreadIsolationData& GetThreadIsolationData() {
} // namespace gin
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)

@ -7,7 +7,7 @@
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#include "base/allocator/partition_allocator/src/partition_alloc/thread_isolation/alignment.h"
#include "base/no_destructor.h"
@ -40,6 +40,6 @@ GIN_EXPORT ThreadIsolationData& GetThreadIsolationData();
} // namespace gin
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // GIN_THREAD_ISOLATION_H_

@ -119,12 +119,12 @@ base::LazyInstance<EnabledStateObserverImpl>::Leaky g_trace_state_dispatcher =
LAZY_INSTANCE_INITIALIZER;
#endif // !BUILDFLAG(USE_PERFETTO_CLIENT_LIBRARY)
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
base::LazyInstance<gin::PageAllocator>::Leaky g_page_allocator =
LAZY_INSTANCE_INITIALIZER;
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
base::TaskPriority ToBaseTaskPriority(v8::TaskPriority priority) {
switch (priority) {
@ -322,19 +322,19 @@ V8Platform::V8Platform() : tracing_controller_(new TracingControllerImpl) {}
V8Platform::~V8Platform() = default;
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
PageAllocator* V8Platform::GetPageAllocator() {
return g_page_allocator.Pointer();
}
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
ThreadIsolatedAllocator* V8Platform::GetThreadIsolatedAllocator() {
if (!GetThreadIsolationData().Initialized()) {
return nullptr;
}
return GetThreadIsolationData().allocator.get();
}
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
void V8Platform::OnCriticalMemoryPressure() {
// We only have a reservation on 32-bit Windows systems.
@ -353,7 +353,7 @@ v8::ZoneBackingAllocator* V8Platform::GetZoneBackingAllocator() {
} allocator;
return &allocator;
}
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
std::shared_ptr<v8::TaskRunner> V8Platform::GetForegroundTaskRunner(
v8::Isolate* isolate,

@ -10,7 +10,7 @@
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
#include "base/allocator/partition_allocator/src/partition_alloc/page_allocator.h"
#include "gin/gin_export.h"
@ -59,6 +59,6 @@ class GIN_EXPORT PageAllocator final : public v8::PageAllocator {
};
} // namespace gin
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#endif // GIN_V8_PLATFORM_PAGE_ALLOCATOR_H_

@ -6,7 +6,7 @@
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h"
#include "base/allocator/partition_allocator/src/partition_alloc/partition_root.h"
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#include <sys/mman.h>
#include <sys/syscall.h>
@ -14,10 +14,10 @@
#include "base/allocator/partition_allocator/src/partition_alloc/thread_isolation/pkey.h"
#include "gin/thread_isolation.h"
#if BUILDFLAG(ENABLE_PKEYS)
#else // BUILDFLAG(ENABLE_PKEYS)
#if PA_BUILDFLAG(ENABLE_PKEYS)
#else // PA_BUILDFLAG(ENABLE_PKEYS)
#error Not implemented for non-pkey thread isolation
#endif // BUILDFLAG(ENABLE_PKEYS)
#endif // PA_BUILDFLAG(ENABLE_PKEYS)
namespace gin {
@ -50,4 +50,4 @@ int ThreadIsolatedAllocator::Pkey() const {
} // namespace gin
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)

@ -7,11 +7,11 @@
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
#if BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#if !BUILDFLAG(ENABLE_PKEYS)
#if !PA_BUILDFLAG(ENABLE_PKEYS)
#error Not implemented for non-pkey thread isolation
#endif // BUILDFLAG(ENABLE_PKEYS)
#endif // PA_BUILDFLAG(ENABLE_PKEYS)
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc.h"
#include "gin/gin_export.h"
@ -42,6 +42,6 @@ class GIN_EXPORT ThreadIsolatedAllocator final
} // namespace gin
#endif // BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // PA_BUILDFLAG(ENABLE_THREAD_ISOLATION)
#endif // GIN_V8_PLATFORM_THREAD_ISOLATED_ALLOCATOR_H_

@ -100,10 +100,10 @@ int main(int argc, char* argv[]) {
// Register Chrome path providers.
RegisterPathProviders();
#if BUILDFLAG(USE_PARTITION_ALLOC) && !BUILDFLAG(USE_BLINK)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC) && !BUILDFLAG(USE_BLINK)
// ContentMainRunnerImpl::Initialize calls this when USE_BLINK is true.
base::allocator::PartitionAllocSupport::Get()->ReconfigureEarlyish("");
#endif // BUILDFLAG(USE_PARTITION_ALLOC) && !BUILDFLAG(USE_BLINK)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC) && !BUILDFLAG(USE_BLINK)
return RunUIApplicationMain(argc, argv);
}

@ -6,10 +6,10 @@
#include "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_buildflags.h"
__attribute__((constructor(0))) void InitializePartitionAlloc() {
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
// Perform malloc zone registration before loading any dependency as this
// needs to be called before any thread creation which happens during the
// initialisation of some of the runtime libraries.
partition_alloc::EarlyMallocZoneRegistration();
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
}

@ -160,7 +160,7 @@ void Start() {
}
UMA_HISTOGRAM_BOOLEAN("Stability.IOS.Crashpad.Initialized", initialized);
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
static crash_reporter::CrashKeyString<4> key("partition_alloc");
key.Set("yes");
#endif

@ -338,12 +338,12 @@ void IOSChromeMainParts::PreMainMessageLoopRun() {
segmentation_platform::UkmDatabaseClientHolder::GetClientInstance(nullptr)
.StartObservation();
#if BUILDFLAG(USE_PARTITION_ALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC)
base::allocator::PartitionAllocSupport::Get()
->ReconfigureAfterFeatureListInit("");
base::allocator::PartitionAllocSupport::Get()->ReconfigureAfterTaskRunnerInit(
"");
#endif // BUILDFLAG(USE_PARTITION_ALLOC)
#endif // PA_BUILDFLAG(USE_PARTITION_ALLOC)
#if BUILDFLAG(ENABLE_RLZ)
// Init the RLZ library. This just schedules a task on the file thread to be

@ -45,10 +45,10 @@ class MediaInitializer {
// Disable logging as it interferes with layout tests.
av_log_set_level(AV_LOG_QUIET);
#if BUILDFLAG(USE_ALLOCATOR_SHIM)
#if PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
// Remove allocation limit from ffmpeg, so calls go down to shim layer.
av_max_alloc(std::numeric_limits<size_t>::max());
#endif // BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // PA_BUILDFLAG(USE_ALLOCATOR_SHIM)
#endif // BUILDFLAG(ENABLE_FFMPEG)

@ -25,8 +25,8 @@ TEST(PartitionAllocMemoryDumpProviderTest, Simple) {
base::trace_event::ProcessMemoryDump pmd(args);
PartitionAllocMemoryDumpProvider::Instance()->OnMemoryDump(args, &pmd);
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_CONFIG(THREAD_CACHE_SUPPORTED) && \
!defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
histogram_tester.ExpectTotalCount("Memory.PartitionAlloc.ThreadCache.HitRate",
1);
@ -46,7 +46,7 @@ TEST(PartitionAllocMemoryDumpProviderTest, Simple) {
"Memory.PartitionAlloc.ThreadCache.BatchFillRate", 0);
histogram_tester.ExpectTotalCount(
"Memory.PartitionAlloc.ThreadCache.BatchFillRate.MainThread", 0);
#endif // !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_CONFIG(THREAD_CACHE_SUPPORTED) &&
// !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
}

@ -57,7 +57,7 @@ BASE_FEATURE(kBlinkUseLargeEmptySlotSpanRingForBufferRoot,
"BlinkUseLargeEmptySlotSpanRingForBufferRoot",
base::FEATURE_DISABLED_BY_DEFAULT);
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
// Runs PCScan on WTF partitions.
BASE_FEATURE(kPCScanBlinkPartitions,
"PartitionAllocPCScanBlinkPartitions",
@ -82,7 +82,7 @@ partition_alloc::PartitionOptions PartitionOptionsFromFeatures() {
using base::features::BackupRefPtrMode;
using partition_alloc::PartitionOptions;
#if BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#if PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
const auto brp_mode = base::features::kBackupRefPtrModeParam.Get();
const bool process_affected_by_brp_flag =
base::features::kBackupRefPtrEnabledProcessesParam.Get() ==
@ -93,7 +93,7 @@ partition_alloc::PartitionOptions PartitionOptionsFromFeatures() {
base::features::kPartitionAllocBackupRefPtr) &&
(brp_mode == BackupRefPtrMode::kEnabled) &&
process_affected_by_brp_flag;
#else // BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
#else // PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)
const bool enable_brp = false;
#endif
@ -105,12 +105,12 @@ partition_alloc::PartitionOptions PartitionOptionsFromFeatures() {
const auto memory_tagging =
enable_memory_tagging ? partition_alloc::PartitionOptions::kEnabled
: partition_alloc::PartitionOptions::kDisabled;
#if BUILDFLAG(USE_FREELIST_DISPATCHER)
#if PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
const bool pool_offset_freelists_enabled =
base::FeatureList::IsEnabled(base::features::kUsePoolOffsetFreelists);
#else
const bool pool_offset_freelists_enabled = false;
#endif // BUILDFLAG(USE_FREELIST_DISPATCHER)
#endif // PA_BUILDFLAG(USE_FREELIST_DISPATCHER)
const auto use_pool_offset_freelists =
pool_offset_freelists_enabled
? partition_alloc::PartitionOptions::kEnabled
@ -162,12 +162,12 @@ bool Partitions::InitializeOnce() {
scan_is_enabled_ =
(options.backup_ref_ptr == PartitionOptions::kDisabled) &&
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
(base::FeatureList::IsEnabled(base::features::kPartitionAllocPCScan) ||
base::FeatureList::IsEnabled(kPCScanBlinkPartitions));
#else
false;
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
// FastMalloc doesn't provide isolation, only a (hopefully fast) malloc().
// When PartitionAlloc is already the malloc() implementation, there is
@ -179,8 +179,8 @@ bool Partitions::InitializeOnce() {
//
// In addition, enable the FastMalloc partition if
// --enable-features=PartitionAllocPCScanBlinkPartitions is specified.
if (scan_is_enabled_ || !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)) {
#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
if (scan_is_enabled_ || !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)) {
#if !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
options.thread_cache = PartitionOptions::kEnabled;
#endif
static base::NoDestructor<partition_alloc::PartitionAllocator>
@ -188,7 +188,7 @@ bool Partitions::InitializeOnce() {
fast_malloc_root_ = fast_malloc_allocator->root();
}
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
if (scan_is_enabled_) {
if (!partition_alloc::internal::PCScan::IsInitialized()) {
partition_alloc::internal::PCScan::Initialize(
@ -200,7 +200,7 @@ bool Partitions::InitializeOnce() {
partition_alloc::internal::PCScan::RegisterScannableRoot(fast_malloc_root_);
// Ignore other partitions for now.
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
initialized_ = true;
return initialized_;
@ -234,14 +234,14 @@ void Partitions::InitializeArrayBufferPartition() {
array_buffer_root_ = array_buffer_allocator->root();
#if BUILDFLAG(USE_STARSCAN)
#if PA_BUILDFLAG(USE_STARSCAN)
// PCScan relies on the fact that quarantinable allocations go to PA's
// regular pool. This is not the case if configurable pool is available.
if (scan_is_enabled_ && !array_buffer_root_->uses_configurable_pool()) {
partition_alloc::internal::PCScan::RegisterNonScannableRoot(
array_buffer_root_);
}
#endif // BUILDFLAG(USE_STARSCAN)
#endif // PA_BUILDFLAG(USE_STARSCAN)
}
// static

@ -58,7 +58,7 @@ class TestMultiprocessExec final : public MultiprocessExec {
// //base/allocator/partition_allocator/src/partition_alloc/random.cc) So when
// making PartitionAllocator default, multiprocess_exec_test_child will crash
// because of LOG(FATAL) << "close". https://crbug.com/1153544
#if defined(OS_POSIX) && BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
#if defined(OS_POSIX) && PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) || \
defined(OS_MAC)
#define MAYBE_MultiprocessExec DISABLED_MultiprocessExec
#else

@ -50,7 +50,7 @@ namespace {
// fail.) To avoid this failue, firstly allocate a large buffer and read entire
// /proc/self/maps into the buffer. Next will parse data from the buffer and
// initialize MemoryMap. crbug.com/1163794.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#define MAYBE_SelfLargeFiles DISABLED_SelfLargeFiles
#else
#define MAYBE_SelfLargeFiles SelfLargeFiles
@ -89,7 +89,7 @@ TEST(MemoryMap, MAYBE_SelfLargeFiles) {
// TODO(tasak): Disable SelfBasic when PartitionAlloc is used as malloc.
// crbug.com/1163794. See SelfLargeFiles' comment.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#define MAYBE_SelfBasic DISABLED_SelfBasic
#else
#define MAYBE_SelfBasic SelfBasic
@ -330,7 +330,7 @@ void ExpectMappings(const MemoryMap& map,
// TODO(tasak): Disable SelfLargeMapFile when PartitionAlloc is used as malloc.
// crbug.com/1163794. See SelfLargeFiles' comment.
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#if PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
#define MAYBE_SelfLargeMapFile DISABLED_SelfLargeMapFile
#else
#define MAYBE_SelfLargeMapFile SelfLargeMapFile

@ -473,7 +473,7 @@ class OzonePlatformWayland : public OzonePlatform,
void PostMainMessageLoopRun() override {
// TODO(b/324294360): This will cause a lot of dangling pointers, which
// breaks linux wayland bot. Fix them and enable on linux as well.
#if BUILDFLAG(IS_CHROMEOS) || !BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
#if BUILDFLAG(IS_CHROMEOS) || !PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
connection_.reset();
#endif
}