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