• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_MAC_H_
6 #define BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_MAC_H_
7 
8 // This is an Apple-only file, used to register PartitionAlloc's zone *before*
9 // the process becomes multi-threaded.
10 
11 namespace partition_alloc {
12 
13 static constexpr char kDelegatingZoneName[] =
14     "DelegatingDefaultZoneForPartitionAlloc";
15 static constexpr char kPartitionAllocZoneName[] = "PartitionAlloc";
16 
17 // Zone version. Determines which callbacks are set in the various malloc_zone_t
18 // structs.
19 #if (__MAC_OS_X_VERSION_MAX_ALLOWED >= 130000) || \
20     (__IPHONE_OS_VERSION_MAX_ALLOWED >= 160100)
21 #define PA_TRY_FREE_DEFAULT_IS_AVAILABLE 1
22 #endif
23 #if PA_TRY_FREE_DEFAULT_IS_AVAILABLE
24 constexpr int kZoneVersion = 13;
25 #else
26 constexpr int kZoneVersion = 9;
27 #endif
28 
29 // Must be called *once*, *before* the process becomes multi-threaded.
30 void EarlyMallocZoneRegistration();
31 
32 // Tricks the registration code to believe that PartitionAlloc was not already
33 // registered. This allows a future library load to register PartitionAlloc's
34 // zone as well, rather than bailing out.
35 //
36 // This is mutually exclusive with EarlyMallocZoneRegistation(), and should
37 // ideally be removed. Indeed, by allowing two zones to be registered, we still
38 // end up with a split heap, and more memory usage.
39 //
40 // This is a hack for crbug.com/1274236.
41 void AllowDoublePartitionAllocZoneRegistration();
42 
43 }  // namespace partition_alloc
44 
45 #endif  // BASE_ALLOCATOR_EARLY_ZONE_REGISTRATION_H_
46