partition_alloc_features.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #ifndef BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
  5. #define BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_
  6. #include "base/allocator/buildflags.h"
  7. #include "base/allocator/partition_allocator/partition_alloc_config.h"
  8. #include "base/base_export.h"
  9. #include "base/compiler_specific.h"
  10. #include "base/metrics/field_trial_params.h"
  11. namespace base {
  12. struct Feature;
  13. namespace features {
  14. // See /docs/dangling_ptr.md
  15. //
  16. // Usage:
  17. // --enable-features=PartitionAllocDanglingPtr:mode/crash
  18. // --enable-features=PartitionAllocDanglingPtr:mode/log_signature
  19. extern const BASE_EXPORT Feature kPartitionAllocDanglingPtr;
  20. enum class DanglingPtrMode {
  21. // Crash immediately after detecting a dangling raw_ptr.
  22. kCrash, // (default)
  23. // Log the signature of every occurrences without crashing. It is used by
  24. // bots.
  25. // Format "[DanglingSignature]\t<1>\t<2>"
  26. // 1. The function who freed the memory while it was still referenced.
  27. // 2. The function who released the raw_ptr reference.
  28. kLogSignature,
  29. // Note: This will be extended with a single shot DumpWithoutCrashing.
  30. };
  31. extern const BASE_EXPORT base::FeatureParam<DanglingPtrMode>
  32. kDanglingPtrModeParam;
  33. #if defined(PA_ALLOW_PCSCAN)
  34. extern const BASE_EXPORT Feature kPartitionAllocPCScan;
  35. #endif // defined(PA_ALLOW_PCSCAN)
  36. #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
  37. extern const BASE_EXPORT Feature kPartitionAllocPCScanBrowserOnly;
  38. extern const BASE_EXPORT Feature kPartitionAllocPCScanRendererOnly;
  39. extern const BASE_EXPORT Feature kPartitionAllocBackupRefPtrControl;
  40. extern const BASE_EXPORT Feature kPartitionAllocLargeThreadCacheSize;
  41. extern const BASE_EXPORT Feature kPartitionAllocLargeEmptySlotSpanRing;
  42. #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
  43. enum class BackupRefPtrEnabledProcesses {
  44. // BRP enabled only in the browser process.
  45. kBrowserOnly,
  46. // BRP enabled only in the browser and renderer processes.
  47. kBrowserAndRenderer,
  48. // BRP enabled in all processes, except renderer.
  49. kNonRenderer,
  50. // BRP enabled in all processes.
  51. kAllProcesses,
  52. };
  53. enum class BackupRefPtrMode {
  54. // BRP is disabled across all partitions. Equivalent to the Finch flag being
  55. // disabled.
  56. kDisabled,
  57. // BRP is enabled in the main partition, as well as certain Renderer-only
  58. // partitions (if enabled in Renderer at all).
  59. // This entails splitting the main partition.
  60. kEnabled,
  61. // Same as kEnabled but without zapping quarantined objects.
  62. kEnabledWithoutZapping,
  63. // BRP is disabled, but the main partition is split out, as if BRP was enabled
  64. // in the "previous slot" mode.
  65. kDisabledButSplitPartitions2Way,
  66. // BRP is disabled, but the main partition *and* aligned partition are split
  67. // out, as if BRP was enabled in the "before allocation" mode.
  68. kDisabledButSplitPartitions3Way,
  69. };
  70. extern const BASE_EXPORT Feature kPartitionAllocBackupRefPtr;
  71. extern const BASE_EXPORT base::FeatureParam<BackupRefPtrEnabledProcesses>
  72. kBackupRefPtrEnabledProcessesParam;
  73. extern const BASE_EXPORT base::FeatureParam<BackupRefPtrMode>
  74. kBackupRefPtrModeParam;
  75. extern const BASE_EXPORT base::FeatureParam<bool>
  76. kBackupRefPtrAsanEnableDereferenceCheckParam;
  77. extern const BASE_EXPORT base::FeatureParam<bool>
  78. kBackupRefPtrAsanEnableExtractionCheckParam;
  79. extern const BASE_EXPORT base::FeatureParam<bool>
  80. kBackupRefPtrAsanEnableInstantiationCheckParam;
  81. extern const BASE_EXPORT Feature kPartitionAllocPCScanMUAwareScheduler;
  82. extern const BASE_EXPORT Feature kPartitionAllocPCScanStackScanning;
  83. extern const BASE_EXPORT Feature kPartitionAllocDCScan;
  84. extern const BASE_EXPORT Feature kPartitionAllocPCScanImmediateFreeing;
  85. extern const BASE_EXPORT Feature kPartitionAllocPCScanEagerClearing;
  86. extern const BASE_EXPORT Feature kPartitionAllocUseAlternateDistribution;
  87. extern const BASE_EXPORT Feature kPartitionAllocSortActiveSlotSpans;
  88. } // namespace features
  89. } // namespace base
  90. #endif // BASE_ALLOCATOR_PARTITION_ALLOC_FEATURES_H_