blob: b72b1305f48cad30562f7d370f6cebb5d8e5062f [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
Arthur Sonzognibe6f0132022-07-06 13:54:1214const BASE_EXPORT Feature kPartitionAllocDanglingPtr{
15 "PartitionAllocDanglingPtr", FEATURE_DISABLED_BY_DEFAULT};
16constexpr FeatureParam<DanglingPtrMode>::Option kDanglingPtrModeOption[] = {
17 {DanglingPtrMode::kCrash, "crash"},
18 {DanglingPtrMode::kLogSignature, "log_signature"},
19};
20const base::FeatureParam<DanglingPtrMode> kDanglingPtrModeParam{
21 &kPartitionAllocDanglingPtr,
22 "mode",
23 DanglingPtrMode::kCrash,
24 &kDanglingPtrModeOption,
25};
26
Bartek Nowierskibba18462021-06-02 02:34:4727#if defined(PA_ALLOW_PCSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5828// If enabled, PCScan is turned on by default for all partitions that don't
29// disable it explicitly.
30const Feature kPartitionAllocPCScan{"PartitionAllocPCScan",
31 FEATURE_DISABLED_BY_DEFAULT};
Bartek Nowierskibba18462021-06-02 02:34:4732#endif // defined(PA_ALLOW_PCSCAN)
Anton Bikineev9d8b21b2020-10-09 08:11:5833
Anton Bikineevdb908de2020-12-08 14:48:1334#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
35// If enabled, PCScan is turned on only for the browser's malloc partition.
36const Feature kPartitionAllocPCScanBrowserOnly{
37 "PartitionAllocPCScanBrowserOnly", FEATURE_DISABLED_BY_DEFAULT};
Benoit Lize6ae00272021-02-25 15:56:5338
Anton Bikineevd2509332021-09-16 17:14:5739// If enabled, PCScan is turned on only for the renderer's malloc partition.
40const Feature kPartitionAllocPCScanRendererOnly{
41 "PartitionAllocPCScanRendererOnly", FEATURE_DISABLED_BY_DEFAULT};
42
Bartek Nowierskid2d35f92021-04-22 21:36:3943// If enabled, this instance belongs to the Control group of the BackupRefPtr
44// binary experiment.
45const Feature kPartitionAllocBackupRefPtrControl{
46 "PartitionAllocBackupRefPtrControl", FEATURE_DISABLED_BY_DEFAULT};
47
Benoit Lize006cfcb2021-03-29 16:18:5248// Use a larger maximum thread cache cacheable bucket size.
49const Feature kPartitionAllocLargeThreadCacheSize{
Benoit Lize2e4a8f62022-01-12 13:35:2150 "PartitionAllocLargeThreadCacheSize",
Xiaohan Wang617a9a5f2022-01-15 19:23:0151#if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS)
Benoit Lize2e4a8f62022-01-12 13:35:2152 // Not unconditionally enabled on 32 bit Android, since it is a more
53 // memory-constrained platform.
54 FEATURE_DISABLED_BY_DEFAULT
55#else
56 FEATURE_ENABLED_BY_DEFAULT
57#endif
58};
Benoit Lize006cfcb2021-03-29 16:18:5259
Benoit Lizef13d7932022-01-07 10:29:3260const BASE_EXPORT Feature kPartitionAllocLargeEmptySlotSpanRing{
61 "PartitionAllocLargeEmptySlotSpanRing", FEATURE_DISABLED_BY_DEFAULT};
Sergei Glazunov7afc89b92022-05-31 19:31:2962#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Benoit Lizef13d7932022-01-07 10:29:3263
Keishi Hattoriebb719d2022-05-13 09:40:3064const Feature kPartitionAllocBackupRefPtr {
65 "PartitionAllocBackupRefPtr",
Sergei Glazunov38f07f62022-06-15 09:45:5866#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN) || \
67 (BUILDFLAG(USE_ASAN_BACKUP_REF_PTR) && BUILDFLAG(IS_LINUX))
Keishi Hattoriebb719d2022-05-13 09:40:3068 FEATURE_ENABLED_BY_DEFAULT
69#else
70 FEATURE_DISABLED_BY_DEFAULT
71#endif
72};
Keishi Hattoriaf499ac2021-09-22 23:45:0473
74constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option
75 kBackupRefPtrEnabledProcessesOptions[] = {
76 {BackupRefPtrEnabledProcesses::kBrowserOnly, "browser-only"},
77 {BackupRefPtrEnabledProcesses::kBrowserAndRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3978 "browser-and-renderer"},
Bartek Nowierski76680472021-12-09 17:58:2579 {BackupRefPtrEnabledProcesses::kNonRenderer, "non-renderer"},
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3980 {BackupRefPtrEnabledProcesses::kAllProcesses, "all-processes"}};
Keishi Hattoriaf499ac2021-09-22 23:45:0481
82const base::FeatureParam<BackupRefPtrEnabledProcesses>
83 kBackupRefPtrEnabledProcessesParam{
84 &kPartitionAllocBackupRefPtr, "enabled-processes",
85 BackupRefPtrEnabledProcesses::kBrowserOnly,
86 &kBackupRefPtrEnabledProcessesOptions};
87
Bartek Nowierskida7d8f1c2021-12-08 19:30:5988constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = {
Bartek Nowierskiea35aa522021-12-10 07:08:2089 {BackupRefPtrMode::kDisabled, "disabled"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:5990 {BackupRefPtrMode::kEnabled, "enabled"},
Keishi Hattoric384e2f2022-06-16 09:32:5791 {BackupRefPtrMode::kEnabledWithoutZapping, "enabled-without-zapping"},
Bartek Nowierskida7d8f1c2021-12-08 19:30:5992 {BackupRefPtrMode::kDisabledButSplitPartitions2Way,
93 "disabled-but-2-way-split"},
94 {BackupRefPtrMode::kDisabledButSplitPartitions3Way,
95 "disabled-but-3-way-split"},
96};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3997
Bartek Nowierskida7d8f1c2021-12-08 19:30:5998const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{
99 &kPartitionAllocBackupRefPtr, "brp-mode", BackupRefPtrMode::kEnabled,
100 &kBackupRefPtrModeOptions};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:39101
Sergei Glazunov7afc89b92022-05-31 19:31:29102const base::FeatureParam<bool> kBackupRefPtrAsanEnableDereferenceCheckParam{
103 &kPartitionAllocBackupRefPtr, "asan-enable-dereference-check", true};
104const base::FeatureParam<bool> kBackupRefPtrAsanEnableExtractionCheckParam{
105 &kPartitionAllocBackupRefPtr, "asan-enable-extraction-check",
106 false}; // Not much noise at the moment to enable by default.
107const base::FeatureParam<bool> kBackupRefPtrAsanEnableInstantiationCheckParam{
108 &kPartitionAllocBackupRefPtr, "asan-enable-instantiation-check", true};
Anton Bikineevdb908de2020-12-08 14:48:13109
Thiabaud Engelbrecht1efe4372022-02-16 19:33:09110// If enabled, switches the bucket distribution to an alternate one. The
111// alternate distribution must have buckets that are a subset of the default
112// one.
113const Feature kPartitionAllocUseAlternateDistribution{
114 "PartitionAllocUseAlternateDistribution", FEATURE_DISABLED_BY_DEFAULT};
115
Michael Lippautzd34f7b2c2021-04-21 08:32:26116// If enabled, switches PCScan scheduling to a mutator-aware scheduler. Does not
117// affect whether PCScan is enabled itself.
118const Feature kPartitionAllocPCScanMUAwareScheduler{
119 "PartitionAllocPCScanMUAwareScheduler", FEATURE_ENABLED_BY_DEFAULT};
120
Hannes Payera33df7f2021-06-22 18:44:14121// If enabled, PCScan frees unconditionally all quarantined objects.
122// This is a performance testing feature.
123const Feature kPartitionAllocPCScanImmediateFreeing{
124 "PartitionAllocPCScanImmediateFreeing", FEATURE_DISABLED_BY_DEFAULT};
125
Anton Bikineev7f11c212021-08-24 12:03:09126// If enabled, PCScan clears eagerly (synchronously) on free().
127const Feature kPartitionAllocPCScanEagerClearing{
128 "PartitionAllocPCScanEagerClearing", FEATURE_DISABLED_BY_DEFAULT};
129
Anton Bikineevea8859b2021-04-29 19:17:22130// In addition to heap, scan also the stack of the current mutator.
131const Feature kPartitionAllocPCScanStackScanning {
132 "PartitionAllocPCScanStackScanning",
133#if defined(PA_PCSCAN_STACK_SUPPORTED)
134 FEATURE_ENABLED_BY_DEFAULT
135#else
136 FEATURE_DISABLED_BY_DEFAULT
137#endif // defined(PA_PCSCAN_STACK_SUPPORTED)
138};
139
Anton Bikineev6b5ab952021-05-19 23:57:57140const Feature kPartitionAllocDCScan{"PartitionAllocDCScan",
141 FEATURE_DISABLED_BY_DEFAULT};
142
Benoit Lizec9ec61492022-05-20 10:51:25143// Whether to sort the active slot spans in PurgeMemory().
144extern const Feature kPartitionAllocSortActiveSlotSpans{
145 "PartitionAllocSortActiveSlotSpans", FEATURE_DISABLED_BY_DEFAULT};
146
Takashi Sakamoto0c9274d2020-10-08 04:17:37147} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16148} // namespace base