diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-12 15:59:20 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-25 06:57:22 +0000 |
commit | f7eaed5286974984ba5f9e3189d8f49d03e99f81 (patch) | |
tree | caed19b2af2024f35449fb0b781d0a25e09d4f8f /chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc | |
parent | 9729c4479fe23554eae6e6dd1f30ff488f470c84 (diff) | |
download | qtwebengine-chromium-f7eaed5286974984ba5f9e3189d8f49d03e99f81.tar.gz |
BASELINE: Update Chromium to 100.0.4896.167
Change-Id: I98cbeb5d7543d966ffe04d8cefded0c493a11333
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc | 109 |
1 files changed, 58 insertions, 51 deletions
diff --git a/chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc b/chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc index a5ebe182767..be56aef3ea4 100644 --- a/chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc +++ b/chromium/third_party/blink/renderer/platform/wtf/allocator/partitions.cc @@ -61,6 +61,7 @@ const base::Feature kPCScanBlinkPartitions{ #endif bool Partitions::initialized_ = false; +bool Partitions::scan_is_enabled_ = false; // These statics are inlined, so cannot be LazyInstances. We create the values, // and then set the pointers correctly in Initialize(). @@ -76,7 +77,7 @@ void Partitions::Initialize() { // static bool Partitions::InitializeOnce() { - bool enable_brp = + const bool enable_brp = #if BUILDFLAG(USE_BACKUP_REF_PTR) base::FeatureList::IsEnabled( base::features::kPartitionAllocBackupRefPtr) && @@ -89,12 +90,11 @@ bool Partitions::InitializeOnce() { #else false; #endif - base::PartitionOptions::LazyCommit lazy_commit = - base::FeatureList::IsEnabled(base::features::kPartitionAllocLazyCommit) - ? base::PartitionOptions::LazyCommit::kEnabled - : base::PartitionOptions::LazyCommit::kDisabled; + const base::PartitionOptions::BackupRefPtr brp_setting = + enable_brp ? base::PartitionOptions::BackupRefPtr::kEnabled + : base::PartitionOptions::BackupRefPtr::kDisabled; - const bool enable_scan_on_blink_partitions = + scan_is_enabled_ = !enable_brp && #if defined(PA_ALLOW_PCSCAN) (base::FeatureList::IsEnabled(base::features::kPartitionAllocPCScan) || @@ -113,43 +113,40 @@ bool Partitions::InitializeOnce() { // // In addition, enable the FastMalloc partition if // --enable-features=PartitionAllocPCScanBlinkPartitions is specified. - if (enable_scan_on_blink_partitions || - !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)) { - static base::NoDestructor<base::PartitionAllocator> fast_malloc_allocator{}; - fast_malloc_allocator->init({ - base::PartitionOptions::AlignedAlloc::kDisallowed, + if (scan_is_enabled_ || !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)) { + constexpr base::PartitionOptions::ThreadCache thread_cache = #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) - base::PartitionOptions::ThreadCache::kDisabled, + base::PartitionOptions::ThreadCache::kDisabled; #else - base::PartitionOptions::ThreadCache::kEnabled, + base::PartitionOptions::ThreadCache::kEnabled; #endif - base::PartitionOptions::Quarantine::kAllowed, - base::PartitionOptions::Cookie::kAllowed, - (enable_brp ? base::PartitionOptions::BackupRefPtr::kEnabled - : base::PartitionOptions::BackupRefPtr::kDisabled), - base::PartitionOptions::UseConfigurablePool::kNo, lazy_commit + static base::NoDestructor<base::PartitionAllocator> fast_malloc_allocator{}; + fast_malloc_allocator->init({ + base::PartitionOptions::AlignedAlloc::kDisallowed, + thread_cache, + base::PartitionOptions::Quarantine::kAllowed, + base::PartitionOptions::Cookie::kAllowed, + brp_setting, + base::PartitionOptions::UseConfigurablePool::kNo, }); - fast_malloc_root_ = fast_malloc_allocator->root(); } - static base::NoDestructor<base::PartitionAllocator> buffer_allocator{}; - base::PartitionAllocGlobalInit(&Partitions::HandleOutOfMemory); - buffer_allocator->init( - {base::PartitionOptions::AlignedAlloc::kDisallowed, - base::PartitionOptions::ThreadCache::kDisabled, - base::PartitionOptions::Quarantine::kAllowed, - base::PartitionOptions::Cookie::kAllowed, - (enable_brp ? base::PartitionOptions::BackupRefPtr::kEnabled - : base::PartitionOptions::BackupRefPtr::kDisabled), - base::PartitionOptions::UseConfigurablePool::kNo, lazy_commit}); - + static base::NoDestructor<base::PartitionAllocator> buffer_allocator{}; + buffer_allocator->init({ + base::PartitionOptions::AlignedAlloc::kDisallowed, + base::PartitionOptions::ThreadCache::kDisabled, + base::PartitionOptions::Quarantine::kAllowed, + base::PartitionOptions::Cookie::kAllowed, + brp_setting, + base::PartitionOptions::UseConfigurablePool::kNo, + }); buffer_root_ = buffer_allocator->root(); #if defined(PA_ALLOW_PCSCAN) - if (enable_scan_on_blink_partitions) { + if (scan_is_enabled_) { if (!base::internal::PCScan::IsInitialized()) { base::internal::PCScan::Initialize( {base::internal::PCScan::InitConfig::WantedWriteProtectionMode:: @@ -161,45 +158,55 @@ bool Partitions::InitializeOnce() { } #endif // defined(PA_ALLOW_PCSCAN) + if (!base::FeatureList::IsEnabled( + base::features::kPartitionAllocUseAlternateDistribution)) { +#if !BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) + fast_malloc_root_->SwitchToDenserBucketDistribution(); +#endif + buffer_root_->SwitchToDenserBucketDistribution(); + } + initialized_ = true; return initialized_; } // static void Partitions::InitializeArrayBufferPartition() { + CHECK(initialized_); CHECK(!ArrayBufferPartitionInitialized()); static base::NoDestructor<base::PartitionAllocator> array_buffer_allocator{}; - base::PartitionOptions::LazyCommit lazy_commit = - base::FeatureList::IsEnabled(base::features::kPartitionAllocLazyCommit) - ? base::PartitionOptions::LazyCommit::kEnabled - : base::PartitionOptions::LazyCommit::kDisabled; - // BackupRefPtr disallowed because it will prevent allocations from being 16B // aligned as required by ArrayBufferContents. - array_buffer_allocator->init( - {base::PartitionOptions::AlignedAlloc::kDisallowed, - base::PartitionOptions::ThreadCache::kDisabled, - base::PartitionOptions::Quarantine::kAllowed, - base::PartitionOptions::Cookie::kAllowed, - base::PartitionOptions::BackupRefPtr::kDisabled, - // When the V8 virtual memory cage is enabled, the ArrayBuffer partition - // must be placed inside of it. For that, PA's ConfigurablePool is - // created inside the V8 Cage during initialization. As such, here all we - // need to do is indicate that we'd like to use that Pool if it has been - // created by now (if it hasn't been created, the cage isn't enabled, and - // so we'll use the default Pool). - base::PartitionOptions::UseConfigurablePool::kIfAvailable, lazy_commit}); + array_buffer_allocator->init({ + base::PartitionOptions::AlignedAlloc::kDisallowed, + base::PartitionOptions::ThreadCache::kDisabled, + base::PartitionOptions::Quarantine::kAllowed, + base::PartitionOptions::Cookie::kAllowed, + base::PartitionOptions::BackupRefPtr::kDisabled, + // When the V8 virtual memory cage is enabled, the ArrayBuffer partition + // must be placed inside of it. For that, PA's ConfigurablePool is + // created inside the V8 Cage during initialization. As such, here all we + // need to do is indicate that we'd like to use that Pool if it has been + // created by now (if it hasn't been created, the cage isn't enabled, and + // so we'll use the default Pool). + base::PartitionOptions::UseConfigurablePool::kIfAvailable, + }); array_buffer_root_ = array_buffer_allocator->root(); #if defined(PA_ALLOW_PCSCAN) - if (base::FeatureList::IsEnabled(base::features::kPartitionAllocPCScan) || - base::FeatureList::IsEnabled(kPCScanBlinkPartitions)) { + // PCScan relies on the fact that quarantinable allocations go to PA's + // giga-cage. This is not the case if configurable pool is available. + if (scan_is_enabled_ && !array_buffer_root_->uses_configurable_pool()) { base::internal::PCScan::RegisterNonScannableRoot(array_buffer_root_); } #endif // defined(PA_ALLOW_PCSCAN) + if (!base::FeatureList::IsEnabled( + base::features::kPartitionAllocUseAlternateDistribution)) { + array_buffer_root_->SwitchToDenserBucketDistribution(); + } } // static |