• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2022 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 #include "base/allocator/partition_allocator/compressed_pointer.h"
6 
7 #if PA_CONFIG(POINTER_COMPRESSION)
8 
9 namespace partition_alloc::internal {
10 
11 // We keep the useful part in |g_base_| as 1s to speed up decompression.
12 alignas(kPartitionCachelineSize)
13     PA_COMPONENT_EXPORT(PARTITION_ALLOC) CompressedPointerBaseGlobal::Base
14     CompressedPointerBaseGlobal::g_base_ = {.base = kUsefulBitsMask};
15 
SetBase(uintptr_t base)16 void CompressedPointerBaseGlobal::SetBase(uintptr_t base) {
17   PA_DCHECK(!IsSet());
18   PA_DCHECK((base & kUsefulBitsMask) == 0);
19   g_base_.base = base | kUsefulBitsMask;
20 }
21 
ResetBaseForTesting()22 void CompressedPointerBaseGlobal::ResetBaseForTesting() {
23   g_base_.base = kUsefulBitsMask;
24 }
25 
26 }  // namespace partition_alloc::internal
27 
28 #endif  // PA_CONFIG(POINTER_COMPRESSION)
29