blob: 635ca46ef7d0c0c7943dbd865d8cbbd9da318a27 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061# Copyright 2019 The Chromium Authors
Nico Weberb80b0852019-08-01 22:03:012# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Takashi Sakamoto7fdb1692022-08-26 08:17:585import("//base/allocator/partition_allocator/partition_alloc.gni")
Takashi Sakamoto7fdb1692022-08-26 08:17:586import("//build_overrides/partition_alloc.gni")
Nico Weberb80b0852019-08-01 22:03:017
Ali Juma50a19382021-09-20 21:25:238if (is_ios) {
9 import("//build/config/ios/ios_sdk.gni")
10}
11
Nico Weberb80b0852019-08-01 22:03:0112declare_args() {
Nico Weberb80b0852019-08-01 22:03:0113 # Causes all the allocations to be routed via allocator_shim.cc.
Takashi Sakamoto7fdb1692022-08-26 08:17:5814 use_allocator_shim = use_allocator_shim_default
André Kemped154eea52023-03-10 11:07:5215
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 Shiino90d5fe682020-09-02 11:03:5120}
21
Rohit Rao849b4262020-05-01 19:10:3422assert(
Yuki Shiino24622fa2020-08-26 12:01:0223 !use_allocator_shim || is_linux || is_chromeos || is_android || is_win ||
Kevin Marshall64a82a92021-09-08 20:49:4524 is_fuchsia || is_apple,
25 "use_allocator_shim works only on Android, iOS, Linux, macOS, Fuchsia, " +
26 "and Windows.")
Nico Weberb80b0852019-08-01 22:03:0127
Moe Ahmadia36d801a2021-08-30 22:30:5328if (is_win && use_allocator_shim) {
Kevin Marshall64a82a92021-09-08 20:49:4529 # TODO(crbug.com/1245317): Add a comment indicating why the shim doesn't work.
Nico Weberb80b0852019-08-01 22:03:0130 assert(!is_component_build,
Moe Ahmadia36d801a2021-08-30 22:30:5331 "The allocator shim doesn't work for the component build on Windows.")
Nico Weberb80b0852019-08-01 22:03:0132}
Bartek Nowierskiceb2fb32021-05-26 15:09:0533
Bartek Nowierskif5585652022-11-30 05:45:1734# Chromium-specific asserts. External embedders _may_ elect to use these
35# features even without PA-E.
Kalvin Lee49aa6cc2022-11-09 05:09:5736if (!use_partition_alloc_as_malloc) {
Kalvin Lee52c90312023-03-14 05:41:3137 # In theory, BackupRefPtr will work just fine without
38 # PartitionAlloc-Everywhere, but its scope would be limited to partitions
Bartek Nowierskif5585652022-11-30 05:45:1739 # that are invoked explicitly (not via malloc). These are only Blink
40 # partition, where we currently don't even use raw_ptr<T>.
Kalvin Lee49aa6cc2022-11-09 05:09:5741 assert(!enable_backup_ref_ptr_support,
42 "Chromium does not use BRP without PA-E")
Bartek Nowierskie80ad2732022-11-30 09:52:1843
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 Lee49aa6cc2022-11-09 05:09:5751}