Avi Drissman | e4622aa | 2022-09-08 20:36:06 | [diff] [blame] | 1 | # Copyright 2019 The Chromium Authors |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 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 | 7fdb169 | 2022-08-26 08:17:58 | [diff] [blame] | 5 | import("//base/allocator/partition_allocator/partition_alloc.gni") |
Takashi Sakamoto | 7fdb169 | 2022-08-26 08:17:58 | [diff] [blame] | 6 | import("//build_overrides/partition_alloc.gni") |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 7 | |
Ali Juma | 50a1938 | 2021-09-20 21:25:23 | [diff] [blame] | 8 | if (is_ios) { |
| 9 | import("//build/config/ios/ios_sdk.gni") |
| 10 | } |
| 11 | |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 12 | declare_args() { |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 13 | # Causes all the allocations to be routed via allocator_shim.cc. |
Takashi Sakamoto | 7fdb169 | 2022-08-26 08:17:58 | [diff] [blame] | 14 | use_allocator_shim = use_allocator_shim_default |
André Kempe | d154eea5 | 2023-03-10 11:07:52 | [diff] [blame] | 15 | |
| 16 | # Use the new allocation event dispatcher to distribute events to event observers. |
| 17 | # If set to false, PoissonAllocationSampler will hook into PartitionAllocator and |
| 18 | # AllocatorShims directly. |
| 19 | use_allocation_event_dispatcher = false |
Yuki Shiino | 90d5fe68 | 2020-09-02 11:03:51 | [diff] [blame] | 20 | } |
| 21 | |
Rohit Rao | 849b426 | 2020-05-01 19:10:34 | [diff] [blame] | 22 | assert( |
Yuki Shiino | 24622fa | 2020-08-26 12:01:02 | [diff] [blame] | 23 | !use_allocator_shim || is_linux || is_chromeos || is_android || is_win || |
Kevin Marshall | 64a82a9 | 2021-09-08 20:49:45 | [diff] [blame] | 24 | is_fuchsia || is_apple, |
| 25 | "use_allocator_shim works only on Android, iOS, Linux, macOS, Fuchsia, " + |
| 26 | "and Windows.") |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 27 | |
Moe Ahmadi | a36d801a | 2021-08-30 22:30:53 | [diff] [blame] | 28 | if (is_win && use_allocator_shim) { |
Kevin Marshall | 64a82a9 | 2021-09-08 20:49:45 | [diff] [blame] | 29 | # TODO(crbug.com/1245317): Add a comment indicating why the shim doesn't work. |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 30 | assert(!is_component_build, |
Moe Ahmadi | a36d801a | 2021-08-30 22:30:53 | [diff] [blame] | 31 | "The allocator shim doesn't work for the component build on Windows.") |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 32 | } |
Bartek Nowierski | ceb2fb3 | 2021-05-26 15:09:05 | [diff] [blame] | 33 | |
Bartek Nowierski | f558565 | 2022-11-30 05:45:17 | [diff] [blame] | 34 | # Chromium-specific asserts. External embedders _may_ elect to use these |
| 35 | # features even without PA-E. |
Kalvin Lee | 49aa6cc | 2022-11-09 05:09:57 | [diff] [blame] | 36 | if (!use_partition_alloc_as_malloc) { |
Kalvin Lee | 52c9031 | 2023-03-14 05:41:31 | [diff] [blame^] | 37 | # In theory, BackupRefPtr will work just fine without |
| 38 | # PartitionAlloc-Everywhere, but its scope would be limited to partitions |
Bartek Nowierski | f558565 | 2022-11-30 05:45:17 | [diff] [blame] | 39 | # that are invoked explicitly (not via malloc). These are only Blink |
| 40 | # partition, where we currently don't even use raw_ptr<T>. |
Kalvin Lee | 49aa6cc | 2022-11-09 05:09:57 | [diff] [blame] | 41 | assert(!enable_backup_ref_ptr_support, |
| 42 | "Chromium does not use BRP without PA-E") |
Bartek Nowierski | e80ad273 | 2022-11-30 09:52:18 | [diff] [blame] | 43 | |
| 44 | # Pointer compression works only if all pointers are guaranteed to be |
| 45 | # allocated by PA (in one of its core pools, to be precise). In theory, |
| 46 | # this could be useful with partitions that are invoked explicitly. In |
| 47 | # practice, the pointers we have in mind for compression (scoped_refptr<>, |
| 48 | # unique_ptr<>) require PA-E. |
| 49 | assert(!enable_pointer_compression_support, |
| 50 | "Pointer compressions likely doesn't make sense without PA-E") |
Kalvin Lee | 49aa6cc | 2022-11-09 05:09:57 | [diff] [blame] | 51 | } |