diff --git a/src/build.sh b/src/build.sh index 85bcc4ead7..94b52a56f2 100755 --- a/src/build.sh +++ b/src/build.sh @@ -49,6 +49,9 @@ flags="$flags"' enable_reporting=false include_transport_security_state_preload_list=false use_nss_certs=false + + enable_backup_ref_ptr_support=false + enable_dangling_raw_ptr_checks=false ' if [ "$WITH_SYSROOT" ]; then diff --git a/src/net/tools/naive/naive_proxy_bin.cc b/src/net/tools/naive/naive_proxy_bin.cc index f8394e9605..0c1f9ae778 100644 --- a/src/net/tools/naive/naive_proxy_bin.cc +++ b/src/net/tools/naive/naive_proxy_bin.cc @@ -9,6 +9,7 @@ #include #include +#include "base/allocator/partition_alloc_support.h" #include "base/at_exit.h" #include "base/command_line.h" #include "base/feature_list.h" @@ -145,7 +146,9 @@ class MultipleListenCollector : public base::DuplicateSwitchHandler { } } - const std::vector& GetAllValues() const { return all_values_; } + const std::vector& GetAllValues() const { + return all_values_; + } private: std::vector all_values_; @@ -539,7 +542,8 @@ int main(int argc, char* argv[]) { net::HttpNetworkSession::NORMAL_SOCKET_POOL, kDefaultMaxSocketsPerGroup * kExpectedMaxUsers); - naive_partition_alloc_support::ReconfigureAfterFeatureListInit(); + base::allocator::PartitionAllocSupport::Get() + ->ReconfigureAfterFeatureListInit(/*process_type=*/""); #if BUILDFLAG(IS_APPLE) base::mac::ScopedNSAutoreleasePool pool; @@ -576,7 +580,8 @@ int main(int argc, char* argv[]) { base::SingleThreadTaskExecutor io_task_executor(base::MessagePumpType::IO); base::ThreadPoolInstance::CreateAndStartWithDefaultParams("naive"); - naive_partition_alloc_support::ReconfigureAfterTaskRunnerInit(); + base::allocator::PartitionAllocSupport::Get() + ->ReconfigureAfterTaskRunnerInit(/*process_type=*/""); if (!params.ssl_key_path.empty()) { net::SSLClientSocket::SetSSLKeyLogger( diff --git a/src/net/tools/naive/partition_alloc_support.cc b/src/net/tools/naive/partition_alloc_support.cc index 851c1596d5..44cf105e1e 100644 --- a/src/net/tools/naive/partition_alloc_support.cc +++ b/src/net/tools/naive/partition_alloc_support.cc @@ -5,30 +5,13 @@ #include "net/tools/naive/partition_alloc_support.h" -#include - #include "base/allocator/allocator_check.h" -#include "base/allocator/buildflags.h" -#include "base/allocator/partition_alloc_features.h" #include "base/allocator/partition_alloc_support.h" -#include "base/allocator/partition_allocator/partition_alloc_config.h" #include "base/allocator/partition_allocator/shim/allocator_shim.h" -#include "base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.h" -#include "base/allocator/partition_allocator/thread_cache.h" -#include "base/feature_list.h" +#include "base/check.h" #include "base/process/memory.h" -#include "base/time/time.h" #include "build/build_config.h" -#if BUILDFLAG(IS_ANDROID) -#include "base/system/sys_info.h" -#endif - -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) -#include "base/allocator/partition_allocator/memory_reclaimer.h" -#include "base/task/single_thread_task_runner.h" -#endif - #if BUILDFLAG(IS_APPLE) #include "base/allocator/early_zone_registration_mac.h" #endif @@ -62,9 +45,8 @@ void ReconfigureEarly() { // ReconfigureEarlyish(): // These initializations are only relevant for PartitionAlloc-Everywhere // builds. -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - allocator_shim::EnablePartitionAllocMemoryReclaimer(); -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + base::allocator::PartitionAllocSupport::Get()->ReconfigureEarlyish( + /*process_type=*/""); // content/app/content_main.cc: RunContentProcess() // content/app/content_main_runner_impl.cc: Initialize() @@ -75,96 +57,4 @@ void ReconfigureEarly() { CHECK(base::allocator::IsAllocatorInitialized()); } -void ReconfigureAfterFeatureListInit() { - // TODO(bartekn): Switch to DCHECK once confirmed there are no issues. - CHECK(base::FeatureList::GetInstance()); - - // Does not use any of the security features yet. - [[maybe_unused]] bool enable_brp = false; - [[maybe_unused]] bool enable_memory_tagging = false; - [[maybe_unused]] bool split_main_partition = false; - [[maybe_unused]] bool use_dedicated_aligned_partition = false; - [[maybe_unused]] bool process_affected_by_brp_flag = false; - -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - auto bucket_distribution = allocator_shim::BucketDistribution::kNeutral; - // No specified type means we are in the browser. - switch (base::features::kPartitionAllocBucketDistributionParam.Get()) { - case base::features::BucketDistributionMode::kDefault: - break; - case base::features::BucketDistributionMode::kDenser: - bucket_distribution = allocator_shim::BucketDistribution::kDenser; - break; - } - - allocator_shim::ConfigurePartitions( - allocator_shim::EnableBrp(enable_brp), - allocator_shim::EnableMemoryTagging(enable_memory_tagging), - partition_alloc::TagViolationReportingMode::kDisabled, - allocator_shim::SplitMainPartition(split_main_partition), - allocator_shim::UseDedicatedAlignedPartition( - use_dedicated_aligned_partition), - /*ref_count_size=*/0, bucket_distribution); -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - allocator_shim::internal::PartitionAllocMalloc::Allocator() - ->EnableThreadCacheIfSupported(); - - if (base::FeatureList::IsEnabled( - base::features::kPartitionAllocLargeEmptySlotSpanRing)) { - allocator_shim::internal::PartitionAllocMalloc::Allocator() - ->EnableLargeEmptySlotSpanRing(); - allocator_shim::internal::PartitionAllocMalloc::AlignedAllocator() - ->EnableLargeEmptySlotSpanRing(); - } -#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) -} - -void ReconfigureAfterTaskRunnerInit() { -#if defined(PA_THREAD_CACHE_SUPPORTED) && \ - BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - base::allocator::StartThreadCachePeriodicPurge(); - -#if BUILDFLAG(IS_ANDROID) - // Lower thread cache limits to avoid stranding too much memory in the caches. - if (base::SysInfo::IsLowEndDevice()) { - ::partition_alloc::ThreadCacheRegistry::Instance().SetThreadCacheMultiplier( - ::partition_alloc::ThreadCache::kDefaultMultiplier / 2.); - } -#endif // BUILDFLAG(IS_ANDROID) - - // Renderer processes are more performance-sensitive, increase thread cache - // limits. - if (/*is_performance_sensitive=*/true && - base::FeatureList::IsEnabled( - base::features::kPartitionAllocLargeThreadCacheSize)) { - size_t largest_cached_size = - ::partition_alloc::ThreadCacheLimits::kLargeSizeThreshold; - -#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) - // Devices almost always report less physical memory than what they actually - // have, so anything above 3GiB will catch 4GiB and above. - if (base::SysInfo::AmountOfPhysicalMemoryMB() <= 3500) - largest_cached_size = - ::partition_alloc::ThreadCacheLimits::kDefaultSizeThreshold; -#endif // BUILDFLAG(IS_ANDROID) && !defined(ARCH_CPU_64_BITS) - - ::partition_alloc::ThreadCache::SetLargestCachedSize(largest_cached_size); - } - -#endif // defined(PA_THREAD_CACHE_SUPPORTED) && - // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - -#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - base::allocator::StartMemoryReclaimer( - base::SingleThreadTaskRunner::GetCurrentDefault()); -#endif - - if (base::FeatureList::IsEnabled( - base::features::kPartitionAllocSortActiveSlotSpans)) { - partition_alloc::PartitionRoot::EnableSortActiveSlotSpans(); - } -} - } // namespace naive_partition_alloc_support diff --git a/src/net/tools/naive/partition_alloc_support.h b/src/net/tools/naive/partition_alloc_support.h index 515ea3bf84..0cbe6bd14e 100644 --- a/src/net/tools/naive/partition_alloc_support.h +++ b/src/net/tools/naive/partition_alloc_support.h @@ -9,8 +9,6 @@ namespace naive_partition_alloc_support { void ReconfigureEarly(); -void ReconfigureAfterFeatureListInit(); -void ReconfigureAfterTaskRunnerInit(); } // namespace naive_partition_alloc_support