//===-- memprof_mapping.h --------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file is a part of MemProfiler, a memory profiler. // // Defines MemProf memory mapping. //===----------------------------------------------------------------------===// #ifndef MEMPROF_MAPPING_H #define MEMPROF_MAPPING_H #include "memprof_internal.h" static const u64 kDefaultShadowScale = …; #define SHADOW_SCALE … #define SHADOW_OFFSET … #define SHADOW_GRANULARITY … #define MEMPROF_ALIGNMENT … namespace __memprof { extern uptr kHighMemEnd; // Initialized in __memprof_init. } // namespace __memprof // Size of memory block mapped to a single shadow location #define MEM_GRANULARITY … #define SHADOW_MASK … #define MEM_TO_SHADOW(mem) … // Histogram shadow memory is laid different to the standard configuration: // 8 bytes // +---+---+---+ +---+---+---+ +---+---+---+ // Memory | a | | b | | c | // +---+---+---+ +---+---+---+ +---+---+---+ // +---+ +---+ +---+ // Shadow | a | | b | | c | // +---+ +---+ +---+ // 1 byte // // Where we have a 1 byte counter for each 8 bytes. HISTOGRAM_MEM_TO_SHADOW // translates a memory address to the address of its corresponding shadow // counter memory address. The same data is still provided in MIB whether // histograms are used or not. Total access counts per allocations are // computed by summing up all individual 1 byte counters. This can incur an // accuracy penalty. #define HISTOGRAM_GRANULARITY … #define HISTOGRAM_MAX_COUNTER … #define HISTOGRAM_SHADOW_MASK … #define HISTOGRAM_MEM_TO_SHADOW(mem) … #define SHADOW_ENTRY_SIZE … #define kLowMemBeg … #define kLowMemEnd … #define kLowShadowBeg … #define kLowShadowEnd … #define kHighMemBeg … #define kHighShadowBeg … #define kHighShadowEnd … // With the zero shadow base we can not actually map pages starting from 0. // This constant is somewhat arbitrary. #define kZeroBaseShadowStart … #define kZeroBaseMaxShadowStart … #define kShadowGapBeg … #define kShadowGapEnd … namespace __memprof { inline uptr MemToShadowSize(uptr size) { … } inline bool AddrIsInLowMem(uptr a) { … } inline bool AddrIsInLowShadow(uptr a) { … } inline bool AddrIsInHighMem(uptr a) { … } inline bool AddrIsInHighShadow(uptr a) { … } inline bool AddrIsInShadowGap(uptr a) { … } inline bool AddrIsInMem(uptr a) { … } inline uptr MemToShadow(uptr p) { … } inline bool AddrIsInShadow(uptr a) { … } inline bool AddrIsAlignedByGranularity(uptr a) { … } inline void RecordAccess(uptr a) { … } inline void RecordAccessHistogram(uptr a) { … } } // namespace __memprof #endif // MEMPROF_MAPPING_H