blob: 911f0eb13f01e4eee0e78f3cc5e020f2421a0420 [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 Lizebfe74a62021-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
Arthur Sonzognibe6f0132022-07-06 13:54:1218// See /docs/dangling_ptr.md
19//
20// Usage:
21// --enable-features=PartitionAllocDanglingPtr:mode/crash
22// --enable-features=PartitionAllocDanglingPtr:mode/log_signature
Daniel Cheng0fff5c232022-09-21 17:43:3423BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDanglingPtr);
Arthur Sonzognibe6f0132022-07-06 13:54:1224enum class DanglingPtrMode {
25 // Crash immediately after detecting a dangling raw_ptr.
26 kCrash, // (default)
27
28 // Log the signature of every occurrences without crashing. It is used by
29 // bots.
30 // Format "[DanglingSignature]\t<1>\t<2>"
31 // 1. The function who freed the memory while it was still referenced.
32 // 2. The function who released the raw_ptr reference.
33 kLogSignature,
34
35 // Note: This will be extended with a single shot DumpWithoutCrashing.
36};
37extern const BASE_EXPORT base::FeatureParam<DanglingPtrMode>
38 kDanglingPtrModeParam;
39
Bartek Nowierskibba18462021-06-02 02:34:4740#if defined(PA_ALLOW_PCSCAN)
Daniel Cheng0fff5c232022-09-21 17:43:3441BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScan);
Bartek Nowierskibba18462021-06-02 02:34:4742#endif // defined(PA_ALLOW_PCSCAN)
Anton Bikineevdb908de2020-12-08 14:48:1343#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Daniel Cheng0fff5c232022-09-21 17:43:3444BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanBrowserOnly);
45BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanRendererOnly);
46BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtrControl);
47BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeThreadCacheSize);
48BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocLargeEmptySlotSpanRing);
Sergei Glazunov7afc89b92022-05-31 19:31:2949#endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
Keishi Hattoriaf499ac2021-09-22 23:45:0450
51enum class BackupRefPtrEnabledProcesses {
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3952 // BRP enabled only in the browser process.
Keishi Hattoriaf499ac2021-09-22 23:45:0453 kBrowserOnly,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3954 // BRP enabled only in the browser and renderer processes.
Keishi Hattoriaf499ac2021-09-22 23:45:0455 kBrowserAndRenderer,
Bartek Nowierski76680472021-12-09 17:58:2556 // BRP enabled in all processes, except renderer.
57 kNonRenderer,
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3958 // BRP enabled in all processes.
59 kAllProcesses,
Keishi Hattoriaf499ac2021-09-22 23:45:0460};
Bartek Nowierskie9ad8a7d2021-11-04 08:37:3961
Bartek Nowierskida7d8f1c2021-12-08 19:30:5962enum class BackupRefPtrMode {
Bartek Nowierskiea35aa522021-12-10 07:08:2063 // BRP is disabled across all partitions. Equivalent to the Finch flag being
64 // disabled.
65 kDisabled,
66
Bartek Nowierskida7d8f1c2021-12-08 19:30:5967 // BRP is enabled in the main partition, as well as certain Renderer-only
68 // partitions (if enabled in Renderer at all).
69 // This entails splitting the main partition.
70 kEnabled,
71
Keishi Hattoric384e2f2022-06-16 09:32:5772 // Same as kEnabled but without zapping quarantined objects.
73 kEnabledWithoutZapping,
74
Bartek Nowierskida7d8f1c2021-12-08 19:30:5975 // BRP is disabled, but the main partition is split out, as if BRP was enabled
76 // in the "previous slot" mode.
77 kDisabledButSplitPartitions2Way,
78
79 // BRP is disabled, but the main partition *and* aligned partition are split
80 // out, as if BRP was enabled in the "before allocation" mode.
81 kDisabledButSplitPartitions3Way,
82};
83
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:2984enum class AlternateBucketDistributionMode : uint8_t {
85 kDefault,
86 kCoarser,
87 kDenser,
88};
89
Daniel Cheng0fff5c232022-09-21 17:43:3490BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocBackupRefPtr);
Keishi Hattoriaf499ac2021-09-22 23:45:0491extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
92 kBackupRefPtrEnabledProcessesParam;
Bartek Nowierskida7d8f1c2021-12-08 19:30:5993extern const BASE_EXPORT base::FeatureParam<BackupRefPtrMode>
94 kBackupRefPtrModeParam;
Sergei Glazunov7afc89b92022-05-31 19:31:2995extern const BASE_EXPORT base::FeatureParam<bool>
96 kBackupRefPtrAsanEnableDereferenceCheckParam;
97extern const BASE_EXPORT base::FeatureParam<bool>
98 kBackupRefPtrAsanEnableExtractionCheckParam;
99extern const BASE_EXPORT base::FeatureParam<bool>
100 kBackupRefPtrAsanEnableInstantiationCheckParam;
Thiabaud Engelbrecht05f8b8112022-09-16 02:18:29101extern const BASE_EXPORT base::FeatureParam<AlternateBucketDistributionMode>
102 kPartitionAllocAlternateBucketDistributionParam;
Takashi Sakamoto0044f2f2020-06-04 04:19:16103
Daniel Cheng0fff5c232022-09-21 17:43:34104BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanMUAwareScheduler);
105BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanStackScanning);
106BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocDCScan);
107BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanImmediateFreeing);
108BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocPCScanEagerClearing);
109BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocSortActiveSlotSpans);
110BASE_EXPORT BASE_DECLARE_FEATURE(kPartitionAllocUseAlternateDistribution);
Michael Lippautzd34f7b2c2021-04-21 08:32:26111
Takashi Sakamoto0c9274d2020-10-08 04:17:37112} // namespace features
Takashi Sakamoto0044f2f2020-06-04 04:19:16113} // namespace base
114
Takashi Sakamoto1b5312d2021-10-18 08:53:46115#endif // BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_