mirror of
https://github.com/wolfpld/tracy.git
synced 2026-06-08 08:33:48 +00:00
Rewrite TaggedUserlandAddress.
Drop dead code. Move tag to low bits, keep ptr at high bits. Protocol bump, as TaggedUserlandAddress is used to transmit "literal" messages.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace tracy
|
||||
|
||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||
|
||||
constexpr uint32_t ProtocolVersion = 78;
|
||||
constexpr uint32_t ProtocolVersion = 79;
|
||||
constexpr uint16_t BroadcastVersion = 3;
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
|
||||
@@ -11,37 +11,19 @@ namespace tracy
|
||||
|
||||
class TaggedUserlandAddress
|
||||
{
|
||||
// So far no kernel seems to allow userspace address with more than 56bits userspace VAs since now hardware support it.
|
||||
// See https://docs.kernel.org/next/x86/x86_64/mm.html and https://www.kernel.org/doc/html/v5.8/arm64/memory.html#bit-userspace-vas
|
||||
static constexpr uint64_t kUserspaceVABits = 56;
|
||||
static constexpr uint64_t kKernelOnlyBits = 64 - kUserspaceVABits;
|
||||
static constexpr uint64_t kKernelOnlyBitMask = ( ( uint64_t(1) << kKernelOnlyBits ) - uint64_t(1) ) << kUserspaceVABits;
|
||||
static constexpr uint64_t ptrShift = 8;
|
||||
static constexpr uint64_t highBits = 0xFF00000000000000;
|
||||
|
||||
public:
|
||||
TaggedUserlandAddress() = default;
|
||||
tracy_force_inline explicit TaggedUserlandAddress( uint64_t address, uint8_t tag = 0 )
|
||||
{
|
||||
assert( ( address & kKernelOnlyBitMask ) == 0 );
|
||||
assert( ( (uint64_t)tag & ~( kKernelOnlyBitMask >> kUserspaceVABits ) ) == 0 );
|
||||
m_storage = address | ( (uint64_t)tag << kUserspaceVABits );
|
||||
assert( ( address & highBits ) == 0 );
|
||||
m_storage = ( address << ptrShift ) | tag;
|
||||
}
|
||||
|
||||
tracy_force_inline void SetPackedValue(uint64_t value) { m_storage = value; }
|
||||
tracy_force_inline uint64_t GetPackedValue() const { return m_storage; }
|
||||
|
||||
tracy_force_inline void SetAddress( uint64_t address)
|
||||
{
|
||||
assert( ( address & kKernelOnlyBitMask ) == 0 );
|
||||
m_storage = ( m_storage & kKernelOnlyBitMask ) | address;
|
||||
}
|
||||
tracy_force_inline uint64_t GetAddress() const { return m_storage & ( ~kKernelOnlyBitMask ); }
|
||||
|
||||
tracy_force_inline void SetTag( uint8_t tag )
|
||||
{
|
||||
assert( ( (uint64_t)tag & ~( kKernelOnlyBitMask >> kUserspaceVABits ) ) == 0 );
|
||||
m_storage = ( (uint64_t)tag << kUserspaceVABits ) | ( m_storage & ( ~kKernelOnlyBitMask ) );
|
||||
}
|
||||
tracy_force_inline uint8_t GetTag() const { return (uint8_t)( ( m_storage & kKernelOnlyBitMask ) >> kUserspaceVABits ); }
|
||||
tracy_force_inline uint64_t GetAddress() const { return m_storage >> ptrShift; }
|
||||
tracy_force_inline uint8_t GetTag() const { return uint8_t( m_storage & 0xFF ); }
|
||||
|
||||
private:
|
||||
uint64_t m_storage;
|
||||
|
||||
Reference in New Issue
Block a user