blob: e64b3e4a77ffc7fad2ee9bc05606b24c3a333fa0 [file] [log] [blame]
Takashi Sakamoto0044f2f2020-06-04 04:19:161// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Takashi Sakamoto1b5312d2021-10-18 08:53:465#include "base/allocator/partition_alloc_features.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:166
David Sanders6e709942022-04-05 06:49:267#include "base/base_export.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:168#include "base/feature_list.h"
Benoit Lize2e4a8f62022-01-12 13:35:219#include "build/build_config.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:1610
11namespace base {
Takashi Sakamoto0c9274d2020-10-08 04:17:3712namespace features {
Takashi Sakamoto0044f2f2020-06-04 04:19:1613
Bartek Nowierskibba18462021-06-02 02:34:4714#if defined(PA_ALLOW_PCSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5815// If enabled, PCScan is turned on by default for all partitions that don't
16// disable it explicitly.
17const Feature kPartitionAllocPCScan{"PartitionAllocPCScan",
18 FEATURE_DISABLED_BY_DEFAULT};
Bartek Nowierskibba18462021-06-02 02:34:4719#endif // defined(PA_ALLOW_PCSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5820
Anton Bikineevdb908de2020-12-08 14:48:1321#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
22// If enabled, PCScan is turned on only for the browser's malloc partition.
23const Feature kPartitionAllocPCScanBrowserOnly{
24 "PartitionAllocPCScanBrowserOnly", FEATURE_DISABLED_BY_DEFAULT};
Benoit Lize6ae00272021-02-25 15:56:5325
Anton Bikineevd2509332021-09-16 17:14:5726// If enabled, PCScan is turned on only for the renderer's malloc partition.
27const Feature kPartitionAllocPCScanRendererOnly{
28 "PartitionAllocPCScanRendererOnly", FEATURE_DISABLED_BY_DEFAULT};
29
Bartek Nowierskid2d35f92021-04-22 21:36:3930// If enabled, this instance belongs to the Control group of the BackupRefPtr
31// binary experiment.
32const Feature kPartitionAllocBackupRefPtrControl{
33 "PartitionAllocBackupRefPtrControl", FEATURE_DISABLED_BY_DEFAULT};
34
Benoit Lize006cfcb2021-03-29 16:18:5235// Use a larger maximum thread cache cacheable bucket size.
36const Feature kPartitionAllocLargeThreadCacheSize{
Benoit Lize2e4a8f62022-01-12 13:35:2137 "PartitionAllocLargeThreadCacheSize",
Xiaohan Wang617a9a5f2022-01-15 19:23:0138#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
Benoit Lize2e4a8f62022-01-12 13:35:2139 // Not unconditionally enabled on 32 bit Android, since it is a more
40 // memory-constrained platform.
41 FEATURE_DISABLED_BY_DEFAULT
42#else
43 FEATURE_ENABLED_BY_DEFAULT
44#endif
45};
Benoit Lize006cfcb2021-03-29 16:18:5246
Benoit Lizef13d7932022-01-07 10:29:3247const BASE_EXPORT Feature kPartitionAllocLargeEmptySlotSpanRing{
48 "PartitionAllocLargeEmptySlotSpanRing", FEATURE_DISABLED_BY_DEFAULT};
49
Keishi Hattoriebb719d2022-05-13 09:40:3050const Feature kPartitionAllocBackupRefPtr {
51 "PartitionAllocBackupRefPtr",
52#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN)
53 FEATURE_ENABLED_BY_DEFAULT
54#else
55 FEATURE_DISABLED_BY_DEFAULT
56#endif
57};
Keishi Hattoriaf499ac2021-09-22 23:45:0458
59constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option
60 kBackupRefPtrEnabledProcessesOptions[] = {
61 {BackupRefPtrEnabledProcesses::kBrowserOnly, "browser-only"},
62 {BackupRefPtrEnabledProcesses::kBrowserAndRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3963 "browser-and-renderer"},
Bartek Nowierski76680472021-12-09 17:58:2564 {BackupRefPtrEnabledProcesses::kNonRenderer, "non-renderer"},
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3965 {BackupRefPtrEnabledProcesses::kAllProcesses, "all-processes"}};
Keishi Hattoriaf499ac2021-09-22 23:45:0466
67const base::FeatureParam<BackupRefPtrEnabledProcesses>
68 kBackupRefPtrEnabledProcessesParam{
69 &kPartitionAllocBackupRefPtr, "enabled-processes",
70 BackupRefPtrEnabledProcesses::kBrowserOnly,
71 &kBackupRefPtrEnabledProcessesOptions};
72
Bartek Nowierskida7d8f1c2021-12-08 19:30:5973constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = {
Bartek Nowierskiea35aa522021-12-10 07:08:2074 {BackupRefPtrMode::kDisabled, "disabled"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:5975 {BackupRefPtrMode::kEnabled, "enabled"},
76 {BackupRefPtrMode::kDisabledButSplitPartitions2Way,
77 "disabled-but-2-way-split"},
78 {BackupRefPtrMode::kDisabledButSplitPartitions3Way,
79 "disabled-but-3-way-split"},
80};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3981
Bartek Nowierskida7d8f1c2021-12-08 19:30:5982const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{
83 &kPartitionAllocBackupRefPtr, "brp-mode", BackupRefPtrMode::kEnabled,
84 &kBackupRefPtrModeOptions};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3985
Bartek Nowierski481d8462021-01-09 00:30:4686#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Anton Bikineevdb908de2020-12-08 14:48:1387
Thiabaud Engelbrecht1efe4372022-02-16 19:33:0988// If enabled, switches the bucket distribution to an alternate one. The
89// alternate distribution must have buckets that are a subset of the default
90// one.
91const Feature kPartitionAllocUseAlternateDistribution{
92 "PartitionAllocUseAlternateDistribution", FEATURE_DISABLED_BY_DEFAULT};
93
Michael Lippautzd34f7b2c2021-04-21 08:32:2694// If enabled, switches PCScan scheduling to a mutator-aware scheduler. Does not
95// affect whether PCScan is enabled itself.
96const Feature kPartitionAllocPCScanMUAwareScheduler{
97 "PartitionAllocPCScanMUAwareScheduler", FEATURE_ENABLED_BY_DEFAULT};
98
Hannes Payera33df7f2021-06-22 18:44:1499// If enabled, PCScan frees unconditionally all quarantined objects.
100// This is a performance testing feature.
101const Feature kPartitionAllocPCScanImmediateFreeing{
102 "PartitionAllocPCScanImmediateFreeing", FEATURE_DISABLED_BY_DEFAULT};
103
Anton Bikineev7f11c212021-08-24 12:03:09104// If enabled, PCScan clears eagerly (synchronously) on free().
105const Feature kPartitionAllocPCScanEagerClearing{
106 "PartitionAllocPCScanEagerClearing", FEATURE_DISABLED_BY_DEFAULT};
107
Anton Bikineevea8859b2021-04-29 19:17:22108// In addition to heap, scan also the stack of the current mutator.
109const Feature kPartitionAllocPCScanStackScanning {
110 "PartitionAllocPCScanStackScanning",
111#if defined(PA_PCSCAN_STACK_SUPPORTED)
112 FEATURE_ENABLED_BY_DEFAULT
113#else
114 FEATURE_DISABLED_BY_DEFAULT
115#endif // defined(PA_PCSCAN_STACK_SUPPORTED)
116};
117
Anton Bikineev6b5ab952021-05-19 23:57:57118const Feature kPartitionAllocDCScan{"PartitionAllocDCScan",
119 FEATURE_DISABLED_BY_DEFAULT};
120
Takashi Sakamoto0c9274d2020-10-08 04:17:37121} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16122} // namespace base