diff options
author | Ryo Hashimoto <hashimoto@chromium.org> | 2024-05-02 03:30:12 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-05-02 10:29:37 +0000 |
commit | c72f2aaa4717e045009d9f9782b6188879b63b1d (patch) | |
tree | 6a6d2d0b51a2459201a92a270dec0c640d7cef9f | |
parent | 93cfc44323fd5be715fb2ff676d3e1c59648b181 (diff) | |
parent | 45ab17541cbdb5cac7f125b68fa1eca07989aeeb (diff) | |
download | libchrome-upstream-main.tar.gz |
libchrome r1294816 uprevupstream-main
Merge with upstream commit 45ab17541cbdb5cac7f125b68fa1eca07989aeeb
Add a new long term patch to use the pa_buildflag_header GN template
which was introduced in CL:5490693.
BUG=None
TEST=sudo emerge libchrome
Change-Id: I33cf8275502963788169ef9ed74806f430909942
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/libchrome/+/5504598
Reviewed-by: Grace Cham <hscham@chromium.org>
Tested-by: Ryo Hashimoto <hashimoto@chromium.org>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
203 files changed, 1474 insertions, 781 deletions
@@ -1 +1 @@ -1293330 +1294816 @@ -9,6 +9,7 @@ import("//common-mk/mojom_bindings_generator.gni") import("//common-mk/mojom_type_mappings_generator.gni") import("//common-mk/pkg_config.gni") import("//common-mk/proto_library.gni") +import("//libchrome/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni") import("//libchrome/build/buildflag_header.gni") libchrome_basever = read_file("BASE_VER", "trim string") @@ -182,7 +183,7 @@ buildflag_header("allocator_logging_buildflags") { flags = [ "PA_ENABLE_LOG_ERROR_NOT_REACHED=false" ] } -buildflag_header("partition_allocator_buildflags") { +pa_buildflag_header("partition_allocator_buildflags") { # Copied from base/allocator/partition_allocator/src/partition_alloc/partition_alloc.gni without # using is_nacl. if (current_cpu == "x64" || current_cpu == "arm64") { @@ -230,7 +231,7 @@ buildflag_header("partition_allocator_buildflags") { ] } -buildflag_header("partition_allocator_raw_ptr_buildflags") { +pa_buildflag_header("partition_allocator_raw_ptr_buildflags") { header = "base/allocator/partition_allocator/src/partition_alloc/raw_ptr_buildflags.h" flags = [ @@ -240,7 +241,7 @@ buildflag_header("partition_allocator_raw_ptr_buildflags") { ] } -buildflag_header("partition_allocator_chromecast_buildflags") { +pa_buildflag_header("partition_allocator_chromecast_buildflags") { header = "base/allocator/partition_allocator/src/partition_alloc/chromecast_buildflags.h" flags = [ "PA_IS_CAST_ANDROID=false", @@ -248,12 +249,12 @@ buildflag_header("partition_allocator_chromecast_buildflags") { ] } -buildflag_header("partition_allocator_chromeos_buildflags") { +pa_buildflag_header("partition_allocator_chromeos_buildflags") { header = "base/allocator/partition_allocator/src/partition_alloc/chromeos_buildflags.h" flags = [ "PA_IS_CHROMEOS_ASH=false" ] } -buildflag_header("allocator_debugging_buildflags") { +pa_buildflag_header("allocator_debugging_buildflags") { header = "base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" flags = [ "PA_DCHECK_IS_ON=false", diff --git a/base/allocator/allocator_check.cc b/base/allocator/allocator_check.cc index 442e735db3..a993747fcc 100644 --- a/base/allocator/allocator_check.cc +++ b/base/allocator/allocator_check.cc @@ -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 diff --git a/base/allocator/dispatcher/dispatcher.cc b/base/allocator/dispatcher/dispatcher.cc index 78f706cd6b..2c5dfc7870 100644 --- a/base/allocator/dispatcher/dispatcher.cc +++ b/base/allocator/dispatcher/dispatcher.cc @@ -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 } diff --git a/base/allocator/dispatcher/dispatcher_unittest.cc b/base/allocator/dispatcher/dispatcher_unittest.cc index 955ed8f541..75ce3818dd 100644 --- a/base/allocator/dispatcher/dispatcher_unittest.cc +++ b/base/allocator/dispatcher/dispatcher_unittest.cc @@ -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. diff --git a/base/allocator/dispatcher/internal/dispatch_data.cc b/base/allocator/dispatcher/internal/dispatch_data.cc index 6318e2bdb1..6ea80eb089 100644 --- a/base/allocator/dispatcher/internal/dispatch_data.cc +++ b/base/allocator/dispatcher/internal/dispatch_data.cc @@ -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; diff --git a/base/allocator/dispatcher/internal/dispatch_data.h b/base/allocator/dispatcher/internal/dispatch_data.h index e2a926eed3..3c1b24c117 100644 --- a/base/allocator/dispatcher/internal/dispatch_data.h +++ b/base/allocator/dispatcher/internal/dispatch_data.h @@ -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; diff --git a/base/allocator/dispatcher/internal/dispatcher_internal.h b/base/allocator/dispatcher/internal/dispatcher_internal.h index d2763679e5..1db681a40f 100644 --- a/base/allocator/dispatcher/internal/dispatcher_internal.h +++ b/base/allocator/dispatcher/internal/dispatcher_internal.h @@ -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 ; diff --git a/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc b/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc index 1ffb243810..9679d67a83 100644 --- a/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc +++ b/base/allocator/dispatcher/internal/dispatcher_internal_unittest.cc @@ -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 diff --git a/base/allocator/dispatcher/notification_data.h b/base/allocator/dispatcher/notification_data.h index 4d322d8c21..b9adabb5e7 100644 --- a/base/allocator/dispatcher/notification_data.h +++ b/base/allocator/dispatcher/notification_data.h @@ -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_; }; diff --git a/base/allocator/early_zone_registration_apple.cc b/base/allocator/early_zone_registration_apple.cc index afecd6fc5d..ac912b96fe 100644 --- a/base/allocator/early_zone_registration_apple.cc +++ b/base/allocator/early_zone_registration_apple.cc @@ -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 diff --git a/base/allocator/partition_alloc_features.cc b/base/allocator/partition_alloc_features.cc index f6d9f5637d..b7ef12f4d8 100644 --- a/base/allocator/partition_alloc_features.cc +++ b/base/allocator/partition_alloc_features.cc @@ -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, diff --git a/base/allocator/partition_alloc_features.h b/base/allocator/partition_alloc_features.h index e6b9125556..a5c72a6ed5 100644 --- a/base/allocator/partition_alloc_features.h +++ b/base/allocator/partition_alloc_features.h @@ -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 diff --git a/base/allocator/partition_alloc_support.cc b/base/allocator/partition_alloc_support.cc index 31f8eeaf93..4a07b5a252 100644 --- a/base/allocator/partition_alloc_support.cc +++ b/base/allocator/partition_alloc_support.cc @@ -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); diff --git a/base/allocator/partition_alloc_support.h b/base/allocator/partition_alloc_support.h index 6f05e577b1..920f37e16b 100644 --- a/base/allocator/partition_alloc_support.h +++ b/base/allocator/partition_alloc_support.h @@ -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 diff --git a/base/allocator/partition_alloc_support_unittest.cc b/base/allocator/partition_alloc_support_unittest.cc index 86bd1d4c61..799377bcf6 100644 --- a/base/allocator/partition_alloc_support_unittest.cc +++ b/base/allocator/partition_alloc_support_unittest.cc @@ -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: diff --git a/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h b/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h new file mode 100644 index 0000000000..663fd89d9a --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/aarch64_support.h @@ -0,0 +1,49 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PARTITION_ALLOC_AARCH64_SUPPORT_H_ +#define PARTITION_ALLOC_AARCH64_SUPPORT_H_ + +#include <stdint.h> + +#include "partition_alloc/build_config.h" +#include "partition_alloc/partition_alloc_buildflags.h" + +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) +#define HAS_HW_CAPS +#endif + +#if defined(ARCH_CPU_ARM64) && defined(HAS_HW_CAPS) +#include <asm/hwcap.h> +#include <sys/ifunc.h> +#else +struct __ifunc_arg_t; +#endif + +namespace partition_alloc::internal { + +constexpr bool IsBtiEnabled(uint64_t ifunc_hwcap, + struct __ifunc_arg_t* ifunc_hw) { +#if defined(ARCH_CPU_ARM64) && defined(HAS_HW_CAPS) + return (ifunc_hwcap & _IFUNC_ARG_HWCAP) && (ifunc_hw->_hwcap2 & HWCAP2_BTI); +#else + return false; +#endif +} + +constexpr bool IsMteEnabled(uint64_t ifunc_hwcap, + struct __ifunc_arg_t* ifunc_hw) { +#if defined(ARCH_CPU_ARM64) && defined(HAS_HW_CAPS) && \ + BUILDFLAG(HAS_MEMORY_TAGGING) + return (ifunc_hwcap & _IFUNC_ARG_HWCAP) && (ifunc_hw->_hwcap2 & HWCAP2_MTE); +#else + return false; +#endif +} + +} // namespace partition_alloc::internal + +#undef HAS_HW_CAPS + +#endif // PARTITION_ALLOC_AARCH64_SUPPORT_H_ diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.cc b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.cc index d4b6f6af95..d3900304de 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.cc @@ -9,8 +9,8 @@ #include <cstdint> #include <limits> -#include "build/build_config.h" #include "partition_alloc/address_space_stats.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.h b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.h index 152774da69..e1bfe28f43 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.h +++ b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager.h @@ -8,8 +8,8 @@ #include <bitset> #include <limits> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager_types.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_bitmap.h b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_bitmap.h index 4023134dd8..3036330d8f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_bitmap.h +++ b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_bitmap.h @@ -10,7 +10,7 @@ #include <bitset> #include <limits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_unittest.cc index 54281eeb07..50ccac9d38 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/address_pool_manager_unittest.cc @@ -6,8 +6,8 @@ #include <cstdint> -#include "build/build_config.h" #include "partition_alloc/address_space_stats.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/partition_alloc_base/bits.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.cc b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.cc index 1a9aff75b8..bc73fc0064 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.cc @@ -4,7 +4,7 @@ #include "partition_alloc/address_space_randomization.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_check.h" #include "partition_alloc/random.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h index 91f0de27ce..afb2b51917 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h +++ b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h @@ -7,7 +7,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization_unittest.cc index f817670de9..3879f28aa9 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization_unittest.cc @@ -7,7 +7,7 @@ #include <cstdint> #include <vector> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/allocation_guard.h b/base/allocator/partition_allocator/src/partition_alloc/allocation_guard.h index b43919b92a..27bb76f76e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/allocation_guard.h +++ b/base/allocator/partition_allocator/src/partition_alloc/allocation_guard.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_ALLOCATION_GUARD_H_ #define PARTITION_ALLOC_ALLOCATION_GUARD_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_config.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/arm_bti_test_functions.h b/base/allocator/partition_allocator/src/partition_alloc/arm_bti_test_functions.h index 0fac4fc73b..dd3efa064f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/arm_bti_test_functions.h +++ b/base/allocator/partition_allocator/src/partition_alloc/arm_bti_test_functions.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_ARM_BTI_TEST_FUNCTIONS_H_ #define PARTITION_ALLOC_ARM_BTI_TEST_FUNCTIONS_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if defined(ARCH_CPU_ARM64) extern "C" { diff --git a/base/allocator/partition_allocator/src/partition_alloc/build_config.h b/base/allocator/partition_allocator/src/partition_alloc/build_config.h new file mode 100644 index 0000000000..9936a07ff5 --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/build_config.h @@ -0,0 +1,10 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef PARTITION_ALLOC_BUILD_CONFIG_H_ +#define PARTITION_ALLOC_BUILD_CONFIG_H_ + +// TODO(https://crbug.com/41481467): Remove //build dependency. +#include "build/build_config.h" + +#endif // PARTITION_ALLOC_BUILD_CONFIG_H_ diff --git a/base/allocator/partition_allocator/src/partition_alloc/buildflag.h b/base/allocator/partition_allocator/src/partition_alloc/buildflag.h new file mode 100644 index 0000000000..6201d7bb44 --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/buildflag.h @@ -0,0 +1,17 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PARTITION_ALLOC_BUILDFLAG_H_ +#define PARTITION_ALLOC_BUILDFLAG_H_ + +// This was copied from chromium's and adapted to partition_alloc. +// Please refer to chromium's //build/buildflag.h original comments. +// +// Using a different macro and internal define allows partition_alloc and +// chromium to cohabit without affecting each other. +#define PA_BUILDFLAG_CAT_INDIRECT(a, b) a##b +#define PA_BUILDFLAG_CAT(a, b) PA_BUILDFLAG_CAT_INDIRECT(a, b) +#define PA_BUILDFLAG(flag) (PA_BUILDFLAG_CAT(PA_BUILDFLAG_INTERNAL_, flag)()) + +#endif // PARTITION_ALLOC_BUILDFLAG_H_ diff --git a/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni b/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni new file mode 100644 index 0000000000..a1c752a2bc --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni @@ -0,0 +1,121 @@ +# Copyright 2024 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This was copied from chromium's and adapted to partition_alloc. +# Please refer to chromium's //build/buildflag_header.gni + +# Generates a header with preprocessor defines specified by the build file. +# +# The flags are converted to function-style defines with mangled names and +# code uses an accessor macro to access the values. This is to try to +# minimize bugs where code checks whether something is defined or not, and +# the proper header isn't included, meaning the answer will always be silently +# false or might vary across the code base. +# +# In the GN template, specify build flags in the template as a list +# of strings that encode key/value pairs like this: +# +# flags = [ "ENABLE_FOO=1", "ENABLE_BAR=$enable_bar" ] +# +# The GN values "true" and "false" will be mapped to 0 and 1 for boolean +# #if flags to be expressed naturally. This means you can't directly make a +# define that generates C++ value of true or false for use in code. If you +# REALLY need this, you can also use the string "(true)" and "(false)" to +# prevent the rewriting. + +# The `template` creates a closure. It is important to capture the dependency +# from outside, because the template is executed from the context of the +# invoker, who uses a different current directory. +_current_dir = get_path_info(".", "abspath") + +# To check the value of the flag in C code: +# +# #include "path/to/here/header_file.h" +# +# #if PA_BUILDFLAG(ENABLE_FOO) +# ... +# #endif +# +# const char kSpamServerUrl[] = BUILDFLAG(SPAM_SERVER_URL); +# +# There will be no #define called ENABLE_FOO so if you accidentally test for +# that in an ifdef it will always be negative. +# +# +# Template parameters +# +# flags [required, list of strings] +# Flag values as described above. +# +# header [required, string] +# File name for generated header. By default, this will go in the +# generated file directory for this target, and you would include it +# with: +# #include "<path_to_this_BUILD_file>/<header>" +# +# header_dir [optional, string] +# Override the default location of the generated header. The string will +# be treated as a subdirectory of the root_gen_dir. For example: +# header_dir = "foo/bar" +# Then you can include the header as: +# #include "foo/bar/baz.h" +# +# Example +# +# pa_buildflag_header("foo_buildflags") { +# header = "foo_buildflags.h" +# +# flags = [ +# # This uses the GN build flag enable_doom_melon as the definition. +# "ENABLE_DOOM_MELON=$enable_doom_melon", +# +# # This force-enables the flag. +# "ENABLE_SPACE_LASER=true", +# +# # This will expand to the quoted C string when used in source code. +# "SPAM_SERVER_URL=\"http://www.example.com/\"", +# ] +# } +template("pa_buildflag_header") { + action(target_name) { + script = "./write_buildflag_header.py" + + if (defined(invoker.header_dir)) { + header_file = "${invoker.header_dir}/${invoker.header}" + } else { + # Compute the path from the root to this file. + header_file = rebase_path(".", "//") + "/${invoker.header}" + } + + outputs = [ "$root_gen_dir/$header_file" ] + + # Always write --flags to the file so it's not empty. Empty will confuse GN + # into thinking the response file isn't used. + response_file_contents = [ "--flags" ] + if (defined(invoker.flags)) { + response_file_contents += invoker.flags + } + + args = [ + "--output", + header_file, # Not rebased. + "--rulename", + get_label_info(":$target_name", "label_no_toolchain"), + "--gen-dir", + rebase_path(root_gen_dir, root_build_dir), + "--definitions", + "{{response_file_name}}", + ] + + forward_variables_from(invoker, + [ + "deps", + "public_deps", + "testonly", + "visibility", + ]) + + public_deps = [ "${_current_dir}:build_config" ] + } +} diff --git a/base/allocator/partition_allocator/src/partition_alloc/encoded_next_freelist.h b/base/allocator/partition_allocator/src/partition_alloc/encoded_next_freelist.h index 038fa94460..14f133b2c7 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/encoded_next_freelist.h +++ b/base/allocator/partition_allocator/src/partition_alloc/encoded_next_freelist.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/freeslot_bitmap.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/gwp_asan_support.cc b/base/allocator/partition_allocator/src/partition_alloc/gwp_asan_support.cc index 7646de2891..2295f27d99 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/gwp_asan_support.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/gwp_asan_support.cc @@ -6,7 +6,7 @@ #if BUILDFLAG(ENABLE_GWP_ASAN_SUPPORT) -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/freeslot_bitmap_constants.h" #include "partition_alloc/in_slot_metadata.h" #include "partition_alloc/page_allocator_constants.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/hardening_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/hardening_unittest.cc index 4ce8a80127..f6c11653c2 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/hardening_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/hardening_unittest.cc @@ -6,11 +6,12 @@ #include <string> #include <vector> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_config.h" #include "partition_alloc/partition_freelist_entry.h" #include "partition_alloc/partition_page.h" #include "partition_alloc/partition_root.h" +#include "partition_alloc/use_death_tests.h" #include "testing/gtest/include/gtest/gtest.h" // With *SAN, PartitionAlloc is rerouted to malloc(). @@ -19,9 +20,7 @@ namespace partition_alloc::internal { namespace { -// Death tests misbehave on Android, crbug.com/1240184 -#if !BUILDFLAG(IS_ANDROID) && defined(GTEST_HAS_DEATH_TEST) && \ - PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) +#if PA_USE_DEATH_TESTS() && PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) TEST(HardeningTest, PartialCorruption) { std::string important_data("very important"); @@ -91,8 +90,7 @@ TEST(HardeningTest, MetadataPointerCrashing) { // Crashes, because |metadata| points inside the metadata area. EXPECT_DEATH(root.Alloc(kAllocSize), ""); } -#endif // !BUILDFLAG(IS_ANDROID) && defined(GTEST_HAS_DEATH_TEST) && - // PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) +#endif // PA_USE_DEATH_TESTS() && PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) // Below test also misbehaves on Android; as above, death tests don't // quite work (crbug.com/1240184), and having free slot bitmaps enabled @@ -139,8 +137,7 @@ TEST(HardeningTest, SuccessfulCorruption) { #endif // !BUILDFLAG(IS_ANDROID) #if BUILDFLAG(USE_FREELIST_DISPATCHER) -#if !BUILDFLAG(IS_ANDROID) && defined(GTEST_HAS_DEATH_TEST) && \ - PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) +#if PA_USE_DEATH_TESTS() && PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) TEST(HardeningTest, ConstructPoolOffsetFromStackPointerCrashing) { int num_to_corrupt = 12345; int* to_corrupt = &num_to_corrupt; @@ -179,8 +176,7 @@ TEST(HardeningTest, PoolOffsetMetadataPointerCrashing) { // Crashes, because |metadata| points inside the metadata area. EXPECT_DEATH(root.Alloc(kAllocSize), ""); } -#endif // !BUILDFLAG(IS_ANDROID) && defined(GTEST_HAS_DEATH_TEST) && - // PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) +#endif // PA_USE_DEATH_TESTS() && PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) #if !BUILDFLAG(IS_ANDROID) diff --git a/base/allocator/partition_allocator/src/partition_alloc/in_slot_metadata.h b/base/allocator/partition_allocator/src/partition_alloc/in_slot_metadata.h index 70e927a646..219cdad801 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/in_slot_metadata.h +++ b/base/allocator/partition_allocator/src/partition_alloc/in_slot_metadata.h @@ -11,7 +11,7 @@ #include <cstdint> #include <limits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/dangling_raw_ptr_checks.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/memory_reclaimer_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/memory_reclaimer_unittest.cc index 2f501ddf9a..81b2161d4f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/memory_reclaimer_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/memory_reclaimer_unittest.cc @@ -7,7 +7,7 @@ #include <memory> #include <utility> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/oom.cc b/base/allocator/partition_allocator/src/partition_alloc/oom.cc index 58801cc7f4..b21f36ab42 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/oom.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/oom.cc @@ -4,7 +4,7 @@ #include "partition_alloc/oom.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/oom_callback.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/debug/alias.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/oom.h b/base/allocator/partition_allocator/src/partition_alloc/oom.h index 3e666e184d..9ee66f1c90 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/oom.h +++ b/base/allocator/partition_allocator/src/partition_alloc/oom.h @@ -7,8 +7,8 @@ #include <cstddef> -#include "build/build_config.h" #include "partition_alloc/allocation_guard.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator.cc b/base/allocator/partition_allocator/src/partition_alloc/page_allocator.cc index 280624c1ed..439adcee40 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator.cc @@ -8,8 +8,8 @@ #include <bit> #include <cstdint> -#include "build/build_config.h" #include "partition_alloc/address_space_randomization.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_internal.h" #include "partition_alloc/partition_alloc_base/thread_annotations.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h b/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h index 19f9e7f8f7..6e73c6aa03 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h index b5bd4221ce..e6aef0abfc 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h @@ -7,7 +7,7 @@ #include <cstddef> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc index c325beaea2..c4448cad90 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.cc @@ -3,48 +3,76 @@ // found in the LICENSE file. #include <sys/mman.h> -#include "build/build_config.h" +#include "partition_alloc/aarch64_support.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "partition_alloc/partition_alloc_base/notreached.h" +#include "partition_alloc/partition_alloc_buildflags.h" // PA_PROT_BTI requests a page that supports BTI landing pads. #define PA_PROT_BTI 0x10 // PA_PROT_MTE requests a page that's suitable for memory tagging. -#if defined(ARCH_CPU_ARM64) #define PA_PROT_MTE 0x20 -#endif // defined(ARCH_CPU_ARM64) namespace partition_alloc::internal { +namespace { -int GetAccessFlags(PageAccessibilityConfiguration accessibility) { +int GetAccessFlags(PageAccessibilityConfiguration accessibility, + bool mte_enabled, + bool bti_enabled) { switch (accessibility.permissions) { case PageAccessibilityConfiguration::kRead: return PROT_READ; case PageAccessibilityConfiguration::kReadWriteTagged: -#if defined(ARCH_CPU_ARM64) - return PROT_READ | PROT_WRITE | - (base::CPU::GetInstanceNoAllocation().has_mte() ? PA_PROT_MTE : 0); -#else - [[fallthrough]]; -#endif + return PROT_READ | PROT_WRITE | (mte_enabled ? PA_PROT_MTE : 0); case PageAccessibilityConfiguration::kReadWrite: return PROT_READ | PROT_WRITE; case PageAccessibilityConfiguration::kReadExecuteProtected: - return PROT_READ | PROT_EXEC | - (base::CPU::GetInstanceNoAllocation().has_bti() ? PA_PROT_BTI : 0); + return PROT_READ | PROT_EXEC | (bti_enabled ? PA_PROT_BTI : 0); case PageAccessibilityConfiguration::kReadExecute: return PROT_READ | PROT_EXEC; case PageAccessibilityConfiguration::kReadWriteExecute: return PROT_READ | PROT_WRITE | PROT_EXEC; case PageAccessibilityConfiguration::kReadWriteExecuteProtected: return PROT_READ | PROT_WRITE | PROT_EXEC | - (base::CPU::GetInstanceNoAllocation().has_bti() ? PA_PROT_BTI : 0); + (bti_enabled ? PA_PROT_BTI : 0); case PageAccessibilityConfiguration::kInaccessible: case PageAccessibilityConfiguration::kInaccessibleWillJitLater: return PROT_NONE; } } +template <bool MteEnabled, bool BtiEnabled> +int GetAccessFlags(PageAccessibilityConfiguration accessibility) { + return GetAccessFlags(accessibility, MteEnabled, BtiEnabled); +} + +} // namespace + +using GetAccessFlagsInternalFn = int(PageAccessibilityConfiguration); + +extern "C" GetAccessFlagsInternalFn* ResolveGetAccessFlags( + uint64_t hwcap, + struct __ifunc_arg_t* hw) { + if (IsMteEnabled(hwcap, hw)) { + if (IsBtiEnabled(hwcap, hw)) { + return GetAccessFlags<true, true>; + } else { + return GetAccessFlags<true, false>; + } + } else { + if (IsBtiEnabled(hwcap, hw)) { + return GetAccessFlags<false, true>; + } else { + return GetAccessFlags<false, false>; + } + } +} + +// Resolve the implementation for GetAccessFlags using an iFunc. +int GetAccessFlags(PageAccessibilityConfiguration accessibility) + __attribute__((ifunc("ResolveGetAccessFlags"))); + } // namespace partition_alloc::internal diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h index 6b8629f0c6..809c5ff67c 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_internals_posix.h @@ -5,15 +5,15 @@ #ifndef PARTITION_ALLOC_PAGE_ALLOCATOR_INTERNALS_POSIX_H_ #define PARTITION_ALLOC_PAGE_ALLOCATOR_INTERNALS_POSIX_H_ +#include <sys/mman.h> + #include <algorithm> #include <atomic> #include <cerrno> #include <cstdint> #include <cstring> -#include <sys/mman.h> - -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/oom.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/page_allocator_constants.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_unittest.cc index 5932bdca40..d7b714a8ee 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_unittest.cc @@ -11,8 +11,8 @@ #include <string> #include <vector> -#include "build/build_config.h" #include "partition_alloc/address_space_randomization.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "partition_alloc/partition_alloc_base/logging.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.cc index 9a26aa6e4b..df407d31e2 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.cc @@ -11,8 +11,8 @@ #include <ostream> #include <string> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/compressed_pointer.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.h b/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.h index 480e7e8464..54edf02650 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_address_space.h @@ -9,8 +9,8 @@ #include <cstddef> #include <utility> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager_types.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc-inl.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc-inl.h index 9076aee143..a5a4735886 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc-inl.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc-inl.h @@ -8,7 +8,7 @@ #include <algorithm> #include <cstring> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/in_slot_metadata.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/apple/mach_logging.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/apple/mach_logging.h index 4069517bf8..70995fc532 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/apple/mach_logging.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/apple/mach_logging.h @@ -7,7 +7,7 @@ #include <mach/mach.h> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/logging.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/compiler_specific.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/compiler_specific.h index 0dccce5aa8..6e6648b118 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/compiler_specific.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/compiler_specific.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_COMPILER_SPECIFIC_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_COMPILER_SPECIFIC_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" // A wrapper around `__has_cpp_attribute`. #if defined(__has_cpp_attribute) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.cc index f7777214a9..ff43808f7a 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.cc @@ -13,7 +13,7 @@ #include <sstream> #include <utility> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if defined(ARCH_CPU_ARM_FAMILY) && \ (BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.h index 08a2da98f6..4801671989 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_CPU_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_CPU_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" namespace partition_alloc::internal::base { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu_pa_unittest.cc index 063159ae7a..8c7fd8c7c3 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/cpu_pa_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.cc index d221694570..993885cede 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.cc @@ -6,7 +6,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/process/process_handle.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.h index 6d1509e9b1..7627e7ef9d 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace_linux.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace_linux.cc index f9dfe86682..851543e498 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace_linux.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/debug/stack_trace_linux.cc @@ -4,7 +4,7 @@ #include "partition_alloc/partition_alloc_base/debug/stack_trace.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" namespace partition_alloc::internal::base::debug { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path.h index 23ce8cac7d..01cb0a6891 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path.h @@ -106,7 +106,7 @@ #include <iosfwd> #include <string> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" // Windows-style drive letter support and pathname separator characters can be diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path_pa_unittest.cc index 241594a811..6ce0baf334 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_path_pa_unittest.cc @@ -5,7 +5,7 @@ #include <cstddef> #include <sstream> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/files/file_path.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_util.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_util.h index e823c2a61e..3f9c14637d 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_util.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/files/file_util.h @@ -12,7 +12,7 @@ #include <cstdint> #include <cstdio> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/immediate_crash.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/immediate_crash.h index 548ba1e396..7227629fd8 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/immediate_crash.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/immediate_crash.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_IMMEDIATE_CRASH_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_IMMEDIATE_CRASH_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" // Crashes in the fastest possible way with no attempt at logging. // There are several constraints; see http://crbug.com/664209 for more context. diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.cc index d6581d3d22..cfe371ecb3 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.cc @@ -14,7 +14,7 @@ #error "log_message.h should not include check.h" #endif -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/alias.h" #include "partition_alloc/partition_alloc_base/debug/stack_trace.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.h index 896734efcc..b50d353763 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/log_message.h @@ -7,7 +7,7 @@ #include <cstddef> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/scoped_clear_last_error.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.cc index 9a1dc6eda0..d360c884b6 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.cc @@ -14,13 +14,13 @@ #error "logging.h should not include check.h" #endif -#include "build/build_config.h" +#include <algorithm> + +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/alias.h" #include "partition_alloc/partition_alloc_base/immediate_crash.h" -#include <algorithm> - #if BUILDFLAG(IS_WIN) #include <windows.h> diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.h index 38e68c288c..b612f96baf 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging.h @@ -9,7 +9,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging_pa_unittest.cc index 0f978049fd..fa8a3a03ff 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/logging_pa_unittest.cc @@ -5,10 +5,9 @@ #include <sstream> #include <string> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/logging.h" - #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.cc index ba9426eb5e..da9e227b17 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.cc @@ -8,7 +8,7 @@ #include <ostream> #include <type_traits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" namespace partition_alloc::internal::base::subtle { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.h index 0932f496ba..2f06b6186b 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/memory/ref_counted.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_MEMORY_REF_COUNTED_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_MEMORY_REF_COUNTED_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/atomic_ref_count.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library.h index 40416a45da..9244afda70 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library.h @@ -10,7 +10,7 @@ #include <string> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/files/file_path.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library_posix.cc index 0b01c3aa7f..96c7ebe164 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library_posix.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/native_library_posix.cc @@ -6,7 +6,7 @@ #include <dlfcn.h> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/files/file_path.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/numerics/safe_math_shared_impl.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/numerics/safe_math_shared_impl.h index 98aadd87d3..c9f76f5ff7 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/numerics/safe_math_shared_impl.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/numerics/safe_math_shared_impl.h @@ -14,7 +14,7 @@ #include <limits> #include <type_traits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/numerics/safe_conversions.h" #if BUILDFLAG(IS_ASMJS) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/eintr_wrapper.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/eintr_wrapper.h index eb51cd2162..b40e1c1914 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/eintr_wrapper.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/eintr_wrapper.h @@ -17,7 +17,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_POSIX_EINTR_WRAPPER_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_POSIX_EINTR_WRAPPER_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if BUILDFLAG(IS_POSIX) #include <cerrno> diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/safe_strerror.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/safe_strerror.cc index 3a6dea48a6..a910431edb 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/safe_strerror.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/posix/safe_strerror.cc @@ -8,7 +8,7 @@ #include <cstdio> #include <cstring> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" namespace partition_alloc::internal::base { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/process/process_handle.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/process/process_handle.h index 565f08e94f..7426f290c5 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/process/process_handle.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/process/process_handle.h @@ -9,7 +9,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #if BUILDFLAG(IS_WIN) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util.h index b3b14aece4..c50765bc4c 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" namespace partition_alloc { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util_posix.cc index b8f4c58a01..f128b65bf2 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util_posix.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/rand_util_posix.cc @@ -13,7 +13,7 @@ #include <cstdint> #include <sstream> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/files/file_util.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error.h index 4e4ba0fc0c..986f46cf81 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error.h @@ -7,7 +7,7 @@ #include <cerrno> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" namespace partition_alloc::internal::base { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error_pa_unittest.cc index 1856abd1aa..0b9f89e33b 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/scoped_clear_last_error_pa_unittest.cc @@ -2,10 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "partition_alloc/partition_alloc_base/scoped_clear_last_error.h" - -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/logging.h" +#include "partition_alloc/partition_alloc_base/scoped_clear_last_error.h" #include "testing/gtest/include/gtest/gtest.h" #if BUILDFLAG(IS_WIN) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.cc index 59225b6ebd..2cafe396b0 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.cc @@ -4,7 +4,7 @@ #include "partition_alloc/partition_alloc_base/strings/cstring_builder.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/strings/safe_sprintf.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.h index c790986b5d..fbeff75282 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder.h @@ -5,11 +5,11 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_STRINGS_CSTRING_BUILDER_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_STRINGS_CSTRING_BUILDER_H_ -#include "build/build_config.h" -#include "partition_alloc/partition_alloc_base/component_export.h" - #include <cstddef> +#include "partition_alloc/build_config.h" +#include "partition_alloc/partition_alloc_base/component_export.h" + #if !BUILDFLAG(IS_WIN) #include <unistd.h> #endif diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder_pa_unittest.cc index c480242341..1f7c1d214a 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/cstring_builder_pa_unittest.cc @@ -2,11 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "partition_alloc/partition_alloc_base/strings/cstring_builder.h" - #include <cmath> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" +#include "partition_alloc/partition_alloc_base/strings/cstring_builder.h" #include "testing/gtest/include/gtest/gtest.h" namespace partition_alloc::internal::base::strings { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.cc index af551784d4..e0b99cb78f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.cc @@ -9,7 +9,7 @@ #include <cstring> #include <limits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if !defined(NDEBUG) // In debug builds, we use RAW_CHECK() to print useful error messages, if diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.h index e8a1938903..478f255ca0 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf.h @@ -9,7 +9,7 @@ #include <cstdint> #include <cstdlib> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) // For ssize_t diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf_pa_unittest.cc index b91387eb5f..5300fd6468 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/safe_sprintf_pa_unittest.cc @@ -9,7 +9,7 @@ #include <limits> #include <memory> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/strings/safe_sprintf.h" #include "partition_alloc/partition_alloc_config.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/string_util_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/string_util_pa_unittest.cc index 5e8175f95f..510d26d9ab 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/string_util_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/string_util_pa_unittest.cc @@ -2,9 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/strings/string_util.h" - -#include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" namespace partition_alloc::internal::base::strings { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf.h index 60a2870f13..c8665a30c2 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf.h @@ -8,7 +8,7 @@ #include <cstdarg> // va_list #include <string> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf_pa_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf_pa_unittest.cc index 9aa75b27a7..423b24542f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf_pa_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/strings/stringprintf_pa_unittest.cc @@ -5,7 +5,7 @@ #include <cerrno> #include <cstddef> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/strings/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h index 980d86a54f..a5df5c2fab 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h @@ -37,7 +37,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREAD_ANNOTATIONS_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREAD_ANNOTATIONS_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #if defined(__clang__) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread.h index ed8c9af4e1..d971d623cf 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread.h @@ -12,7 +12,7 @@ #include <cstddef> #include <iosfwd> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_ref.h" #include "partition_alloc/partition_alloc_base/time/time.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_apple_for_testing.mm b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_apple_for_testing.mm index ee870a41b9..29cdddd99a 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_apple_for_testing.mm +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_apple_for_testing.mm @@ -13,7 +13,7 @@ #include <atomic> #include <cstddef> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h index 150a04049e..f6789a3c91 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h @@ -12,7 +12,7 @@ #include <cstddef> #include <iosfwd> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread.h" namespace partition_alloc::internal::base { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h index 91404a4379..c2b65b9972 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREADING_PLATFORM_THREAD_INTERNAL_POSIX_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREADING_PLATFORM_THREAD_INTERNAL_POSIX_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" namespace partition_alloc::internal::base::internal { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix.cc index 0bef6890ef..dfdb0d10c5 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix.cc @@ -13,7 +13,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_internal_posix.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix_for_testing.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix_for_testing.cc index 86de89a3d2..c8551add5f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix_for_testing.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_posix_for_testing.cc @@ -13,7 +13,7 @@ #include <cstdint> #include <memory> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_ref.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_ref.h index ee2d5e9e12..8c70071e9d 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_ref.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread_ref.h @@ -12,7 +12,7 @@ #include <iosfwd> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #if BUILDFLAG(IS_WIN) diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time.h index 013faf1255..42bed11dbe 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time.h @@ -67,7 +67,7 @@ #include <iosfwd> #include <limits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/chromeos_buildflags.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_apple.mm b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_apple.mm index ae0d745b82..a477408920 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_apple.mm +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_apple.mm @@ -19,7 +19,7 @@ #include <cerrno> #endif -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_base/numerics/safe_conversions.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_now_posix.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_now_posix.cc index a5d2d00d10..e9db4efbcf 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_now_posix.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_now_posix.cc @@ -7,7 +7,7 @@ #include <cstdint> #include <ctime> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/time/time.h" #if BUILDFLAG(IS_ANDROID) && !defined(__LP64__) #include <time64.h> diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_override.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_override.h index 0eb18720e6..adff6be6a7 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_override.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/time/time_override.h @@ -7,7 +7,7 @@ #include <atomic> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/time/time.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_check.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_check.h index aa0131aa4e..d589b03996 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_check.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_check.h @@ -7,7 +7,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/check.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_config.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_config.h index 034dc1a37e..ac33c50cad 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_config.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_config.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_ALLOC_CONFIG_H_ #define PARTITION_ALLOC_PARTITION_ALLOC_CONFIG_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h index 6f18dc3ff1..1cc238c9a9 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h @@ -10,8 +10,8 @@ #include <cstddef> #include <limits> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager_types.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/flags.h" #include "partition_alloc/page_allocator_constants.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc index e4f779142c..05ad7dd08c 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_perftest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "partition_alloc/partition_alloc.h" + #include <algorithm> #include <atomic> #include <limits> @@ -10,9 +12,8 @@ #include "base/debug/debugging_buildflags.h" #include "base/timer/lap_timer.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/extended_api.h" -#include "partition_alloc/partition_alloc.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_base/strings/stringprintf.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc index b60e04ce4c..cba6e61cd0 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_unittest.cc @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "partition_alloc/partition_alloc_for_testing.h" - #include <algorithm> #include <bit> #include <cstddef> @@ -20,8 +18,8 @@ #include "base/system/sys_info.h" #include "base/test/gtest_util.h" -#include "build/build_config.h" #include "partition_alloc/address_space_randomization.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/chromecast_buildflags.h" #include "partition_alloc/dangling_raw_ptr_checks.h" #include "partition_alloc/freeslot_bitmap.h" @@ -42,6 +40,7 @@ #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_config.h" #include "partition_alloc/partition_alloc_constants.h" +#include "partition_alloc/partition_alloc_for_testing.h" #include "partition_alloc/partition_alloc_forward.h" #include "partition_alloc/partition_bucket.h" #include "partition_alloc/partition_cookie.h" @@ -52,6 +51,7 @@ #include "partition_alloc/reservation_offset_table.h" #include "partition_alloc/tagging.h" #include "partition_alloc/thread_isolation/thread_isolation.h" +#include "partition_alloc/use_death_tests.h" #include "testing/gtest/include/gtest/gtest.h" #if defined(__ARM_FEATURE_MEMORY_TAGGING) @@ -608,9 +608,7 @@ class PartitionAllocTest #endif }; -// Death tests misbehave on Android, http://crbug.com/643760. -#if defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID) -#define PA_HAS_DEATH_TESTS +#if PA_USE_DEATH_TESTS() class PartitionAllocDeathTest : public PartitionAllocTest {}; @@ -2369,7 +2367,7 @@ TEST_P(PartitionAllocTest, LostFreeSlotSpansBug) { EXPECT_TRUE(bucket->decommitted_slot_spans_head); } -#if defined(PA_HAS_DEATH_TESTS) +#if PA_USE_DEATH_TESTS() // Unit tests that check if an allocation fails in "return null" mode, // repeating it doesn't crash, and still returns null. The tests need to @@ -2659,7 +2657,7 @@ TEST_P(PartitionAllocDeathTest, OffByOneDetectionWithRealisticData) { #endif // !BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && // PA_CONFIG(HAS_FREELIST_SHADOW_ENTRY) -#endif // !defined(PA_HAS_DEATH_TESTS) +#endif // PA_USE_DEATH_TESTS() // Tests that |PartitionDumpStats| and |PartitionDumpStats| run without // crashing and return non-zero values when memory is allocated. @@ -4785,7 +4783,7 @@ TEST_P(PartitionAllocTest, DanglingPtrReleaseAfterSchedulerLoopQuarantineExit) { PartitionAllocFreeForRefCounting(allocator.root()->ObjectToSlotStart(ptr)); } -#if defined(PA_HAS_DEATH_TESTS) +#if PA_USE_DEATH_TESTS() // DCHECK message are stripped in official build. It causes death tests with // matchers to fail. #if !defined(OFFICIAL_BUILD) || !defined(NDEBUG) @@ -4823,7 +4821,7 @@ TEST_P(PartitionAllocDeathTest, ReleaseUnderflowDanglingPtr) { } #endif //! defined(OFFICIAL_BUILD) || !defined(NDEBUG) -#endif // defined(PA_HAS_DEATH_TESTS) +#endif // PA_USE_DEATH_TESTS() #endif // BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS) TEST_P(PartitionAllocTest, ReservationOffset) { @@ -5028,7 +5026,7 @@ TEST_P(PartitionAllocTest, FastPathOrReturnNull) { allocator.root()->Free<FreeFlags::kNoHooks>(ptr2); } -#if defined(PA_HAS_DEATH_TESTS) +#if PA_USE_DEATH_TESTS() // DCHECK message are stripped in official build. It causes death tests with // matchers to fail. #if !defined(OFFICIAL_BUILD) || !defined(NDEBUG) @@ -5039,12 +5037,12 @@ TEST_P(PartitionAllocDeathTest, CheckTriggered) { } #endif // !defined(OFFICIAL_BUILD) && !defined(NDEBUG) -#endif // defined(PA_HAS_DEATH_TESTS) +#endif // PA_USE_DEATH_TESTS() // Not on chromecast, since gtest considers extra output from itself as a test // failure: // https://ci.chromium.org/ui/p/chromium/builders/ci/Cast%20Audio%20Linux/98492/overview -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && defined(PA_HAS_DEATH_TESTS) && \ +#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && PA_USE_DEATH_TESTS() && \ !BUILDFLAG(PA_IS_CASTOS) namespace { @@ -5122,7 +5120,7 @@ TEST_P(PartitionAllocTest, DISABLED_PreforkHandler) { } #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && - // PA_CONFIG(HAS_DEATH_TESTS) && !BUILDFLAG(PA_IS_CASTOS) + // PA_USE_DEATH_TESTS() && !BUILDFLAG(PA_IS_CASTOS) // Checks the bucket index logic. TEST_P(PartitionAllocTest, GetIndex) { diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc index f66e4da760..a91b50710e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc @@ -9,8 +9,8 @@ #include <cstdint> #include <tuple> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/freeslot_bitmap.h" #include "partition_alloc/freeslot_bitmap_constants.h" #include "partition_alloc/oom.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_lock.h b/base/allocator/partition_allocator/src/partition_alloc/partition_lock.h index 3a9fc02f0f..5b3c8d8041 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_lock.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_lock.h @@ -8,7 +8,7 @@ #include <atomic> #include <type_traits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/immediate_crash.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_lock_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_lock_unittest.cc index f60da82600..66c942ba9e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_lock_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_lock_unittest.cc @@ -4,7 +4,7 @@ #include "partition_alloc/partition_lock.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/debug/debugging_buildflags.h" #include "partition_alloc/partition_alloc_base/thread_annotations.h" #include "partition_alloc/partition_alloc_base/threading/platform_thread_for_testing.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_oom.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_oom.cc index 17f1d61bf9..4c2b82ddf5 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_oom.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_oom.cc @@ -4,7 +4,7 @@ #include "partition_alloc/partition_oom.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/oom.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/debug/alias.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_oom.h b/base/allocator/partition_allocator/src/partition_alloc/partition_oom.h index 0af88dbedc..f37aeacefc 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_oom.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_oom.h @@ -10,7 +10,7 @@ #include <cstddef> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_page.h b/base/allocator/partition_allocator/src/partition_alloc/partition_page.h index ab08e30c58..2a82685d43 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_page.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_page.h @@ -7,9 +7,9 @@ #include <cstdint> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" #include "partition_alloc/address_pool_manager_types.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/freeslot_bitmap_constants.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc_base/bits.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h b/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h index 1a48c117ae..773d9eec3e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_PAGE_CONSTANTS_H_ #define PARTITION_ALLOC_PARTITION_PAGE_CONSTANTS_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_constants.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_root.cc b/base/allocator/partition_allocator/src/partition_alloc/partition_root.cc index 2a66a615ce..f44e522bb4 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_root.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_root.cc @@ -6,7 +6,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/freeslot_bitmap.h" #include "partition_alloc/in_slot_metadata.h" #include "partition_alloc/oom.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_root.h b/base/allocator/partition_allocator/src/partition_alloc/partition_root.h index 6efa592738..96fc2a45ac 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_root.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_root.h @@ -39,9 +39,9 @@ #include <optional> #include <utility> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager_types.h" #include "partition_alloc/allocation_guard.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/chromecast_buildflags.h" #include "partition_alloc/freeslot_bitmap.h" #include "partition_alloc/in_slot_metadata.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/partition_tls.h b/base/allocator/partition_allocator/src/partition_alloc/partition_tls.h index 8fe8a6f9a0..9d2112819e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/partition_tls.h +++ b/base/allocator/partition_allocator/src/partition_alloc/partition_tls.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_PARTITION_TLS_H_ #define PARTITION_ALLOC_PARTITION_TLS_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/immediate_crash.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h index 28c3ff1d1c..5bd9d91fec 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h +++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr.h @@ -11,7 +11,7 @@ #include <type_traits> #include <utility> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/flags.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_backup_ref_impl.h b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_backup_ref_impl.h index 8c2fa2b772..df1ddf0911 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_backup_ref_impl.h +++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_backup_ref_impl.h @@ -8,7 +8,7 @@ #include <cstddef> #include <type_traits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_exclusion.h b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_exclusion.h index eaff56973c..7734657c11 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_exclusion.h +++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_exclusion.h @@ -7,12 +7,12 @@ // This header will be leakily included even when // `!use_partition_alloc`, which is okay because it's a leaf header. -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" // nogncheck #include "partition_alloc/partition_alloc_buildflags.h" #if PA_HAS_ATTRIBUTE(annotate) -#if defined(OFFICIAL_BUILD) && !BUILDFLAG(FORCE_ENABLE_RAW_PTR_EXCLUSION) +#if defined(OFFICIAL_BUILD) && !PA_BUILDFLAG(FORCE_ENABLE_RAW_PTR_EXCLUSION) // The annotation changed compiler output and increased binary size so disable // for official builds. // TODO(crbug.com/40836910): Remove when issue is resolved. diff --git a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc index 7cac4b1a4b..2d4d1597a8 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/pointers/raw_ptr_unittest.cc @@ -26,7 +26,7 @@ #include "base/test/memory/dangling_ptr_instrumentation.h" #include "base/test/scoped_feature_list.h" #include "base/types/to_address.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/dangling_raw_ptr_checks.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/pool_offset_freelist.h b/base/allocator/partition_allocator/src/partition_alloc/pool_offset_freelist.h index 08a51e0e3d..b2213d5d9e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/pool_offset_freelist.h +++ b/base/allocator/partition_allocator/src/partition_alloc/pool_offset_freelist.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/reservation_offset_table.h b/base/allocator/partition_allocator/src/partition_alloc/reservation_offset_table.h index 992baf8aad..b7ba07c387 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/reservation_offset_table.h +++ b/base/allocator/partition_allocator/src/partition_alloc/reservation_offset_table.h @@ -10,8 +10,8 @@ #include <limits> #include <tuple> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/reverse_bytes.h b/base/allocator/partition_allocator/src/partition_alloc/reverse_bytes.h index e8d7f42887..d9db43e197 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/reverse_bytes.h +++ b/base/allocator/partition_allocator/src/partition_alloc/reverse_bytes.h @@ -12,7 +12,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_config.h" namespace partition_alloc::internal { diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.mm b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.mm index 591bbef2f3..3554fb2c11 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.mm +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_interception_apple.mm @@ -31,7 +31,7 @@ #include <cstddef> #include <new> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/oom.h" #include "partition_alloc/partition_alloc_base/apple/mach_logging.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.cc index 808a0c5154..9e2909bc49 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.cc @@ -4,11 +4,11 @@ #include "partition_alloc/shim/allocator_shim.h" -#include "build/build_config.h" -#include "partition_alloc/partition_alloc_buildflags.h" - #include <unistd.h> +#include "partition_alloc/build_config.h" +#include "partition_alloc/partition_alloc_buildflags.h" + #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) #include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h" #endif diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h index cc80b7cc5f..3654002e4f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim.h @@ -11,7 +11,7 @@ #include "partition_alloc/partition_alloc_buildflags.h" #if BUILDFLAG(USE_ALLOCATOR_SHIM) -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/types/strong_alias.h" #include "partition_alloc/shim/allocator_dispatch.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_android.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_android.cc index 65c00de4cb..c12907cff6 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_android.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_android.cc @@ -6,7 +6,7 @@ #include <unistd.h> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_buildflags.h" #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_apple.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_apple.cc index de49a5d459..8cf5a8b430 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_apple.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_apple.cc @@ -7,7 +7,7 @@ #include <malloc/malloc.h> #include <unistd.h> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/apple/mach_logging.h" #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc index d0d0567894..5b523a1dd3 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_linker_wrapped_symbols.cc @@ -4,7 +4,7 @@ #include <malloc.h> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/shim/allocator_shim.h" // This translation unit defines a default dispatch for the allocator shim which diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc index 104daccb08..379268f0d5 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.cc @@ -11,8 +11,8 @@ #include <string> #include <tuple> -#include "build/build_config.h" #include "partition_alloc/allocation_guard.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/chromecast_buildflags.h" #include "partition_alloc/memory_reclaimer.h" #include "partition_alloc/partition_alloc.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc index ef2bec3a94..3fdecdccae 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc @@ -7,7 +7,7 @@ #include <cstdlib> #include <cstring> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/memory/page_size.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_functions.h b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_functions.h index a64d3c53ce..9edb276a48 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_functions.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_functions.h @@ -13,7 +13,7 @@ #include <cstddef> #include <new> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_check.h" #include "partition_alloc/shim/allocator_dispatch.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h index a059311794..36f3ba8a25 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_internals.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_SHIM_ALLOCATOR_SHIM_INTERNALS_H_ #define PARTITION_ALLOC_SHIM_ALLOCATOR_SHIM_INTERNALS_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if defined(__GNUC__) diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_cpp_symbols.h b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_cpp_symbols.h index bdcddad2da..8bda9566b4 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_cpp_symbols.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_cpp_symbols.h @@ -18,7 +18,7 @@ #include <new> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/shim/allocator_shim_internals.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h index 74457ce489..d60cfa9d3f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_override_libc_symbols.h @@ -15,7 +15,7 @@ #include "partition_alloc/partition_alloc_buildflags.h" #if BUILDFLAG(USE_ALLOCATOR_SHIM) -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #if BUILDFLAG(IS_APPLE) #include <malloc/malloc.h> diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_unittest.cc index a9550a7781..57dd77ecac 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/allocator_shim_unittest.cc @@ -15,7 +15,7 @@ #include "base/synchronization/waitable_event.h" #include "base/threading/platform_thread.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc.h" #include "partition_alloc/partition_alloc_base/memory/page_size.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/shim/shim_alloc_functions.h b/base/allocator/partition_allocator/src/partition_alloc/shim/shim_alloc_functions.h index 13a7a8bef1..c31aa6f588 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/shim/shim_alloc_functions.h +++ b/base/allocator/partition_allocator/src/partition_alloc/shim/shim_alloc_functions.h @@ -12,7 +12,7 @@ #include <bit> #include <cerrno> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/bits.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/memory/page_size.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.cc b/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.cc index 29aacf3134..56b289ec0b 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.cc @@ -4,7 +4,7 @@ #include "partition_alloc/spinning_mutex.h" -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.h b/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.h index 12a5a9c2bc..b550fb4da0 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.h +++ b/base/allocator/partition_allocator/src/partition_alloc/spinning_mutex.h @@ -8,7 +8,7 @@ #include <algorithm> #include <atomic> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_base/thread_annotations.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/stack/stack.cc b/base/allocator/partition_allocator/src/partition_alloc/stack/stack.cc index ac79887af4..3c4086b4c8 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/stack/stack.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/stack/stack.cc @@ -7,7 +7,7 @@ #include <cstdint> #include <limits> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/stack/stack_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/stack/stack_unittest.cc index 6fa1002719..dc20f6392e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/stack/stack_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/stack/stack_unittest.cc @@ -7,7 +7,7 @@ #include <memory> #include <ostream> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_internal.cc b/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_internal.cc index b365a4d8d0..3bb294841f 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_internal.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_internal.cc @@ -17,9 +17,9 @@ #include <unordered_map> #include <vector> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" #include "partition_alloc/allocation_guard.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/internal_allocator.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/page_allocator_constants.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_unittest.cc index bbc4deb3f8..b22f650533 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/pcscan_unittest.cc @@ -6,9 +6,7 @@ #if !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) -#include "partition_alloc/starscan/pcscan.h" - -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc_base/bits.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" @@ -21,7 +19,9 @@ #include "partition_alloc/partition_freelist_entry.h" #include "partition_alloc/partition_root.h" #include "partition_alloc/stack/stack.h" +#include "partition_alloc/starscan/pcscan.h" #include "partition_alloc/tagging.h" +#include "partition_alloc/use_death_tests.h" #include "testing/gtest/include/gtest/gtest.h" #if BUILDFLAG(USE_STARSCAN) @@ -531,16 +531,15 @@ TEST_F(PartitionAllocPCScanTest, DanglingReferenceFromNonScannablePartition) { TestDanglingReferenceNotVisited(*this, value, value_root); } -// Death tests misbehave on Android, http://crbug.com/643760. -#if defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID) -#if PA_CONFIG(STARSCAN_EAGER_DOUBLE_FREE_DETECTION_ENABLED) +#if PA_USE_DEATH_TESTS() && \ + PA_CONFIG(STARSCAN_EAGER_DOUBLE_FREE_DETECTION_ENABLED) TEST_F(PartitionAllocPCScanTest, DoubleFree) { auto* list = List<1>::Create(root()); List<1>::Destroy(root(), list); EXPECT_DEATH(List<1>::Destroy(root(), list), ""); } -#endif // PA_CONFIG(STARSCAN_EAGER_DOUBLE_FREE_DETECTION_ENABLED) -#endif // defined(GTEST_HAS_DEATH_TEST) && !BUILDFLAG(IS_ANDROID) +#endif // PA_USE_DEATH_TESTS() && + // PA_CONFIG(STARSCAN_EAGER_DOUBLE_FREE_DETECTION_ENABLED) template <typename SourceList, typename ValueList> void TestDanglingReferenceWithSafepoint(PartitionAllocPCScanTest& test, diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop.h b/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop.h index b2facc00ca..619218d578 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop.h +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop.h @@ -8,7 +8,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_check.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop_unittest.cc index bba33465c0..5c3aedff8e 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/scan_loop_unittest.cc @@ -6,11 +6,10 @@ #include <algorithm> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "partition_alloc/partition_alloc_buildflags.h" #include "partition_alloc/partition_alloc_config.h" - #include "testing/gtest/include/gtest/gtest.h" #if BUILDFLAG(HAS_64_BIT_POINTERS) diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.cc b/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.cc index a41e1f87fa..27391301fe 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.cc @@ -7,8 +7,8 @@ #include <mutex> #include <thread> -#include "build/build_config.h" #include "partition_alloc/address_pool_manager.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_address_space.h" #include "partition_alloc/partition_alloc_base/logging.h" #include "partition_alloc/partition_alloc_base/posix/eintr_wrapper.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.h b/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.h index 76d08f2c6f..30fc61db3d 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.h +++ b/base/allocator/partition_allocator/src/partition_alloc/starscan/write_protector.h @@ -9,7 +9,7 @@ #include <cstdint> #include <mutex> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/internal_allocator_forward.h" #include "partition_alloc/starscan/pcscan.h" #include "partition_alloc/starscan/raceful_worklist.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/tagging.cc b/base/allocator/partition_allocator/src/partition_alloc/tagging.cc index 07a6ad5007..46b4767511 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/tagging.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/tagging.cc @@ -4,7 +4,10 @@ #include "partition_alloc/tagging.h" -#include "build/build_config.h" +#include <stdint.h> + +#include "partition_alloc/aarch64_support.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "partition_alloc/partition_alloc_buildflags.h" @@ -51,31 +54,47 @@ #endif // BUILDFLAG(IS_ANDROID) namespace partition_alloc { +void ChangeMemoryTaggingModeForCurrentThreadNoOp(TagViolationReportingMode m) {} #if BUILDFLAG(HAS_MEMORY_TAGGING) -namespace { -void ChangeMemoryTaggingModeInternal(unsigned prctl_mask) { - if (internal::base::CPU::GetInstanceNoAllocation().has_mte()) { - int status = prctl(PR_SET_TAGGED_ADDR_CTRL, prctl_mask, 0, 0, 0); +using ChangeMemoryTaggingModeForCurrentThreadInternalFn = + void(TagViolationReportingMode); + +void ChangeMemoryTaggingModeForCurrentThreadForMte( + TagViolationReportingMode m) { + const auto change_memory_tagging_mode = [](unsigned long prctl_mask) { + const int status = prctl(PR_SET_TAGGED_ADDR_CTRL, prctl_mask, 0, 0, 0); PA_CHECK(status == 0); - } -} -} // namespace -#endif // BUILDFLAG(HAS_MEMORY_TAGGING) + }; -void ChangeMemoryTaggingModeForCurrentThread(TagViolationReportingMode m) { -#if BUILDFLAG(HAS_MEMORY_TAGGING) if (m == TagViolationReportingMode::kSynchronous) { - ChangeMemoryTaggingModeInternal(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | - (0xfffe << PR_MTE_TAG_SHIFT)); + change_memory_tagging_mode(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | + (0xfffe << PR_MTE_TAG_SHIFT)); } else if (m == TagViolationReportingMode::kAsynchronous) { - ChangeMemoryTaggingModeInternal(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC | - (0xfffe << PR_MTE_TAG_SHIFT)); + change_memory_tagging_mode(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_ASYNC | + (0xfffe << PR_MTE_TAG_SHIFT)); } else { - ChangeMemoryTaggingModeInternal(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_NONE); + change_memory_tagging_mode(PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_NONE); } +} + +extern "C" ChangeMemoryTaggingModeForCurrentThreadInternalFn* +ResolveChangeMemoryTaggingModeForCurrentThread(uint64_t hwcap, + struct __ifunc_arg_t* hw) { + return internal::IsMteEnabled(hwcap, hw) + ? &ChangeMemoryTaggingModeForCurrentThreadForMte + : &ChangeMemoryTaggingModeForCurrentThreadNoOp; +} #endif // BUILDFLAG(HAS_MEMORY_TAGGING) + +void ChangeMemoryTaggingModeForCurrentThread(TagViolationReportingMode m) +#if BUILDFLAG(HAS_MEMORY_TAGGING) + __attribute__((ifunc("ResolveChangeMemoryTaggingModeForCurrentThread"))); +#else +{ + ChangeMemoryTaggingModeForCurrentThreadNoOp(m); } +#endif namespace internal { @@ -192,30 +211,31 @@ void* RemaskVoidPtrNoOp(void* ptr) { #if BUILDFLAG(HAS_MEMORY_TAGGING) using RemaskPtrInternalFn = void*(void* ptr); using TagMemoryRangeIncrementInternalFn = void*(void* ptr, size_t size); - using TagMemoryRangeRandomlyInternalFn = void*(void* ptr, size_t size, uint64_t mask); -extern "C" TagMemoryRangeIncrementInternalFn( - *ResolveTagMemoryRangeIncrement(uint64_t hwcap, struct __ifunc_arg_t* hw)) { - if ((hwcap & _IFUNC_ARG_HWCAP) && (hw->_hwcap2 & HWCAP2_MTE)) { +extern "C" TagMemoryRangeIncrementInternalFn* ResolveTagMemoryRangeIncrement( + uint64_t hwcap, + struct __ifunc_arg_t* hw) { + if (IsMteEnabled(hwcap, hw)) { return TagRegionIncrementForMTE; } return TagRegionIncrementNoOp; } -extern "C" TagMemoryRangeRandomlyInternalFn( - *ResolveTagMemoryRandomly(uint64_t hwcap, struct __ifunc_arg_t* hw)) { - if ((hwcap & _IFUNC_ARG_HWCAP) && (hw->_hwcap2 & HWCAP2_MTE)) { +extern "C" TagMemoryRangeRandomlyInternalFn* ResolveTagMemoryRandomly( + uint64_t hwcap, + struct __ifunc_arg_t* hw) { + if (IsMteEnabled(hwcap, hw)) { return TagRegionRandomlyForMTE; } return TagRegionRandomlyNoOp; } -extern "C" RemaskPtrInternalFn( - *ResolveRemaskPointer(uint64_t hwcap, struct __ifunc_arg_t* hw)) { - if ((hwcap & _IFUNC_ARG_HWCAP) && (hw->_hwcap2 & HWCAP2_MTE)) { +extern "C" RemaskPtrInternalFn* ResolveRemaskPointer(uint64_t hwcap, + struct __ifunc_arg_t* hw) { + if (IsMteEnabled(hwcap, hw)) { return RemaskVoidPtrForMTE; } return RemaskVoidPtrNoOp; @@ -229,13 +249,16 @@ void* RemaskPointerInternal(void* ptr) __attribute__((ifunc("ResolveRemaskPointer"))); #endif // BUILDFLAG(HAS_MEMORY_TAGGING) -TagViolationReportingMode GetMemoryTaggingModeForCurrentThread() { +TagViolationReportingMode GetMemoryTaggingModeForCurrentThreadNoMte() { + return TagViolationReportingMode::kUndefined; +} + #if BUILDFLAG(HAS_MEMORY_TAGGING) - base::CPU cpu; - if (!cpu.has_mte()) { - return TagViolationReportingMode::kUndefined; - } - int status = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0); +using GetMemoryTaggingModeForCurrentThreadInternalFn = + TagViolationReportingMode(); + +TagViolationReportingMode GetMemoryTaggingModeForCurrentThreadMte() { + const int status = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0); PA_CHECK(status >= 0); // Check for Asynchronous first because ASYNC on Android sets both // PR_MTE_TCF_ASYNC and PR_MTE_TCF_SYNC bits. @@ -246,10 +269,24 @@ TagViolationReportingMode GetMemoryTaggingModeForCurrentThread() { return TagViolationReportingMode::kSynchronous; } return TagViolationReportingMode::kDisabled; -#else - return TagViolationReportingMode::kUndefined; +} + +extern "C" GetMemoryTaggingModeForCurrentThreadInternalFn* +ResolveGetMemoryTaggingModeForCurrentThread(uint64_t hwcap, + struct __ifunc_arg_t* hw) { + return IsMteEnabled(hwcap, hw) ? &GetMemoryTaggingModeForCurrentThreadMte + : &GetMemoryTaggingModeForCurrentThreadNoMte; +} #endif // BUILDFLAG(HAS_MEMORY_TAGGING) + +TagViolationReportingMode GetMemoryTaggingModeForCurrentThread() +#if BUILDFLAG(HAS_MEMORY_TAGGING) + __attribute__((ifunc("ResolveGetMemoryTaggingModeForCurrentThread"))); +#else +{ + return GetMemoryTaggingModeForCurrentThreadNoMte(); } +#endif } // namespace internal diff --git a/base/allocator/partition_allocator/src/partition_alloc/tagging.h b/base/allocator/partition_allocator/src/partition_alloc/tagging.h index ec4e288755..d01419a8e0 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/tagging.h +++ b/base/allocator/partition_allocator/src/partition_alloc/tagging.h @@ -11,7 +11,7 @@ #include <cstddef> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" #include "partition_alloc/partition_alloc_base/component_export.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/tagging_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/tagging_unittest.cc index 75c22724aa..fed08ccb37 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/tagging_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/tagging_unittest.cc @@ -6,7 +6,7 @@ #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/page_allocator.h" #include "partition_alloc/partition_alloc_base/cpu.h" #include "partition_alloc/partition_alloc_buildflags.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/thread_cache.cc b/base/allocator/partition_allocator/src/partition_alloc/thread_cache.cc index e787b32db0..c99e448159 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/thread_cache.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/thread_cache.cc @@ -10,7 +10,7 @@ #include <atomic> #include <cstdint> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/internal_allocator.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc_base/component_export.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/thread_cache.h b/base/allocator/partition_allocator/src/partition_alloc/thread_cache.h index cf9e63a013..161f806a3d 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/thread_cache.h +++ b/base/allocator/partition_allocator/src/partition_alloc/thread_cache.h @@ -11,7 +11,7 @@ #include <memory> #include <optional> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/lightweight_quarantine.h" #include "partition_alloc/partition_alloc-inl.h" #include "partition_alloc/partition_alloc_base/compiler_specific.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/thread_cache_unittest.cc b/base/allocator/partition_allocator/src/partition_alloc/thread_cache_unittest.cc index a245485cd4..9b83405912 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/thread_cache_unittest.cc +++ b/base/allocator/partition_allocator/src/partition_alloc/thread_cache_unittest.cc @@ -8,7 +8,7 @@ #include <atomic> #include <vector> -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/extended_api.h" #include "partition_alloc/internal_allocator.h" #include "partition_alloc/partition_address_space.h" diff --git a/base/allocator/partition_allocator/src/partition_alloc/use_death_tests.h b/base/allocator/partition_allocator/src/partition_alloc/use_death_tests.h new file mode 100644 index 0000000000..d79bb24d22 --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/use_death_tests.h @@ -0,0 +1,30 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PARTITION_ALLOC_USE_DEATH_TESTS_H_ +#define PARTITION_ALLOC_USE_DEATH_TESTS_H_ + +// Test-only header. This must be separated from the main body of +// `partition_alloc_config.h` because the preprocessor evaluates it too +// early leaving `GTEST_HAS_DEATH_TEST` undefined. This makes the +// corresponding `PA_CONFIG()` yield the wrong result. + +#include "partition_alloc/build_config.h" + +// An informal CQ survey +// (https://chromium-review.googlesource.com/c/chromium/src/+/5493422/1?tab=checks) +// tells us that iOS doesn't define `GTEST_HAS_DEATH_TEST`. +// +// In addition, Android is generally thought not to support death tests. +// See also: +// * crbug.com/40483507 +// * crbug.com/40785222 +// * crbug.com/41372437 +#if defined(GTEST_HAS_DEATH_TEST) +#define PA_USE_DEATH_TESTS() (!BUILDFLAG(IS_ANDROID)) +#else +#define PA_USE_DEATH_TESTS() 0 +#endif + +#endif // PARTITION_ALLOC_USE_DEATH_TESTS_H_ diff --git a/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py b/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py new file mode 100755 index 0000000000..e6adb7793c --- /dev/null +++ b/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +# Copyright 2024 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# This was copied from chromium's and adapted to partition_alloc. + +# This writes headers for build flags. See buildflag_header.gni for usage of +# this system as a whole. +# +# The parameters are passed in a response file so we don't have to worry +# about command line lengths. The name of the response file is passed on the +# command line. +# +# The format of the response file is: +# [--flags <list of one or more flag values>] +import optparse +import os +import re +import shlex +import sys + +class Options: + def __init__(self, output, rulename, header_guard, flags): + self.output = output + self.rulename = rulename + self.header_guard = header_guard + self.flags = flags + + +def GetOptions(): + parser = optparse.OptionParser() + parser.add_option('--output', help="Output header name inside --gen-dir.") + parser.add_option('--rulename', + help="Helpful name of build rule for including in the " + + "comment at the top of the file.") + parser.add_option('--gen-dir', + help="Path to root of generated file directory tree.") + parser.add_option('--definitions', + help="Name of the response file containing the flags.") + cmdline_options, cmdline_flags = parser.parse_args() + + # Compute a valid C++ header guard by replacing non valid chars with '_', + # upper-casing everything and prepending '_' if first symbol is digit. + header_guard = cmdline_options.output.upper() + if header_guard[0].isdigit(): + header_guard = '_' + header_guard + header_guard = re.sub(r'[^\w]', '_', header_guard) + header_guard += '_' + + # The actual output file is inside the gen dir. + output = os.path.join(cmdline_options.gen_dir, cmdline_options.output) + + # Definition file in GYP is newline separated, in GN they are shell formatted. + # shlex can parse both of these. + with open(cmdline_options.definitions, 'r') as def_file: + defs = shlex.split(def_file.read()) + flags_index = defs.index('--flags') + + # Everything after --flags are flags. true/false are remapped to 1/0, + # everything else is passed through. + flags = [] + for flag in defs[flags_index + 1 :]: + equals_index = flag.index('=') + key = flag[:equals_index] + value = flag[equals_index + 1:] + + # Canonicalize and validate the value. + if value == 'true': + value = '1' + elif value == 'false': + value = '0' + flags.append((key, str(value))) + + return Options(output=output, + rulename=cmdline_options.rulename, + header_guard=header_guard, + flags=flags) + + +def WriteHeader(options): + with open(options.output, 'w') as output_file: + output_file.write("// Generated by partition_alloc/write_buildflag_header.py\n") + if options.rulename: + output_file.write('// From "' + options.rulename + '"\n') + + output_file.write('\n#ifndef %s\n' % options.header_guard) + output_file.write('#define %s\n\n' % options.header_guard) + output_file.write('#include "partition_alloc/buildflag.h" // IWYU pragma: export\n\n') + # TODO(https://crbug.com/41481467) Remove dependency on chromium: + output_file.write('#include "build/buildflag.h" // IWYU pragma: export\n\n') + + for pair in options.flags: + output_file.write('#define PA_BUILDFLAG_INTERNAL_%s() (%s)\n' % pair) + # TODO(https://crbug.com/41481467) Remove dependency on chromium: + output_file.write('#define BUILDFLAG_INTERNAL_%s() (%s)\n' % pair) + + output_file.write('\n#endif // %s\n' % options.header_guard) + + +def main(): + options = GetOptions() + WriteHeader(options) + return 0; + +if __name__ == '__main__': + sys.exit(main()) diff --git a/base/allocator/partition_allocator/src/partition_alloc/yield_processor.h b/base/allocator/partition_allocator/src/partition_alloc/yield_processor.h index a4a62b7bb8..75b0bbbe26 100644 --- a/base/allocator/partition_allocator/src/partition_alloc/yield_processor.h +++ b/base/allocator/partition_allocator/src/partition_alloc/yield_processor.h @@ -5,7 +5,7 @@ #ifndef PARTITION_ALLOC_YIELD_PROCESSOR_H_ #define PARTITION_ALLOC_YIELD_PROCESSOR_H_ -#include "build/build_config.h" +#include "partition_alloc/build_config.h" #include "partition_alloc/partition_alloc_config.h" // The PA_YIELD_PROCESSOR macro wraps an architecture specific-instruction that diff --git a/base/android/java/src/org/chromium/base/cached_flags/CachedFieldTrialParameter.java b/base/android/java/src/org/chromium/base/cached_flags/CachedFieldTrialParameter.java index 0202181dc8..43be3d2587 100644 --- a/base/android/java/src/org/chromium/base/cached_flags/CachedFieldTrialParameter.java +++ b/base/android/java/src/org/chromium/base/cached_flags/CachedFieldTrialParameter.java @@ -14,6 +14,7 @@ import org.chromium.build.annotations.CheckDiscard; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.HashMap; import java.util.HashSet; import java.util.Set; @@ -47,12 +48,23 @@ public abstract class CachedFieldTrialParameter { private final String mFeatureName; private final String mParameterName; private final @FieldTrialParameterType int mType; + private static HashMap<String, CachedFieldTrialParameter> sParamsCreatedForTesting = + new HashMap<>(); CachedFieldTrialParameter( FeatureMap featureMap, String featureName, String parameterName, @FieldTrialParameterType int type) { + if (BuildConfig.IS_FOR_TEST) { + String combinedName = featureName + ":" + parameterName; + CachedFieldTrialParameter previous = sParamsCreatedForTesting.put(combinedName, this); + assert previous == null + : String.format( + "Feature '%s' has a duplicate parameter: '%s'", + featureName, parameterName); + } + mFeatureMap = featureMap; mFeatureName = featureName; // parameterName does not apply to ALL (because it includes all parameters). diff --git a/base/android/proguard/chromium_code.flags b/base/android/proguard/chromium_code.flags index e417fbaaa5..6b164d51da 100644 --- a/base/android/proguard/chromium_code.flags +++ b/base/android/proguard/chromium_code.flags @@ -42,6 +42,9 @@ -keep,allowobfuscation,allowaccessmodification class !cr_allowunused,** extends <1> { <init>(); } +# This is necessary to work around a bug: crbug.com/337905171. +-keep,allowobfuscation,allowshrinking @org.chromium.components.module_installer.builder.ModuleInterface interface !cr_allowunused,* + # Required to remove fields until b/274802355 is resolved. -assumevalues class !cr_allowunused,** { diff --git a/base/containers/contains.h b/base/containers/contains.h index 3ebf061a9d..e3223888e6 100644 --- a/base/containers/contains.h +++ b/base/containers/contains.h @@ -17,59 +17,8 @@ namespace internal { // Small helper to detect whether a given type has a nested `key_type` typedef. // Used below to catch misuses of the API for associative containers. -template <typename T, typename SFINAE = void> -struct HasKeyType : std::false_type {}; - template <typename T> -struct HasKeyType<T, std::void_t<typename T::key_type>> : std::true_type {}; - -// Probe whether a `contains` member function exists and return the result of -// `container.contains(value)` if this is a valid expression. This is the -// highest priority option. -template <typename Container, typename Value> -constexpr auto ContainsImpl(const Container& container, - const Value& value, - priority_tag<2>) - -> decltype(container.contains(value)) { - return container.contains(value); -} - -// Probe whether a `find` member function exists and whether its return value -// can be compared with `container.end()`. Intended for STL style maps and sets -// that lack a `contains` member function. -template <typename Container, typename Value> -constexpr auto ContainsImpl(const Container& container, - const Value& value, - priority_tag<1>) - -> decltype(container.find(value) != container.end()) { - return container.find(value) != container.end(); -} - -// Probe whether a `find` member function exists and whether its return value -// can be compared with `Container::npos`. Intended for STL style strings that -// lack a `contains` member function. -template <typename Container, typename Value> -constexpr auto ContainsImpl(const Container& container, - const Value& value, - priority_tag<1>) - -> decltype(container.find(value) != Container::npos) { - return container.find(value) != Container::npos; -} - -// Generic fallback option, using a linear search over `container` to find -// `value`. Has the lowest priority. This will not compile for associative -// containers, as this likely is a performance bug. -template <typename Container, typename Value> -constexpr bool ContainsImpl(const Container& container, - const Value& value, - priority_tag<0>) { - static_assert( - !HasKeyType<Container>::value, - "Error: About to perform linear search on an associative container. " - "Either use a more generic comparator (e.g. std::less<>) or, if a linear " - "search is desired, provide an explicit projection parameter."); - return ranges::find(container, value) != ranges::end(container); -} +concept HasKeyType = requires { typename T::key_type; }; } // namespace internal @@ -78,7 +27,22 @@ constexpr bool ContainsImpl(const Container& container, // exists, and fall back to a generic linear search over `container`. template <typename Container, typename Value> constexpr bool Contains(const Container& container, const Value& value) { - return internal::ContainsImpl(container, value, internal::priority_tag<2>()); + if constexpr (requires { + { container.contains(value) } -> std::same_as<bool>; + }) { + return container.contains(value); + } else if constexpr (requires { container.find(value) != Container::npos; }) { + return container.find(value) != Container::npos; + } else if constexpr (requires { container.find(value) != container.end(); }) { + return container.find(value) != container.end(); + } else { + static_assert( + !internal::HasKeyType<Container>, + "Error: About to perform linear search on an associative container. " + "Either use a more generic comparator (e.g. std::less<>) or, if a " + "linear search is desired, provide an explicit projection parameter."); + return ranges::find(container, value) != ranges::end(container); + } } // Overload that allows to provide an additional projection invocable. This diff --git a/base/cpu.h b/base/cpu.h index 20589f3827..565e34420c 100644 --- a/base/cpu.h +++ b/base/cpu.h @@ -65,6 +65,7 @@ class BASE_EXPORT CPU final { }; // Accessors for CPU information. + // TODO(crbug.com/335001230): Most if not all of these should be x86-only. std::string vendor_name() const { return cpu_vendor_; } int signature() const { return signature_; } int stepping() const { return stepping_; } @@ -73,6 +74,7 @@ class BASE_EXPORT CPU final { int type() const { return type_; } int extended_model() const { return ext_model_; } int extended_family() const { return ext_family_; } +#if defined(ARCH_CPU_X86_FAMILY) bool has_mmx() const { return has_mmx_; } bool has_sse() const { return has_sse_; } bool has_sse2() const { return has_sse2_; } @@ -84,6 +86,7 @@ class BASE_EXPORT CPU final { bool has_avx() const { return has_avx_; } bool has_fma3() const { return has_fma3_; } bool has_avx2() const { return has_avx2_; } +#endif bool has_aesni() const { return has_aesni_; } bool has_non_stop_time_stamp_counter() const { return has_non_stop_time_stamp_counter_; @@ -136,6 +139,7 @@ class BASE_EXPORT CPU final { uint32_t part_number_ = 0; // ARM MIDR part number uint8_t implementer_ = 0; // ARM MIDR implementer identifier #endif +#if defined(ARCH_CPU_X86_FAMILY) bool has_mmx_ = false; bool has_sse_ = false; bool has_sse2_ = false; @@ -147,6 +151,7 @@ class BASE_EXPORT CPU final { bool has_avx_ = false; bool has_fma3_ = false; bool has_avx2_ = false; +#endif bool has_aesni_ = false; #if defined(ARCH_CPU_ARM_FAMILY) bool has_mte_ = false; // Armv8.5-A MTE (Memory Taggging Extension) diff --git a/base/debug/allocation_trace_unittest.cc b/base/debug/allocation_trace_unittest.cc index 485edca812..b7fbfc01ea 100644 --- a/base/debug/allocation_trace_unittest.cc +++ b/base/debug/allocation_trace_unittest.cc @@ -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 ; diff --git a/base/debug/stack_trace_unittest.cc b/base/debug/stack_trace_unittest.cc index e54452fe0d..dd43d88e80 100644 --- a/base/debug/stack_trace_unittest.cc +++ b/base/debug/stack_trace_unittest.cc @@ -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 { diff --git a/base/feature_list.cc b/base/feature_list.cc index c70aa776b1..c2ae37433f 100644 --- a/base/feature_list.cc +++ b/base/feature_list.cc @@ -204,7 +204,7 @@ bool SplitIntoTwo(std::string_view text, *second = std::string(parts[1]); } else if (parts.size() > 2) { DLOG(ERROR) << "Only one '" << separator - << "' is allowed but got: " << *first; + << "' is allowed but got: " << text; return false; } *first = parts[0]; diff --git a/base/functional/bind_internal.h b/base/functional/bind_internal.h index dc5fee6d64..bf64a8d29a 100644 --- a/base/functional/bind_internal.h +++ b/base/functional/bind_internal.h @@ -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 = diff --git a/base/functional/bind_unittest.cc b/base/functional/bind_unittest.cc index 6f54d75ca3..13a8e6b2b7 100644 --- a/base/functional/bind_unittest.cc +++ b/base/functional/bind_unittest.cc @@ -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 diff --git a/base/memory/nonscannable_memory.cc b/base/memory/nonscannable_memory.cc index 5a0c3ed6b1..5fc81e6d76 100644 --- a/base/memory/nonscannable_memory.cc +++ b/base/memory/nonscannable_memory.cc @@ -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); diff --git a/base/memory/raw_ptr_asan_bound_arg_tracker.cc b/base/memory/raw_ptr_asan_bound_arg_tracker.cc index 3b149715ce..6dceff4b17 100644 --- a/base/memory/raw_ptr_asan_bound_arg_tracker.cc +++ b/base/memory/raw_ptr_asan_bound_arg_tracker.cc @@ -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) diff --git a/base/memory/raw_ptr_asan_bound_arg_tracker.h b/base/memory/raw_ptr_asan_bound_arg_tracker.h index 5d720e576d..17c8aaf207 100644 --- a/base/memory/raw_ptr_asan_bound_arg_tracker.h +++ b/base/memory/raw_ptr_asan_bound_arg_tracker.h @@ -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_ diff --git a/base/memory/raw_ptr_asan_hooks.cc b/base/memory/raw_ptr_asan_hooks.cc index 4cda382148..06c717834b 100644 --- a/base/memory/raw_ptr_asan_hooks.cc +++ b/base/memory/raw_ptr_asan_hooks.cc @@ -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) diff --git a/base/memory/raw_ptr_asan_hooks.h b/base/memory/raw_ptr_asan_hooks.h index 6e1e31bd36..052c1f7374 100644 --- a/base/memory/raw_ptr_asan_hooks.h +++ b/base/memory/raw_ptr_asan_hooks.h @@ -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_ diff --git a/base/memory/raw_ptr_asan_service.cc b/base/memory/raw_ptr_asan_service.cc index 351e081da0..c50deae131 100644 --- a/base/memory/raw_ptr_asan_service.cc +++ b/base/memory/raw_ptr_asan_service.cc @@ -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) diff --git a/base/memory/raw_ptr_asan_service.h b/base/memory/raw_ptr_asan_service.h index 3e4eaa828d..224c877eca 100644 --- a/base/memory/raw_ptr_asan_service.h +++ b/base/memory/raw_ptr_asan_service.h @@ -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_ diff --git a/base/memory/raw_ptr_asan_unittest.cc b/base/memory/raw_ptr_asan_unittest.cc index c8658afb1c..58c58b94f5 100644 --- a/base/memory/raw_ptr_asan_unittest.cc +++ b/base/memory/raw_ptr_asan_unittest.cc @@ -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) diff --git a/base/memory/safety_checks.h b/base/memory/safety_checks.h index fd84b71413..136acdd411 100644 --- a/base/memory/safety_checks.h +++ b/base/memory/safety_checks.h @@ -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); } diff --git a/base/memory/safety_checks_unittest.cc b/base/memory/safety_checks_unittest.cc index d9d0588ae4..f972caf52d 100644 --- a/base/memory/safety_checks_unittest.cc +++ b/base/memory/safety_checks_unittest.cc @@ -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 diff --git a/base/process/internal_linux.cc b/base/process/internal_linux.cc index f818141995..a0af093749 100644 --- a/base/process/internal_linux.cc +++ b/base/process/internal_linux.cc @@ -82,7 +82,6 @@ bool ReadProcFile(const FilePath& file, std::string* buffer) { ScopedAllowBlocking scoped_allow_blocking; if (!ReadFileToString(file, buffer)) { - DLOG(WARNING) << "Failed to read " << file.MaybeAsASCII(); return false; } return !buffer->empty(); diff --git a/base/process/memory.cc b/base/process/memory.cc index a5b8f9710d..e0c256137b 100644 --- a/base/process/memory.cc +++ b/base/process/memory.cc @@ -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; diff --git a/base/process/memory_linux.cc b/base/process/memory_linux.cc index d712594363..9399786288 100644 --- a/base/process/memory_linux.cc +++ b/base/process/memory_linux.cc @@ -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); diff --git a/base/process/memory_unittest.cc b/base/process/memory_unittest.cc index 1dd8e4afda..9bf1708d8f 100644 --- a/base/process/memory_unittest.cc +++ b/base/process/memory_unittest.cc @@ -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) diff --git a/base/ranges/algorithm.h b/base/ranges/algorithm.h index 4e0b96b341..0c3515f8f2 100644 --- a/base/ranges/algorithm.h +++ b/base/ranges/algorithm.h @@ -38,6 +38,25 @@ constexpr auto ProjectedUnaryPredicate(Pred& pred, Proj& proj) noexcept { }; } +// Helper concept that is true if the binary predicate can be invoked on the +// result of projecting T and projecting U. See `BinaryPredicateProjector` for +// additional background. +template <typename BinaryPred, + typename ProjT, + typename ProjU, + typename T, + typename U> +concept BinaryPredicateProjectorIsInvokable = requires(BinaryPred& predicate, + ProjT& project_t, + ProjU& project_u, + T&& t, + U&& u) { + { + std::invoke(predicate, std::invoke(project_t, std::forward<T>(t)), + std::invoke(project_u, std::forward<U>(u))) + } -> std::same_as<bool>; +}; + // Returns a transformed version of the binary predicate `pred` applying `proj1` // and `proj2` to its arguments before invoking `pred` on them. // @@ -67,47 +86,30 @@ class BinaryPredicateProjector { : pred_(pred), proj1_(proj1), proj2_(proj2) {} private: - template <typename ProjT, typename ProjU, typename T, typename U> - using InvokeResult = std::invoke_result_t<Pred&, - std::invoke_result_t<ProjT&, T&&>, - std::invoke_result_t<ProjU&, U&&>>; - - template <typename T, typename U, typename = InvokeResult<Proj1, Proj2, T, U>> - constexpr std::pair<Proj1&, Proj2&> GetProjs(priority_tag<3>) const { - return {proj1_, proj2_}; - } - - template <typename T, - typename U, - bool LazyPermute = kPermute, - typename = std::enable_if_t<LazyPermute>, - typename = InvokeResult<Proj2, Proj1, T, U>> - constexpr std::pair<Proj2&, Proj1&> GetProjs(priority_tag<2>) const { - return {proj2_, proj1_}; - } - - template <typename T, - typename U, - bool LazyPermute = kPermute, - typename = std::enable_if_t<LazyPermute>, - typename = InvokeResult<Proj1, Proj1, T, U>> - constexpr std::pair<Proj1&, Proj1&> GetProjs(priority_tag<1>) const { - return {proj1_, proj1_}; - } - - template <typename T, - typename U, - bool LazyPermute = kPermute, - typename = std::enable_if_t<LazyPermute>, - typename = InvokeResult<Proj2, Proj2, T, U>> - constexpr std::pair<Proj2&, Proj2&> GetProjs(priority_tag<0>) const { - return {proj2_, proj2_}; + template <typename T, typename U> + constexpr auto GetProjs() const { + if constexpr (BinaryPredicateProjectorIsInvokable<Pred, Proj1, Proj2, T, + U>) { + return std::pair<Proj1&, Proj2&>(proj1_, proj2_); + } else if constexpr (kPermute && + BinaryPredicateProjectorIsInvokable<Pred, Proj2, Proj1, + T, U>) { + return std::pair<Proj2&, Proj1&>(proj2_, proj1_); + } else if constexpr (kPermute && + BinaryPredicateProjectorIsInvokable<Pred, Proj1, Proj1, + T, U>) { + return std::pair<Proj1&, Proj1&>(proj1_, proj1_); + } else if constexpr (kPermute && + BinaryPredicateProjectorIsInvokable<Pred, Proj2, Proj2, + T, U>) { + return std::pair<Proj2&, Proj2&>(proj2_, proj2_); + } } public: template <typename T, typename U> constexpr bool operator()(T&& lhs, U&& rhs) const { - auto projs = GetProjs<T, U>(priority_tag<3>()); + auto projs = GetProjs<T, U>(); return std::invoke(pred_, std::invoke(projs.first, std::forward<T>(lhs)), std::invoke(projs.second, std::forward<U>(rhs))); } diff --git a/base/security_unittest.cc b/base/security_unittest.cc index 4fce7f059f..1f81190042 100644 --- a/base/security_unittest.cc +++ b/base/security_unittest.cc @@ -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 diff --git a/base/task/thread_pool/worker_thread.cc b/base/task/thread_pool/worker_thread.cc index d58885c012..b1a45ff123 100644 --- a/base/task/thread_pool/worker_thread.cc +++ b/base/task/thread_pool/worker_thread.cc @@ -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, diff --git a/base/task/thread_pool/worker_thread.h b/base/task/thread_pool/worker_thread.h index 93233e25f7..7a8a829d79 100644 --- a/base/task/thread_pool/worker_thread.h +++ b/base/task/thread_pool/worker_thread.h @@ -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) }; diff --git a/base/task/thread_pool/worker_thread_waitable_event.cc b/base/task/thread_pool/worker_thread_waitable_event.cc index fd2ca63a46..e96fe13618 100644 --- a/base/task/thread_pool/worker_thread_waitable_event.cc +++ b/base/task/thread_pool/worker_thread_waitable_event.cc @@ -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 diff --git a/base/task/thread_pool/worker_thread_waitable_event_unittest.cc b/base/task/thread_pool/worker_thread_waitable_event_unittest.cc index bcf45b007e..3eb9a18157 100644 --- a/base/task/thread_pool/worker_thread_waitable_event_unittest.cc +++ b/base/task/thread_pool/worker_thread_waitable_event_unittest.cc @@ -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 diff --git a/base/test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java b/base/test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java index 1fcbbe0677..87c463a5e3 100644 --- a/base/test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java +++ b/base/test/android/javatests/src/org/chromium/base/test/BaseChromiumAndroidJUnitRunner.java @@ -39,6 +39,7 @@ import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.InMemorySharedPreferencesContext; import org.chromium.base.test.util.MinAndroidSdkLevel; +import org.chromium.base.test.util.ScalableTimeout; import org.chromium.build.BuildConfig; import org.chromium.testing.TestListInstrumentationRunListener; @@ -67,6 +68,7 @@ public class BaseChromiumAndroidJUnitRunner extends AndroidJUnitRunner { private static final String IS_UNIT_TEST_FLAG = "BaseChromiumAndroidJUnitRunner.IsUnitTest"; private static final String EXTRA_CLANG_COVERAGE_DEVICE_FILE = "BaseChromiumAndroidJUnitRunner.ClangCoverageDeviceFile"; + private static final String EXTRA_TIMEOUT_SCALE = "BaseChromiumAndroidJUnitRunner.TimeoutScale"; private static final String EXTRA_TRACE_FILE = "BaseChromiumAndroidJUnitRunner.TraceFile"; private static final String ARGUMENT_LOG_ONLY = "log"; @@ -149,6 +151,10 @@ public class BaseChromiumAndroidJUnitRunner extends AndroidJUnitRunner { @Override public void onStart() { Bundle arguments = InstrumentationRegistry.getArguments(); + String timeoutScale = arguments.getString(EXTRA_TIMEOUT_SCALE); + if (timeoutScale != null) { + ScalableTimeout.setScale(Float.valueOf(timeoutScale)); + } if (sTestListMode) { Log.w( TAG, diff --git a/base/test/android/javatests/src/org/chromium/base/test/transit/Elements.java b/base/test/android/javatests/src/org/chromium/base/test/transit/Elements.java index 3286462525..d5436ce004 100644 --- a/base/test/android/javatests/src/org/chromium/base/test/transit/Elements.java +++ b/base/test/android/javatests/src/org/chromium/base/test/transit/Elements.java @@ -4,6 +4,12 @@ package org.chromium.base.test.transit; +import android.view.View; + +import org.hamcrest.Matcher; + +import org.chromium.base.test.transit.ViewConditions.NotDisplayedAnymoreCondition; + import java.util.ArrayList; import java.util.List; @@ -76,6 +82,11 @@ public class Elements { return inState; } + /** Declare as a Condition that a View is not displayed. */ + public void declareNoView(Matcher<View> viewMatcher) { + mElements.mOtherEnterConditions.add(new NotDisplayedAnymoreCondition(viewMatcher)); + } + /** * Declare as an element a logical check that must return true when and as long as the * Station is ACTIVE. diff --git a/base/test/android/javatests/src/org/chromium/base/test/transit/ItemOnScreenFacility.java b/base/test/android/javatests/src/org/chromium/base/test/transit/ItemOnScreenFacility.java new file mode 100644 index 0000000000..0f4adc9af1 --- /dev/null +++ b/base/test/android/javatests/src/org/chromium/base/test/transit/ItemOnScreenFacility.java @@ -0,0 +1,44 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.test.transit; + +/** + * A facility representing an item inside a {@link ScrollableFacility} shown on the screen. + * + * @param <HostStationT> the type of TransitStation this is scoped to. + * @param <SelectReturnT> the return type of the |selectHandler|. + */ +public class ItemOnScreenFacility<HostStationT extends TransitStation, SelectReturnT> + extends StationFacility<HostStationT> { + + protected final ScrollableFacility<HostStationT>.Item<SelectReturnT> mItem; + + protected ItemOnScreenFacility( + HostStationT station, ScrollableFacility<HostStationT>.Item<SelectReturnT> item) { + super(station); + mItem = item; + } + + @Override + public void declareElements(Elements.Builder elements) { + mItem.declareViewElement(elements); + } + + /** Select the item and trigger its |selectHandler|. */ + public SelectReturnT select() { + if (!mItem.isPresent()) { + throw new IllegalStateException("Cannot click on an absent item"); + } + if (!mItem.isEnabled()) { + throw new IllegalStateException("Cannot click on a disabled item"); + } + + try { + return mItem.getSelectHandler().call(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/base/test/android/javatests/src/org/chromium/base/test/transit/ScrollableFacility.java b/base/test/android/javatests/src/org/chromium/base/test/transit/ScrollableFacility.java new file mode 100644 index 0000000000..7d75112245 --- /dev/null +++ b/base/test/android/javatests/src/org/chromium/base/test/transit/ScrollableFacility.java @@ -0,0 +1,286 @@ +// Copyright 2024 The Chromium Authors +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.chromium.base.test.transit; + +import static androidx.test.espresso.Espresso.onData; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; + +import static org.chromium.base.test.transit.ViewElement.sharedViewElement; + +import android.view.View; + +import androidx.annotation.CallSuper; +import androidx.annotation.Nullable; +import androidx.test.espresso.NoMatchingViewException; +import androidx.test.espresso.action.ViewActions; + +import org.hamcrest.Matcher; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Callable; + +/** + * Represents a facility that contains items which may or may not be visible due to scrolling. + * + * @param <HostStationT> the type of TransitStation this is scoped to. + */ +public abstract class ScrollableFacility<HostStationT extends TransitStation> + extends StationFacility<HostStationT> { + + public ScrollableFacility(HostStationT station) { + super(station); + } + + /** Must populate |items| with the expected items. */ + protected abstract void declareItems(List<Item<?>> items); + + /** Returns the minimum number of items declared expected to be displayed screen initially. */ + protected abstract int getMinimumOnScreenItemCount(); + + /** Create a new item stub which throws UnsupportedOperationException if selected. */ + public Item<Void> newStubItem( + Matcher<View> onScreenViewMatcher, Matcher<?> offScreenDataMatcher) { + return new Item<>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ true, + /* enabled= */ true, + ScrollableFacility::unsupported); + } + + /** Create a new item which runs |selectHandler| when selected. */ + public <SelectReturnT> Item<SelectReturnT> newItem( + Matcher<View> onScreenViewMatcher, + Matcher<?> offScreenDataMatcher, + Callable<SelectReturnT> selectHandler) { + return new Item<>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ true, + /* enabled= */ true, + selectHandler); + } + + /** Create a new item which transitions to a |DestinationStationT| when selected. */ + public <DestinationStationT extends TransitStation> Item<DestinationStationT> newItemToStation( + Matcher<View> onScreenViewMatcher, + Matcher<?> offScreenDataMatcher, + Callable<DestinationStationT> destinationStationFactory) { + var item = + new Item<DestinationStationT>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ true, + /* enabled= */ true, + /* selectHandler= */ null); + item.setSelectHandler(() -> travelToStation(item, destinationStationFactory)); + return item; + } + + /** Create a new item which enters a |EnteredFacilityT| when selected. */ + public <EnteredFacilityT extends StationFacility<HostStationT>> + Item<EnteredFacilityT> newItemToFacility( + Matcher<View> onScreenViewMatcher, + Matcher<?> offScreenDataMatcher, + Callable<EnteredFacilityT> destinationFacilityFactory) { + final var item = + new Item<EnteredFacilityT>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ true, + /* enabled= */ true, + /* selectHandler= */ null); + item.setSelectHandler(() -> enterFacility(item, destinationFacilityFactory)); + return item; + } + + /** Create a new disabled item. */ + public Item<Void> newDisabledItem( + Matcher<View> onScreenViewMatcher, Matcher<?> offScreenDataMatcher) { + return new Item<>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ true, + /* enabled= */ false, + null); + } + + /** Create a new item expected to be absent. */ + public Item<Void> newAbsentItem( + Matcher<View> onScreenViewMatcher, Matcher<?> offScreenDataMatcher) { + return new Item<>( + onScreenViewMatcher, + offScreenDataMatcher, + /* present= */ false, + /* enabled= */ false, + null); + } + + private static Void unsupported() { + // Selected an item created with newStubItem(). + // Use newItemToStation(), newItemToFacility() or newItem() to declare expected behavior + // when this item is selected. + throw new UnsupportedOperationException( + "This item is a stub and has not been bound to a select handler."); + } + + @CallSuper + @Override + public void declareElements(Elements.Builder elements) { + List<Item<?>> items = new ArrayList<>(); + declareItems(items); + + int i = 0; + int itemsToExpect = getMinimumOnScreenItemCount(); + for (Item<?> item : items) { + // Expect only the first |itemsToExpect| items because of scrolling. + // Items that should be absent should be checked regardless of position. + if (!item.isPresent() || i < itemsToExpect) { + item.declareViewElement(elements); + } + + i++; + } + } + + /** + * Represents an item in a specific {@link ScrollableFacility}. + * + * <p>{@link ScrollableFacility} subclasses should use these to represent their items. + * + * @param <SelectReturnT> the return type of the |selectHandler|. + */ + public class Item<SelectReturnT> { + protected final Matcher<View> mOnScreenViewMatcher; + protected final Matcher<?> mOffScreenDataMatcher; + protected final boolean mPresent; + protected final boolean mEnabled; + protected final ViewElement mViewElement; + protected Callable<SelectReturnT> mSelectHandler; + + /** + * Use one of {@link ScrollableFacility}'s factory methods to instantiate: + * + * <ul> + * <li>{@link #newStubItem(Matcher, Matcher)} + * <li>{@link #newItem(Matcher, Matcher, Callable)} + * <li>{@link #newItemToFacility(Matcher, Matcher, Callable)} + * <li>{@link #newItemToStation(Matcher, Matcher, Callable)} + * <li>{@link #newDisabledItem(Matcher, Matcher)} + * <li>{@link #newAbsentItem(Matcher, Matcher)} + * </ul> + */ + protected Item( + Matcher<View> onScreenViewMatcher, + Matcher<?> offScreenDataMatcher, + boolean present, + boolean enabled, + @Nullable Callable<SelectReturnT> selectHandler) { + mPresent = present; + mEnabled = enabled; + mOnScreenViewMatcher = onScreenViewMatcher; + if (mPresent) { + if (mEnabled) { + mViewElement = sharedViewElement(mOnScreenViewMatcher); + } else { + mViewElement = + sharedViewElement( + mOnScreenViewMatcher, + ViewElement.newOptions().expectDisabled().build()); + } + } else { + mViewElement = null; + } + mOffScreenDataMatcher = offScreenDataMatcher; + mSelectHandler = selectHandler; + } + + /** + * Select the item, scrolling to it if necessary. + * + * @return the return value of the |selectHandler|. e.g. a Facility or Station. + */ + public SelectReturnT scrollToAndSelect() { + return scrollTo().select(); + } + + /** + * Scroll to the item if necessary. + * + * @return a ItemScrolledTo facility representing the item on the screen, which runs the + * |selectHandler| when selected. + */ + public ItemOnScreenFacility<HostStationT, SelectReturnT> scrollTo() { + ItemOnScreenFacility<HostStationT, SelectReturnT> focusedItem = + new ItemOnScreenFacility<>(mStation, this); + return StationFacility.enterSync(focusedItem, this::maybeScrollTo); + } + + protected void setSelectHandler(Callable<SelectReturnT> selectHandler) { + assert mSelectHandler == null; + mSelectHandler = selectHandler; + } + + protected void declareViewElement(Elements.Builder elements) { + if (mViewElement != null) { + elements.declareView(mViewElement); + } else { + elements.declareNoView(mOnScreenViewMatcher); + } + } + + protected boolean isPresent() { + return mPresent; + } + + protected boolean isEnabled() { + return mEnabled; + } + + protected ViewElement getViewElement() { + return mViewElement; + } + + protected Callable<SelectReturnT> getSelectHandler() { + return mSelectHandler; + } + + private void maybeScrollTo() { + try { + onView(mOnScreenViewMatcher).check(matches(isDisplayed())); + } catch (AssertionError | NoMatchingViewException e) { + onData(mOffScreenDataMatcher).perform(ViewActions.scrollTo()); + } + } + } + + private <EnteredFacilityT extends StationFacility> EnteredFacilityT enterFacility( + Item<EnteredFacilityT> item, Callable<EnteredFacilityT> mDestinationFactory) { + EnteredFacilityT destination; + try { + destination = mDestinationFactory.call(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return StationFacility.enterSync(destination, () -> item.getViewElement().perform(click())); + } + + private <DestinationStationT extends TransitStation> DestinationStationT travelToStation( + Item<DestinationStationT> item, Callable<DestinationStationT> mDestinationFactory) { + DestinationStationT destination; + try { + destination = mDestinationFactory.call(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + return Trip.travelSync(mStation, destination, () -> item.getViewElement().perform(click())); + } +} diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java b/base/test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java index 94739f5fc1..264b2af629 100644 --- a/base/test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java +++ b/base/test/android/javatests/src/org/chromium/base/test/util/ScalableTimeout.java @@ -6,24 +6,17 @@ package org.chromium.base.test.util; /** * Utility class for scaling various timeouts by a common factor. - * For example, to run tests under slow memory tools, you might do - * something like this: - * adb shell "echo 20.0 > /data/local/tmp/chrome_timeout_scale" + * + * <p>Set this value via command-line. E.g.: out/Debug/bin/run_tests --timeout-scale=3 */ public class ScalableTimeout { - private static Double sTimeoutScale; - public static final String PROPERTY_FILE = "/data/local/tmp/chrome_timeout_scale"; + private static float sTimeoutScale = 1; + + public static void setScale(float value) { + sTimeoutScale = value; + } public static long scaleTimeout(long timeout) { - if (sTimeoutScale == null) { - try { - char[] data = TestFileUtil.readUtf8File(PROPERTY_FILE, 32); - sTimeoutScale = Double.parseDouble(new String(data)); - } catch (Exception e) { - // NumberFormatException, FileNotFoundException, IOException - sTimeoutScale = 1.0; - } - } return (long) (timeout * sTimeoutScale); } } diff --git a/base/test/android/javatests/src/org/chromium/base/test/util/TimeoutScale.java b/base/test/android/javatests/src/org/chromium/base/test/util/TimeoutScale.java deleted file mode 100644 index 60547adcb8..0000000000 --- a/base/test/android/javatests/src/org/chromium/base/test/util/TimeoutScale.java +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2012 The Chromium Authors -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -package org.chromium.base.test.util; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** This annotation can be used to scale a specific test timeout. */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface TimeoutScale { - /** - * @return A number to scale the test timeout. - */ - public int value(); -} diff --git a/base/test/memory/dangling_ptr_instrumentation.cc b/base/test/memory/dangling_ptr_instrumentation.cc index b00decc875..e2d418c3e5 100644 --- a/base/test/memory/dangling_ptr_instrumentation.cc +++ b/base/test/memory/dangling_ptr_instrumentation.cc @@ -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."); diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index b6f7b36391..425158da2b 100644 --- a/base/test/test_suite.cc +++ b/base/test/test_suite.cc @@ -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) diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc index 69c80d8524..c3091909a3 100644 --- a/base/threading/platform_thread_posix.cc +++ b/base/threading/platform_thread_posix.cc @@ -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 diff --git a/base/threading/sequence_local_storage_map_unittest.cc b/base/threading/sequence_local_storage_map_unittest.cc index 1b507cabde..5f4eef87d4 100644 --- a/base/threading/sequence_local_storage_map_unittest.cc +++ b/base/threading/sequence_local_storage_map_unittest.cc @@ -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_; diff --git a/base/trace_event/address_space_dump_provider.cc b/base/trace_event/address_space_dump_provider.cc index ca433276a8..d90d4f8e46 100644 --- a/base/trace_event/address_space_dump_provider.cc +++ b/base/trace_event/address_space_dump_provider.cc @@ -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; } diff --git a/base/trace_event/malloc_dump_provider.cc b/base/trace_event/malloc_dump_provider.cc index 55a654fcdf..0f459f9e29 100644 --- a/base/trace_event/malloc_dump_provider.cc +++ b/base/trace_event/malloc_dump_provider.cc @@ -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 diff --git a/base/trace_event/malloc_dump_provider.h b/base/trace_event/malloc_dump_provider.h index 73b563dd3b..ad5b1b9fc7 100644 --- a/base/trace_event/malloc_dump_provider.h +++ b/base/trace_event/malloc_dump_provider.h @@ -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 diff --git a/base/trace_event/memory_dump_manager.cc b/base/trace_event/memory_dump_manager.cc index deca421afb..28813cd257 100644 --- a/base/trace_event/memory_dump_manager.cc +++ b/base/trace_event/memory_dump_manager.cc @@ -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 diff --git a/base/trace_event/memory_infra_background_allowlist.cc b/base/trace_event/memory_infra_background_allowlist.cc index 389d2f3536..84088f243b 100644 --- a/base/trace_event/memory_infra_background_allowlist.cc +++ b/base/trace_event/memory_infra_background_allowlist.cc @@ -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 diff --git a/base/tracing/protos/chrome_track_event.proto b/base/tracing/protos/chrome_track_event.proto index 0a8842f729..8b766cbc43 100644 --- a/base/tracing/protos/chrome_track_event.proto +++ b/base/tracing/protos/chrome_track_event.proto @@ -39,6 +39,7 @@ message BlinkTaskScope { TASK_SCOPE_SCHEDULER_POST_TASK = 6; TASK_SCOPE_REQUEST_IDLE_CALLBACK = 7; TASK_SCOPE_XML_HTTP_REQUEST = 8; + TASK_SCOPE_SOFT_NAVIGATION = 9; } optional TaskScopeType type = 1; optional int64 scope_task_id = 2; diff --git a/build/android/pylib/valgrind_tools.py b/build/android/pylib/valgrind_tools.py deleted file mode 100644 index 8c00705b72..0000000000 --- a/build/android/pylib/valgrind_tools.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright 2012 The Chromium Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# pylint: disable=R0201 - - - - -import logging -import sys - -from devil.android import device_errors -from devil.android.valgrind_tools import base_tool - - -def SetChromeTimeoutScale(device, scale): - """Sets the timeout scale in /data/local/tmp/chrome_timeout_scale to scale.""" - path = '/data/local/tmp/chrome_timeout_scale' - if not scale or scale == 1.0: - # Delete if scale is None/0.0/1.0 since the default timeout scale is 1.0 - device.RemovePath(path, force=True, as_root=True) - else: - device.WriteFile(path, '%f' % scale, as_root=True) - - - -class AddressSanitizerTool(base_tool.BaseTool): - """AddressSanitizer tool.""" - - WRAPPER_NAME = '/system/bin/asanwrapper' - # Disable memcmp overlap check.There are blobs (gl drivers) - # on some android devices that use memcmp on overlapping regions, - # nothing we can do about that. - EXTRA_OPTIONS = 'strict_memcmp=0,use_sigaltstack=1' - - def __init__(self, device): - super().__init__() - self._device = device - - @classmethod - def CopyFiles(cls, device): - """Copies ASan tools to the device.""" - del device - - def GetTestWrapper(self): - return AddressSanitizerTool.WRAPPER_NAME - - def GetUtilWrapper(self): - """Returns the wrapper for utilities, such as forwarder. - - AddressSanitizer wrapper must be added to all instrumented binaries, - including forwarder and the like. This can be removed if such binaries - were built without instrumentation. """ - return self.GetTestWrapper() - - def SetupEnvironment(self): - try: - self._device.EnableRoot() - except device_errors.CommandFailedError as e: - # Try to set the timeout scale anyway. - # TODO(jbudorick) Handle this exception appropriately after interface - # conversions are finished. - logging.error(str(e)) - SetChromeTimeoutScale(self._device, self.GetTimeoutScale()) - - def CleanUpEnvironment(self): - SetChromeTimeoutScale(self._device, None) - - def GetTimeoutScale(self): - # Very slow startup. - return 20.0 - - -TOOL_REGISTRY = { - 'asan': AddressSanitizerTool, -} - - -def CreateTool(tool_name, device): - """Creates a tool with the specified tool name. - - Args: - tool_name: Name of the tool to create. - device: A DeviceUtils instance. - Returns: - A tool for the specified tool_name. - """ - if not tool_name: - return base_tool.BaseTool() - - ctor = TOOL_REGISTRY.get(tool_name) - if ctor: - return ctor(device) - print('Unknown tool %s, available tools: %s' % - (tool_name, ', '.join(sorted(TOOL_REGISTRY.keys())))) - sys.exit(1) - - -def PushFilesForTool(tool_name, device): - """Pushes the files required for |tool_name| to |device|. - - Args: - tool_name: Name of the tool to create. - device: A DeviceUtils instance. - """ - if not tool_name: - return - - clazz = TOOL_REGISTRY.get(tool_name) - if clazz: - clazz.CopyFiles(device) - else: - print('Unknown tool %s, available tools: %s' % (tool_name, ', '.join( - sorted(TOOL_REGISTRY.keys())))) - sys.exit(1) diff --git a/components/policy/core/common/generate_policy_source_unittest.cc b/components/policy/core/common/generate_policy_source_unittest.cc index 0f7be8a9b2..3e39bb4ca6 100644 --- a/components/policy/core/common/generate_policy_source_unittest.cc +++ b/components/policy/core/common/generate_policy_source_unittest.cc @@ -180,6 +180,29 @@ TEST(GeneratePolicySource, ChromeSchemaData) { #endif } +TEST(GeneratePolicySource, PolicyScope) { + const PolicyDetails* details; +#if !BUILDFLAG(IS_IOS) + details = GetChromePolicyDetails(key::kCloudProfileReportingEnabled); + ASSERT_TRUE(details); + EXPECT_EQ(kSingleProfile, details->scope); +#endif + + details = GetChromePolicyDetails(key::kDefaultSearchProviderEnabled); + ASSERT_TRUE(details); + EXPECT_EQ(kProfile, details->scope); + + details = GetChromePolicyDetails(key::kCloudReportingEnabled); + ASSERT_TRUE(details); + EXPECT_EQ(kBrowser, details->scope); + +#if BUILDFLAG(IS_CHROMEOS_ASH) + details = GetChromePolicyDetails(key::kDeviceGuestModeEnabled); + ASSERT_TRUE(details); + EXPECT_EQ(kDevice, details->scope); +#endif +} + TEST(GeneratePolicySource, PolicyDetails) { EXPECT_FALSE(GetChromePolicyDetails("")); EXPECT_FALSE(GetChromePolicyDetails("no such policy")); @@ -191,7 +214,7 @@ TEST(GeneratePolicySource, PolicyDetails) { GetChromePolicyDetails(key::kSearchSuggestEnabled); ASSERT_TRUE(details); EXPECT_FALSE(details->is_deprecated); - EXPECT_FALSE(details->is_device_policy); + EXPECT_EQ(kProfile, details->scope); EXPECT_EQ(6, details->id); EXPECT_EQ(0u, details->max_external_data_size); @@ -199,7 +222,7 @@ TEST(GeneratePolicySource, PolicyDetails) { details = GetChromePolicyDetails(key::kJavascriptEnabled); ASSERT_TRUE(details); EXPECT_TRUE(details->is_deprecated); - EXPECT_FALSE(details->is_device_policy); + EXPECT_EQ(kProfile, details->scope); EXPECT_EQ(9, details->id); EXPECT_EQ(0u, details->max_external_data_size); #endif @@ -208,7 +231,7 @@ TEST(GeneratePolicySource, PolicyDetails) { details = GetChromePolicyDetails(key::kDevicePolicyRefreshRate); ASSERT_TRUE(details); EXPECT_FALSE(details->is_deprecated); - EXPECT_TRUE(details->is_device_policy); + EXPECT_EQ(kDevice, details->scope); EXPECT_EQ(90, details->id); EXPECT_EQ(0u, details->max_external_data_size); @@ -217,7 +240,7 @@ TEST(GeneratePolicySource, PolicyDetails) { details = GetChromePolicyDetails(key::kWallpaperImage); ASSERT_TRUE(details); EXPECT_FALSE(details->is_deprecated); - EXPECT_FALSE(details->is_device_policy); + EXPECT_EQ(kProfile, details->scope); EXPECT_EQ(262, details->id); EXPECT_GT(details->max_external_data_size, 0u); #endif diff --git a/components/policy/core/common/policy_details.h b/components/policy/core/common/policy_details.h index df85ed8c15..cea3d64ddb 100644 --- a/components/policy/core/common/policy_details.h +++ b/components/policy/core/common/policy_details.h @@ -15,6 +15,19 @@ namespace policy { +// An enum defines what the policy can control, generated based on policy +// templates. +// Note that `kProfile` policy may be set to control all profiles simultaneously +// while `kSingleProfile` policy can only control one profile at a time. +enum Scope { + kDevice, // Policy controls Chrome OS device behavior, like wifi setup. + kBrowser, // Policy controls browser behavior, like guest profile setting. + kProfile, // Policy controls one or multiple profiles behavior, like homepage + // url. + kSingleProfile, // Policy controls only one profile behavior, like the + // profile label. +}; + // Contains read-only metadata about a Chrome policy. struct POLICY_EXPORT PolicyDetails { // True if this policy has been deprecated. @@ -23,8 +36,8 @@ struct POLICY_EXPORT PolicyDetails { // True if the policy hasn't been released yet. bool is_future : 1; - // True if this policy is a Chrome OS device policy. - bool is_device_policy : 1; + // The scope of the policy. + Scope scope; // The id of the protobuf field that contains this policy, // in the cloud policy protobuf. diff --git a/components/policy/core/common/policy_map_unittest.cc b/components/policy/core/common/policy_map_unittest.cc index 6dde0c7546..6f771964e3 100644 --- a/components/policy/core/common/policy_map_unittest.cc +++ b/components/policy/core/common/policy_map_unittest.cc @@ -89,8 +89,8 @@ class PolicyMapTest : public PolicyMapTestBase, public testing::Test { return &nonExternalDetails_; } - PolicyDetails externalDetails_ = {false, false, false, 0, 10, {}}; - PolicyDetails nonExternalDetails_ = {false, false, false, 0, 0, {}}; + PolicyDetails externalDetails_ = {false, false, kProfile, 0, 10, {}}; + PolicyDetails nonExternalDetails_ = {false, false, kProfile, 0, 0, {}}; }; TEST_F(PolicyMapTest, SetAndGet) { diff --git a/components/policy/core/common/policy_statistics_collector_unittest.cc b/components/policy/core/common/policy_statistics_collector_unittest.cc index e3db4d83f0..53827a4033 100644 --- a/components/policy/core/common/policy_statistics_collector_unittest.cc +++ b/components/policy/core/common/policy_statistics_collector_unittest.cc @@ -63,12 +63,12 @@ const char kTestChromeSchema[] = R"( const PolicyDetails kTestPolicyDetails[] = { // is_deprecated is_future is_device_policy id max_external_data_size - {false, false, false, kTestPolicy1Id, 0}, - {false, false, false, kTestPolicy2Id, 0}, - {false, false, false, kTestPolicy3Id, 0}, - {false, false, false, kEnrollmentTokenPolicyId, 0}, - {false, false, false, kEnrollmentOptionPolicyId, 0}, - {false, false, false, kBrowserSigninPolicyId, 0}, + {false, false, kProfile, kTestPolicy1Id, 0}, + {false, false, kProfile, kTestPolicy2Id, 0}, + {false, false, kProfile, kTestPolicy3Id, 0}, + {false, false, kProfile, kEnrollmentTokenPolicyId, 0}, + {false, false, kProfile, kEnrollmentOptionPolicyId, 0}, + {false, false, kProfile, kBrowserSigninPolicyId, 0}, }; } // namespace diff --git a/libchrome_tools/patches/long-term-2300-Fix-partition_alloc-buildflag-generation-logic.patch b/libchrome_tools/patches/long-term-2300-Fix-partition_alloc-buildflag-generation-logic.patch new file mode 100644 index 0000000000..6c10e05753 --- /dev/null +++ b/libchrome_tools/patches/long-term-2300-Fix-partition_alloc-buildflag-generation-logic.patch @@ -0,0 +1,55 @@ +From e7f0c46f1b75a97cce2674c4e0455a568801a919 Mon Sep 17 00:00:00 2001 +From: Ryo Hashimoto <hashimoto@chromium.org> +Date: Thu, 2 May 2024 06:27:06 +0000 +Subject: [PATCH] [PATCH] Fix partition_alloc buildflag generation logic for + libchrome + +- Fix buildflag_header.gni to locate the script correctly, and to remove + the dependency on the build_config source set which doesn't exist in + libchrome. +- Fix write_buildflag_header.py to fix the include paths in the + generated header files. + +Change-Id: I2bedffea30ecb10a61721ff0bccdc57424f8324c +--- + .../src/partition_alloc/buildflag_header.gni | 4 +--- + .../src/partition_alloc/write_buildflag_header.py | 2 +- + 2 files changed, 2 insertions(+), 4 deletions(-) + +diff --git a/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni b/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni +index a1c752a2bc..baae7e7a4f 100644 +--- a/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni ++++ b/base/allocator/partition_allocator/src/partition_alloc/buildflag_header.gni +@@ -79,7 +79,7 @@ _current_dir = get_path_info(".", "abspath") + # } + template("pa_buildflag_header") { + action(target_name) { +- script = "./write_buildflag_header.py" ++ script = "${_current_dir}/write_buildflag_header.py" + + if (defined(invoker.header_dir)) { + header_file = "${invoker.header_dir}/${invoker.header}" +@@ -115,7 +115,5 @@ template("pa_buildflag_header") { + "testonly", + "visibility", + ]) +- +- public_deps = [ "${_current_dir}:build_config" ] + } + } +diff --git a/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py b/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py +index e6adb7793c..ed9d7c5a32 100755 +--- a/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py ++++ b/base/allocator/partition_allocator/src/partition_alloc/write_buildflag_header.py +@@ -86,7 +86,7 @@ def WriteHeader(options): + + output_file.write('\n#ifndef %s\n' % options.header_guard) + output_file.write('#define %s\n\n' % options.header_guard) +- output_file.write('#include "partition_alloc/buildflag.h" // IWYU pragma: export\n\n') ++ output_file.write('#include "base/allocator/partition_allocator/src/partition_alloc/buildflag.h" // IWYU pragma: export\n\n') + # TODO(https://crbug.com/41481467) Remove dependency on chromium: + output_file.write('#include "build/buildflag.h" // IWYU pragma: export\n\n') + +-- +2.45.0.rc0.197.gbae5840b3b-goog + diff --git a/mojo/public/cpp/bindings/README.md b/mojo/public/cpp/bindings/README.md index 2e1cdbd6f7..d0693dd3a2 100644 --- a/mojo/public/cpp/bindings/README.md +++ b/mojo/public/cpp/bindings/README.md @@ -721,7 +721,8 @@ LOG(INFO) << "Value is " << value->get_string_value(); // DCHECK! Mojom `feature` generates a `base::Feature` with the given `name` and `default_state` (`true` => `ENABLED_BY_DEFAULT`). The feature can be accessed and tested in C++ using the mapped name even if it is not used to mark any -interfaces or methods. +[interfaces](#runtimefeature-on-interfaces) or +[methods](#runtimefeature-on-methods). ```mojom module experiment.mojom; @@ -1873,6 +1874,13 @@ enum Department { }; ``` +*** note +**NOTE**: The `[Default]` enumerator value is distinct from the automatically +populated enum value used when a non-nullable enum field is not defined in an +older client's versioned struct definition +([the enumerator value corresponding to `0`](/mojo/public/tools/bindings/README.md#ensuring-backward-compatible-behavior)). +*** + ### Using Mojo Bindings in Chrome See [Converting Legacy Chrome IPC To Mojo](/docs/mojo_ipc_conversion.md). diff --git a/mojo/public/tools/bindings/README.md b/mojo/public/tools/bindings/README.md index 3348fc97e5..c840352bb8 100644 --- a/mojo/public/tools/bindings/README.md +++ b/mojo/public/tools/bindings/README.md @@ -739,8 +739,9 @@ struct Employee { *** note **NOTE:** Mojo object or handle types added with a `MinVersion` **MUST** be -optional (nullable). On the other hand, primitive numeric types added with a -`MinVersion` are allowed to be either nullable or non-nullable. +optional (nullable). On the other hand, primitive numeric types (including +enums) added with a `MinVersion` are allowed to be either nullable or +non-nullable. See [Primitive Types](#Primitive-Types) for details on nullable values. @@ -801,6 +802,9 @@ When a struct of version X is passed to a destination using version Y: * If X is older than Y, then all fields newer than version X are populated automatically: `null` for nullable types, and `0`/`false` for primitive + numeric types, including enums. See + [Ensuring Backward Compatible Behavior](#ensuring-backward-compatible-behavior) + for more details on choosing between nullable and non-nullable primitive numeric types. * If X is newer than Y, then all fields newer than version Y are truncated. @@ -950,9 +954,9 @@ definition to communicate with a service using a different version Y: **Choosing between Nullable and Non-nullable Primitive Numeric Types** -Primitive numeric types are allowed to be either nullable or non-nullable when -extending structs or method parameter lists. There are several tradeoffs to -consider when choosing between the two: +Primitive numeric types, including enums, are allowed to be either nullable or +non-nullable when extending structs or method parameter lists. There are several +tradeoffs to consider when choosing between the two: * Nullable numeric primitives: they can offer more semantic safety for new fields because it is more obvious that such fields are optional, and whether @@ -964,6 +968,14 @@ consider when choosing between the two: negligible). And they can avoid additional null checks if value `0`/`false` already represents the invalid state. +*** note +**NOTE**: A non-nullable enum's automatically populated value is distinct from +the value used when an extensible enum is deserialised with an enumerator value +that is not defined in the current enum definition (the enum's +[`[Default]` enumerator value](/mojo/public/cpp/bindings/README.md#versioned-enums), +if one exists). +*** + If the consequences of auto-populated `0`/`false` have not been thoroughly and carefully considered, prefer nullable numeric primitives. |