blob: 581cb7634a785be8298b0b12b1f69cd3b16c48e6 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2020 The Chromium Authors
Takashi Sakamoto0044f2f2020-06-04 04:19:162// 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#ifndef BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
6#define BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
Takashi Sakamoto0044f2f2020-06-04 04:19:167
Benoit Lizea27feee2020-06-10 12:48:528#include "base/allocator/buildflags.h"
Benoit Lizebfe74a652021-04-02 04:54:049#include "base/allocator/partition_allocator/partition_alloc_config.h"
Takashi Sakamoto0044f2f2020-06-04 04:19:1610#include "base/base_export.h"
Hans Wennborg133b1f52021-05-11 19:49:0311#include "base/compiler_specific.h"
Anthony Vallee-Dubois9dbbbda32022-08-26 01:25:3112#include "base/feature_list.h"
Keishi Hattoriaf499ac2021-09-22 23:45:0413#include "base/metrics/field_trial_params.h"
Takashi Sakamoto3f767cdd2020-08-20 08:37:3114
Takashi Sakamoto0044f2f2020-06-04 04:19:1615namespace base {
Takashi Sakamoto0c9274d2020-10-08 04:17:3716namespace features {
17
Paul Semelb0ce4842022-09-28 08:09:5318extern const BASE_EXPORT Feature kPartitionAllocUnretainedDanglingPtr;
19enum class UnretainedDanglingPtrMode {
20 kCrash,
21 kDumpWithoutCrashing,
22};
23extern const BASE_EXPORT base::FeatureParam<UnretainedDanglingPtrMode>
24 kUnretainedDanglingPtrModeParam;
25
Arthur Sonzognibe6f0132022-07-06 13:54:1226// See /docs/dangling_ptr.md
27//
28// Usage:
29// --enable-features=PartitionAllocDanglingPtr:mode/crash
30// --enable-features=PartitionAllocDanglingPtr:mode/log_signature
Daniel Cheng0fff5c232022-09-21 17:43:3431BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDanglingPtr);
Arthur Sonzognibe6f0132022-07-06 13:54:1232enum class DanglingPtrMode {
33 // Crash immediately after detecting a dangling raw_ptr.
34 kCrash, // (default)
35
36 // Log the signature of every occurrences without crashing. It is used by
37 // bots.
38 // Format "[DanglingSignature]\t<1>\t<2>"
39 // 1. The function who freed the memory while it was still referenced.
40 // 2. The function who released the raw_ptr reference.
41 kLogSignature,
42
43 // Note: This will be extended with a single shot DumpWithoutCrashing.
44};
45extern const BASE_EXPORT base::FeatureParam<DanglingPtrMode>
46 kDanglingPtrModeParam;
47
Bartek Nowierskibba18462021-06-02 02:34:4748#if defined(PA_ALLOW_PCSCAN)
Daniel Cheng0fff5c232022-09-21 17:43:3449BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScan);
Bartek Nowierskibba18462021-06-02 02:34:4750#endif // defined(PA_ALLOW_PCSCAN)
Anton Bikineevdb908de2020-12-08 14:48:1351#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Daniel Cheng0fff5c232022-09-21 17:43:3452BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanBrowserOnly);
53BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanRendererOnly);
54BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtrControl);
55BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeThreadCacheSize);
56BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing);
Sergei Glazunov7afc89b92022-05-31 19:31:2957#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Keishi Hattoriaf499ac2021-09-22 23:45:0458
59enum class BackupRefPtrEnabledProcesses {
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3960 // BRP enabled only in the browser process.
Keishi Hattoriaf499ac2021-09-22 23:45:0461 kBrowserOnly,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3962 // BRP enabled only in the browser and renderer processes.
Keishi Hattoriaf499ac2021-09-22 23:45:0463 kBrowserAndRenderer,
Bartek Nowierski76680472021-12-09 17:58:2564 // BRP enabled in all processes, except renderer.
65 kNonRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3966 // BRP enabled in all processes.
67 kAllProcesses,
Keishi Hattoriaf499ac2021-09-22 23:45:0468};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3969
Bartek Nowierskida7d8f1c2021-12-08 19:30:5970enum class BackupRefPtrMode {
Bartek Nowierskiea35aa522021-12-10 07:08:2071 // BRP is disabled across all partitions. Equivalent to the Finch flag being
72 // disabled.
73 kDisabled,
74
Bartek Nowierskida7d8f1c2021-12-08 19:30:5975 // BRP is enabled in the main partition, as well as certain Renderer-only
76 // partitions (if enabled in Renderer at all).
77 // This entails splitting the main partition.
78 kEnabled,
79
Keishi Hattoric384e2f2022-06-16 09:32:5780 // Same as kEnabled but without zapping quarantined objects.
81 kEnabledWithoutZapping,
82
Bartek Nowierskida7d8f1c2021-12-08 19:30:5983 // BRP is disabled, but the main partition is split out, as if BRP was enabled
84 // in the "previous slot" mode.
85 kDisabledButSplitPartitions2Way,
86
87 // BRP is disabled, but the main partition *and* aligned partition are split
88 // out, as if BRP was enabled in the "before allocation" mode.
89 kDisabledButSplitPartitions3Way,
Keishi Hattoria8fb2be2022-11-21 05:52:5990
91 // BRP is disabled, but add dummy ref count to each allocation. This will
92 // increase allocation size but not change any of the logic. If an issue
93 // reproduce in this mode, it means the increase in size is causing it.
94 kDisabledButAddDummyRefCount,
Bartek Nowierskida7d8f1c2021-12-08 19:30:5995};
96
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:2997enum class AlternateBucketDistributionMode : uint8_t {
98 kDefault,
99 kCoarser,
100 kDenser,
101};
102
Daniel Cheng0fff5c232022-09-21 17:43:34103BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtr);
Keishi Hattoriaf499ac2021-09-22 23:45:04104extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
105 kBackupRefPtrEnabledProcessesParam;
Bartek Nowierskida7d8f1c2021-12-08 19:30:59106extern const BASE_EXPORT base::FeatureParam<BackupRefPtrMode>
107 kBackupRefPtrModeParam;
Sergei Glazunov7afc89b92022-05-31 19:31:29108extern const BASE_EXPORT base::FeatureParam<bool>
109 kBackupRefPtrAsanEnableDereferenceCheckParam;
110extern const BASE_EXPORT base::FeatureParam<bool>
111 kBackupRefPtrAsanEnableExtractionCheckParam;
112extern const BASE_EXPORT base::FeatureParam<bool>
113 kBackupRefPtrAsanEnableInstantiationCheckParam;
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:29114extern const BASE_EXPORT base::FeatureParam<AlternateBucketDistributionMode>
115 kPartitionAllocAlternateBucketDistributionParam;
Takashi Sakamoto0044f2f2020-06-04 04:19:16116
Daniel Cheng0fff5c232022-09-21 17:43:34117BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanMUAwareScheduler);
118BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanStackScanning);
119BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDCScan);
120BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanImmediateFreeing);
121BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanEagerClearing);
122BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocSortActiveSlotSpans);
123BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocUseAlternateDistribution);
Michael Lippautzd34f7b2c2021-04-21 08:32:26124
Takashi Sakamoto0c9274d2020-10-08 04:17:37125} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16126} // namespace base
127
Takashi Sakamoto1b5312d2021-10-18 08:53:46128#endif // BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_