Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 1 | // 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 Sakamoto | 1b5312d | 2021-10-18 08:53:46 | [diff] [blame] | 5 | #include "base/allocator/partition_alloc_features.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 6 | |
David Sanders | 6e70994 | 2022-04-05 06:49:26 | [diff] [blame] | 7 | #include "base/base_export.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 8 | #include "base/feature_list.h" |
Benoit Lize | 2e4a8f6 | 2022-01-12 13:35:21 | [diff] [blame] | 9 | #include "build/build_config.h" |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 10 | |
| 11 | namespace base { |
Takashi Sakamoto | 0c9274d | 2020-10-08 04:17:37 | [diff] [blame] | 12 | namespace features { |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 13 | |
Bartek Nowierski | bba1846 | 2021-06-02 02:34:47 | [diff] [blame] | 14 | #if defined(PA_ALLOW_PCSCAN) |
Anton Bikineev | 9d8b21b | 2020-10-09 08:11:58 | [diff] [blame] | 15 | // If enabled, PCScan is turned on by default for all partitions that don't |
| 16 | // disable it explicitly. |
| 17 | const Feature kPartitionAllocPCScan{"PartitionAllocPCScan", |
| 18 | FEATURE_DISABLED_BY_DEFAULT}; |
Bartek Nowierski | bba1846 | 2021-06-02 02:34:47 | [diff] [blame] | 19 | #endif // defined(PA_ALLOW_PCSCAN) |
Anton Bikineev | 9d8b21b | 2020-10-09 08:11:58 | [diff] [blame] | 20 | |
Anton Bikineev | db908de | 2020-12-08 14:48:13 | [diff] [blame] | 21 | #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) |
| 22 | // If enabled, PCScan is turned on only for the browser's malloc partition. |
| 23 | const Feature kPartitionAllocPCScanBrowserOnly{ |
| 24 | "PartitionAllocPCScanBrowserOnly", FEATURE_DISABLED_BY_DEFAULT}; |
Benoit Lize | 6ae0027 | 2021-02-25 15:56:53 | [diff] [blame] | 25 | |
Anton Bikineev | d250933 | 2021-09-16 17:14:57 | [diff] [blame] | 26 | // If enabled, PCScan is turned on only for the renderer's malloc partition. |
| 27 | const Feature kPartitionAllocPCScanRendererOnly{ |
| 28 | "PartitionAllocPCScanRendererOnly", FEATURE_DISABLED_BY_DEFAULT}; |
| 29 | |
Bartek Nowierski | d2d35f9 | 2021-04-22 21:36:39 | [diff] [blame] | 30 | // If enabled, this instance belongs to the Control group of the BackupRefPtr |
| 31 | // binary experiment. |
| 32 | const Feature kPartitionAllocBackupRefPtrControl{ |
| 33 | "PartitionAllocBackupRefPtrControl", FEATURE_DISABLED_BY_DEFAULT}; |
| 34 | |
Benoit Lize | 006cfcb | 2021-03-29 16:18:52 | [diff] [blame] | 35 | // Use a larger maximum thread cache cacheable bucket size. |
| 36 | const Feature kPartitionAllocLargeThreadCacheSize{ |
Benoit Lize | 2e4a8f6 | 2022-01-12 13:35:21 | [diff] [blame] | 37 | "PartitionAllocLargeThreadCacheSize", |
Xiaohan Wang | 617a9a5f | 2022-01-15 19:23:01 | [diff] [blame] | 38 | #if BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_32_BITS) |
Benoit Lize | 2e4a8f6 | 2022-01-12 13:35:21 | [diff] [blame] | 39 | // 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 Lize | 006cfcb | 2021-03-29 16:18:52 | [diff] [blame] | 46 | |
Benoit Lize | f13d793 | 2022-01-07 10:29:32 | [diff] [blame] | 47 | const BASE_EXPORT Feature kPartitionAllocLargeEmptySlotSpanRing{ |
| 48 | "PartitionAllocLargeEmptySlotSpanRing", FEATURE_DISABLED_BY_DEFAULT}; |
| 49 | |
Keishi Hattori | ebb719d | 2022-05-13 09:40:30 | [diff] [blame^] | 50 | const 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 Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 58 | |
| 59 | constexpr FeatureParam<BackupRefPtrEnabledProcesses>::Option |
| 60 | kBackupRefPtrEnabledProcessesOptions[] = { |
| 61 | {BackupRefPtrEnabledProcesses::kBrowserOnly, "browser-only"}, |
| 62 | {BackupRefPtrEnabledProcesses::kBrowserAndRenderer, |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 63 | "browser-and-renderer"}, |
Bartek Nowierski | 7668047 | 2021-12-09 17:58:25 | [diff] [blame] | 64 | {BackupRefPtrEnabledProcesses::kNonRenderer, "non-renderer"}, |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 65 | {BackupRefPtrEnabledProcesses::kAllProcesses, "all-processes"}}; |
Keishi Hattori | af499ac | 2021-09-22 23:45:04 | [diff] [blame] | 66 | |
| 67 | const base::FeatureParam<BackupRefPtrEnabledProcesses> |
| 68 | kBackupRefPtrEnabledProcessesParam{ |
| 69 | &kPartitionAllocBackupRefPtr, "enabled-processes", |
| 70 | BackupRefPtrEnabledProcesses::kBrowserOnly, |
| 71 | &kBackupRefPtrEnabledProcessesOptions}; |
| 72 | |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 73 | constexpr FeatureParam<BackupRefPtrMode>::Option kBackupRefPtrModeOptions[] = { |
Bartek Nowierski | ea35aa52 | 2021-12-10 07:08:20 | [diff] [blame] | 74 | {BackupRefPtrMode::kDisabled, "disabled"}, |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 75 | {BackupRefPtrMode::kEnabled, "enabled"}, |
| 76 | {BackupRefPtrMode::kDisabledButSplitPartitions2Way, |
| 77 | "disabled-but-2-way-split"}, |
| 78 | {BackupRefPtrMode::kDisabledButSplitPartitions3Way, |
| 79 | "disabled-but-3-way-split"}, |
| 80 | }; |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 81 | |
Bartek Nowierski | da7d8f1c | 2021-12-08 19:30:59 | [diff] [blame] | 82 | const base::FeatureParam<BackupRefPtrMode> kBackupRefPtrModeParam{ |
| 83 | &kPartitionAllocBackupRefPtr, "brp-mode", BackupRefPtrMode::kEnabled, |
| 84 | &kBackupRefPtrModeOptions}; |
Bartek Nowierski | e9ad8a7d | 2021-11-04 08:37:39 | [diff] [blame] | 85 | |
Bartek Nowierski | 481d846 | 2021-01-09 00:30:46 | [diff] [blame] | 86 | #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) |
Anton Bikineev | db908de | 2020-12-08 14:48:13 | [diff] [blame] | 87 | |
Thiabaud Engelbrecht | 1efe437 | 2022-02-16 19:33:09 | [diff] [blame] | 88 | // 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. |
| 91 | const Feature kPartitionAllocUseAlternateDistribution{ |
| 92 | "PartitionAllocUseAlternateDistribution", FEATURE_DISABLED_BY_DEFAULT}; |
| 93 | |
Michael Lippautz | d34f7b2c | 2021-04-21 08:32:26 | [diff] [blame] | 94 | // If enabled, switches PCScan scheduling to a mutator-aware scheduler. Does not |
| 95 | // affect whether PCScan is enabled itself. |
| 96 | const Feature kPartitionAllocPCScanMUAwareScheduler{ |
| 97 | "PartitionAllocPCScanMUAwareScheduler", FEATURE_ENABLED_BY_DEFAULT}; |
| 98 | |
Hannes Payer | a33df7f | 2021-06-22 18:44:14 | [diff] [blame] | 99 | // If enabled, PCScan frees unconditionally all quarantined objects. |
| 100 | // This is a performance testing feature. |
| 101 | const Feature kPartitionAllocPCScanImmediateFreeing{ |
| 102 | "PartitionAllocPCScanImmediateFreeing", FEATURE_DISABLED_BY_DEFAULT}; |
| 103 | |
Anton Bikineev | 7f11c21 | 2021-08-24 12:03:09 | [diff] [blame] | 104 | // If enabled, PCScan clears eagerly (synchronously) on free(). |
| 105 | const Feature kPartitionAllocPCScanEagerClearing{ |
| 106 | "PartitionAllocPCScanEagerClearing", FEATURE_DISABLED_BY_DEFAULT}; |
| 107 | |
Anton Bikineev | ea8859b | 2021-04-29 19:17:22 | [diff] [blame] | 108 | // In addition to heap, scan also the stack of the current mutator. |
| 109 | const 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 Bikineev | 6b5ab95 | 2021-05-19 23:57:57 | [diff] [blame] | 118 | const Feature kPartitionAllocDCScan{"PartitionAllocDCScan", |
| 119 | FEATURE_DISABLED_BY_DEFAULT}; |
| 120 | |
Takashi Sakamoto | 0c9274d | 2020-10-08 04:17:37 | [diff] [blame] | 121 | } // namespace features |
Takashi Sakamoto | 0044f2f | 2020-06-04 04:19:16 | [diff] [blame] | 122 | } // namespace base |