Update On Wed Nov 20 19:36:24 CET 2024

This commit is contained in:
github-action[bot]
2024-11-20 19:36:24 +01:00
parent 83ec5ecc52
commit 8e6e20e4f2
1402 changed files with 30980 additions and 19455 deletions
@@ -337,6 +337,40 @@ std::map<std::string, std::string> ProposeSyntheticFinchTrials() {
return trials;
}
namespace {
bool ShouldEnableFeatureOnProcess(
features::internal::PAFeatureEnabledProcesses enabled_processes,
const std::string& process_type) {
switch (enabled_processes) {
case features::internal::PAFeatureEnabledProcesses::kBrowserOnly:
return process_type.empty();
case features::internal::PAFeatureEnabledProcesses::kNonRenderer:
return process_type != switches::kRendererProcess;
case features::internal::PAFeatureEnabledProcesses::kBrowserAndRenderer:
return process_type.empty() || process_type == switches::kRendererProcess;
case features::internal::PAFeatureEnabledProcesses::kRendererOnly:
return process_type == switches::kRendererProcess;
case features::internal::PAFeatureEnabledProcesses::kAllChildProcesses:
return !process_type.empty() && process_type != switches::kZygoteProcess;
case features::internal::PAFeatureEnabledProcesses::kAllProcesses:
return true;
}
}
#if PA_CONFIG(ENABLE_SHADOW_METADATA)
bool ShouldEnableShadowMetadata(const std::string& process_type) {
if (!base::FeatureList::IsEnabled(
base::features::kPartitionAllocShadowMetadata)) {
return false;
}
return ShouldEnableFeatureOnProcess(
features::kShadowMetadataEnabledProcessesParam.Get(), process_type);
}
#endif // PA_CONFIG(ENABLE_SHADOW_METADATA)
} // namespace
#if PA_BUILDFLAG(ENABLE_DANGLING_RAW_PTR_CHECKS)
namespace {
@@ -779,14 +813,8 @@ bool PartitionAllocSupport::ShouldEnableMemoryTagging(
base::features::kKillPartitionAllocMemoryTagging)) {
return false;
}
switch (base::features::kMemoryTaggingEnabledProcessesParam.Get()) {
case base::features::MemoryTaggingEnabledProcesses::kBrowserOnly:
return process_type.empty();
case base::features::MemoryTaggingEnabledProcesses::kNonRenderer:
return process_type != switches::kRendererProcess;
case base::features::MemoryTaggingEnabledProcesses::kAllProcesses:
return true;
}
return ShouldEnableFeatureOnProcess(
base::features::kMemoryTaggingEnabledProcessesParam.Get(), process_type);
}
// static
@@ -804,36 +832,13 @@ bool PartitionAllocSupport::ShouldEnablePartitionAllocWithAdvancedChecks(
base::features::kPartitionAllocWithAdvancedChecks)) {
return false;
}
switch (base::features::kPartitionAllocWithAdvancedChecksEnabledProcessesParam
.Get()) {
case base::features::PartitionAllocWithAdvancedChecksEnabledProcesses::
kBrowserOnly:
return process_type.empty();
case base::features::PartitionAllocWithAdvancedChecksEnabledProcesses::
kBrowserAndRenderer:
return process_type.empty() || process_type == switches::kRendererProcess;
case base::features::PartitionAllocWithAdvancedChecksEnabledProcesses::
kNonRenderer:
return process_type != switches::kRendererProcess;
case base::features::PartitionAllocWithAdvancedChecksEnabledProcesses::
kAllProcesses:
return true;
}
return ShouldEnableFeatureOnProcess(
base::features::kPartitionAllocWithAdvancedChecksEnabledProcessesParam
.Get(),
process_type);
#endif // !PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
}
#if PA_BUILDFLAG( \
ENABLE_ALLOCATOR_SHIM_PARTITION_ALLOC_DISPATCH_WITH_ADVANCED_CHECKS_SUPPORT)
allocator_shim::AllocatorDispatch g_dispatch_for_advanced_checks = {
.realloc_function =
&allocator_shim::internal::PartitionReallocWithAdvancedChecks,
.free_function = &allocator_shim::internal::PartitionFreeWithAdvancedChecks,
.next = nullptr,
};
#endif // PA_BUILDFLAG(
// ENABLE_ALLOCATOR_SHIM_PARTITION_ALLOC_DISPATCH_WITH_ADVANCED_CHECKS_SUPPORT)
// static
PartitionAllocSupport::BrpConfiguration
PartitionAllocSupport::GetBrpConfiguration(const std::string& process_type) {
@@ -841,32 +846,19 @@ PartitionAllocSupport::GetBrpConfiguration(const std::string& process_type) {
CHECK(base::FeatureList::GetInstance());
bool process_affected_by_brp_flag = false;
#if (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) || \
#if (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) && \
PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT) && \
!PA_BUILDFLAG(FORCE_DISABLE_BACKUP_REF_PTR_FEATURE)) || \
PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
if (base::FeatureList::IsEnabled(
base::features::kPartitionAllocBackupRefPtr)) {
// No specified process type means this is the Browser process.
switch (base::features::kBackupRefPtrEnabledProcessesParam.Get()) {
case base::features::BackupRefPtrEnabledProcesses::kBrowserOnly:
process_affected_by_brp_flag = process_type.empty();
break;
case base::features::BackupRefPtrEnabledProcesses::kBrowserAndRenderer:
process_affected_by_brp_flag =
process_type.empty() ||
(process_type == switches::kRendererProcess);
break;
case base::features::BackupRefPtrEnabledProcesses::kNonRenderer:
process_affected_by_brp_flag =
(process_type != switches::kRendererProcess);
break;
case base::features::BackupRefPtrEnabledProcesses::kAllProcesses:
process_affected_by_brp_flag = true;
break;
}
process_affected_by_brp_flag = ShouldEnableFeatureOnProcess(
base::features::kBackupRefPtrEnabledProcessesParam.Get(), process_type);
}
#endif // (PA_BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) &&
// PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)) ||
// PA_BUILDFLAG(ENABLE_BACKUP_REF_PTR_SUPPORT)&&
// !PA_BUILDFLAG(FORCE_DISABLE_BACKUP_REF_PTR_FEATURE)) ||
// PA_BUILDFLAG(USE_ASAN_BACKUP_REF_PTR)
const bool enable_brp =
@@ -1138,8 +1130,7 @@ void PartitionAllocSupport::ReconfigureAfterFeatureListInit(
bool enable_pa_with_advanced_checks =
ShouldEnablePartitionAllocWithAdvancedChecks(process_type);
if (enable_pa_with_advanced_checks) {
allocator_shim::InstallDispatchToPartitionAllocWithAdvancedChecks(
&g_dispatch_for_advanced_checks);
allocator_shim::InstallCustomDispatchForPartitionAllocWithAdvancedChecks();
}
#endif // PA_BUILDFLAG(
// ENABLE_ALLOCATOR_SHIM_PARTITION_ALLOC_DISPATCH_WITH_ADVANCED_CHECKS_SUPPORT)
@@ -1254,6 +1245,14 @@ void PartitionAllocSupport::ReconfigureAfterTaskRunnerInit(
partition_alloc::PartitionRoot::SetSortActiveSlotSpansEnabled(
base::FeatureList::IsEnabled(
base::features::kPartitionAllocSortActiveSlotSpans));
#if PA_CONFIG(ENABLE_SHADOW_METADATA)
if (ShouldEnableShadowMetadata(process_type)) {
partition_alloc::PartitionRoot::EnableShadowMetadata(
partition_alloc::internal::PoolHandleMask::kRegular |
partition_alloc::internal::PoolHandleMask::kBRP);
}
#endif // PA_CONFIG(ENABLE_SHADOW_METADATA)
}
void PartitionAllocSupport::OnForegrounded(bool has_main_frame) {
@@ -1308,9 +1307,8 @@ void PartitionAllocSupport::OnBackgrounded() {
// TODO(lizeb): Remove once/if the behavior of idle tasks changes.
base::PostDelayedMemoryReductionTask(
base::SingleThreadTaskRunner::GetCurrentDefault(), FROM_HERE,
base::BindOnce([]() {
::partition_alloc::MemoryReclaimer::Instance()->ReclaimAll();
}),
base::BindOnce(
[] { ::partition_alloc::MemoryReclaimer::Instance()->ReclaimAll(); }),
base::Seconds(10));
#endif // PA_CONFIG(THREAD_CACHE_SUPPORTED)