blob: ac9d77e2fdbbabf14b50dc88fc81da6fdbd1ec5c [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
Bartek Nowierskid5d1984a2022-12-18 12:13:158#include "base/allocator/partition_allocator/partition_alloc_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"
Benoit Lize7ebe3d42022-11-24 21:12:0014#include "build/build_config.h"
Takashi Sakamoto3f767cdd2020-08-20 08:37:3115
Takashi Sakamoto0044f2f2020-06-04 04:19:1616namespace base {
Takashi Sakamoto0c9274d2020-10-08 04:17:3717namespace features {
18
Paul Semelb0ce4842022-09-28 08:09:5319extern const BASE_EXPORT Feature kPartitionAllocUnretainedDanglingPtr;
20enum class UnretainedDanglingPtrMode {
21 kCrash,
22 kDumpWithoutCrashing,
23};
24extern const BASE_EXPORT base::FeatureParam<UnretainedDanglingPtrMode>
25 kUnretainedDanglingPtrModeParam;
26
Arthur Sonzognibe6f0132022-07-06 13:54:1227// See /docs/dangling_ptr.md
28//
29// Usage:
30// --enable-features=PartitionAllocDanglingPtr:mode/crash
31// --enable-features=PartitionAllocDanglingPtr:mode/log_signature
Daniel Cheng0fff5c232022-09-21 17:43:3432BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDanglingPtr);
Arthur Sonzognibe6f0132022-07-06 13:54:1233enum class DanglingPtrMode {
34 // Crash immediately after detecting a dangling raw_ptr.
35 kCrash, // (default)
36
37 // Log the signature of every occurrences without crashing. It is used by
38 // bots.
39 // Format "[DanglingSignature]\t<1>\t<2>"
40 // 1. The function who freed the memory while it was still referenced.
41 // 2. The function who released the raw_ptr reference.
42 kLogSignature,
43
44 // Note: This will be extended with a single shot DumpWithoutCrashing.
45};
46extern const BASE_EXPORT base::FeatureParam<DanglingPtrMode>
47 kDanglingPtrModeParam;
48
Bartek Nowierskibba18462021-06-02 02:34:4749#if defined(PA_ALLOW_PCSCAN)
Daniel Cheng0fff5c232022-09-21 17:43:3450BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScan);
Bartek Nowierskibba18462021-06-02 02:34:4751#endif // defined(PA_ALLOW_PCSCAN)
Anton Bikineevdb908de2020-12-08 14:48:1352#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Daniel Cheng0fff5c232022-09-21 17:43:3453BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanBrowserOnly);
54BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanRendererOnly);
55BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtrControl);
56BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeThreadCacheSize);
57BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing);
Sergei Glazunov7afc89b92022-05-31 19:31:2958#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Keishi Hattoriaf499ac2021-09-22 23:45:0459
60enum class BackupRefPtrEnabledProcesses {
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3961 // BRP enabled only in the browser process.
Keishi Hattoriaf499ac2021-09-22 23:45:0462 kBrowserOnly,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3963 // BRP enabled only in the browser and renderer processes.
Keishi Hattoriaf499ac2021-09-22 23:45:0464 kBrowserAndRenderer,
Bartek Nowierski76680472021-12-09 17:58:2565 // BRP enabled in all processes, except renderer.
66 kNonRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3967 // BRP enabled in all processes.
68 kAllProcesses,
Keishi Hattoriaf499ac2021-09-22 23:45:0469};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3970
Bartek Nowierskida7d8f1c2021-12-08 19:30:5971enum class BackupRefPtrMode {
Bartek Nowierskiea35aa522021-12-10 07:08:2072 // BRP is disabled across all partitions. Equivalent to the Finch flag being
73 // disabled.
74 kDisabled,
75
Bartek Nowierskida7d8f1c2021-12-08 19:30:5976 // BRP is enabled in the main partition, as well as certain Renderer-only
77 // partitions (if enabled in Renderer at all).
78 // This entails splitting the main partition.
79 kEnabled,
80
Keishi Hattoric384e2f2022-06-16 09:32:5781 // Same as kEnabled but without zapping quarantined objects.
82 kEnabledWithoutZapping,
83
Bartek Nowierskida7d8f1c2021-12-08 19:30:5984 // BRP is disabled, but the main partition is split out, as if BRP was enabled
85 // in the "previous slot" mode.
86 kDisabledButSplitPartitions2Way,
87
88 // BRP is disabled, but the main partition *and* aligned partition are split
89 // out, as if BRP was enabled in the "before allocation" mode.
90 kDisabledButSplitPartitions3Way,
Keishi Hattoria8fb2be2022-11-21 05:52:5991
92 // BRP is disabled, but add dummy ref count to each allocation. This will
93 // increase allocation size but not change any of the logic. If an issue
94 // reproduce in this mode, it means the increase in size is causing it.
95 kDisabledButAddDummyRefCount,
Bartek Nowierskida7d8f1c2021-12-08 19:30:5996};
97
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:2998enum class AlternateBucketDistributionMode : uint8_t {
99 kDefault,
100 kCoarser,
101 kDenser,
102};
103
Daniel Cheng0fff5c232022-09-21 17:43:34104BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtr);
Keishi Hattoriaf499ac2021-09-22 23:45:04105extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
106 kBackupRefPtrEnabledProcessesParam;
Bartek Nowierskida7d8f1c2021-12-08 19:30:59107extern const BASE_EXPORT base::FeatureParam<BackupRefPtrMode>
108 kBackupRefPtrModeParam;
Sergei Glazunov7afc89b92022-05-31 19:31:29109extern const BASE_EXPORT base::FeatureParam<bool>
110 kBackupRefPtrAsanEnableDereferenceCheckParam;
111extern const BASE_EXPORT base::FeatureParam<bool>
112 kBackupRefPtrAsanEnableExtractionCheckParam;
113extern const BASE_EXPORT base::FeatureParam<bool>
114 kBackupRefPtrAsanEnableInstantiationCheckParam;
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:29115extern const BASE_EXPORT base::FeatureParam<AlternateBucketDistributionMode>
116 kPartitionAllocAlternateBucketDistributionParam;
Takashi Sakamoto0044f2f2020-06-04 04:19:16117
Daniel Cheng0fff5c232022-09-21 17:43:34118BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanMUAwareScheduler);
119BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanStackScanning);
120BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDCScan);
121BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanImmediateFreeing);
122BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanEagerClearing);
123BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocSortActiveSlotSpans);
124BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocUseAlternateDistribution);
Benoit Lize7ebe3d42022-11-24 21:12:00125#if BUILDFLAG(IS_WIN)
126BASE_EXPORT BASE_DECLARE_FEATURE(kPageAllocatorRetryOnCommitFailure);
127#endif
Michael Lippautzd34f7b2c2021-04-21 08:32:26128
Takashi Sakamoto0c9274d2020-10-08 04:17:37129} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16130} // namespace base
131
Takashi Sakamoto1b5312d2021-10-18 08:53:46132#endif // BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_