Use alias for s_ring[i].

This commit is contained in:
Bartosz Taudul 2021-06-12 13:13:53 +02:00
parent f4c95eb021
commit ed50447f7a
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -933,8 +933,9 @@ static void SetupSampling( int64_t& samplingPeriod )
for( int i=0; i<s_numBuffers; i++ ) for( int i=0; i<s_numBuffers; i++ )
{ {
if( !traceActive.load( std::memory_order_relaxed ) ) break; if( !traceActive.load( std::memory_order_relaxed ) ) break;
const auto head = s_ring[i].LoadHead(); auto& ring = s_ring[i];
const auto tail = s_ring[i].GetTail(); const auto head = ring.LoadHead();
const auto tail = ring.GetTail();
if( head == tail ) continue; if( head == tail ) continue;
assert( head > tail ); assert( head > tail );
hadData = true; hadData = true;
@ -944,11 +945,11 @@ static void SetupSampling( int64_t& samplingPeriod )
while( pos < end ) while( pos < end )
{ {
perf_event_header hdr; perf_event_header hdr;
s_ring[i].Read( &hdr, pos, sizeof( perf_event_header ) ); ring.Read( &hdr, pos, sizeof( perf_event_header ) );
if( hdr.type == PERF_RECORD_SAMPLE ) if( hdr.type == PERF_RECORD_SAMPLE )
{ {
auto offset = pos + sizeof( perf_event_header ); auto offset = pos + sizeof( perf_event_header );
const auto id = s_ring[i].GetId(); const auto id = ring.GetId();
if( id == EventCallstack ) if( id == EventCallstack )
{ {
// Layout: // Layout:
@ -962,22 +963,22 @@ static void SetupSampling( int64_t& samplingPeriod )
uint64_t cnt; uint64_t cnt;
offset += sizeof( uint32_t ); offset += sizeof( uint32_t );
s_ring[i].Read( &tid, offset, sizeof( uint32_t ) ); ring.Read( &tid, offset, sizeof( uint32_t ) );
offset += sizeof( uint32_t ); offset += sizeof( uint32_t );
s_ring[i].Read( &t0, offset, sizeof( uint64_t ) ); ring.Read( &t0, offset, sizeof( uint64_t ) );
offset += sizeof( uint64_t ); offset += sizeof( uint64_t );
s_ring[i].Read( &cnt, offset, sizeof( uint64_t ) ); ring.Read( &cnt, offset, sizeof( uint64_t ) );
offset += sizeof( uint64_t ); offset += sizeof( uint64_t );
if( cnt > 0 ) if( cnt > 0 )
{ {
#if defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) #if defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 )
t0 = s_ring[i].ConvertTimeToTsc( t0 ); t0 = ring.ConvertTimeToTsc( t0 );
if( t0 != 0 ) if( t0 != 0 )
#endif #endif
{ {
auto trace = (uint64_t*)tracy_malloc_fast( ( 1 + cnt ) * sizeof( uint64_t ) ); auto trace = (uint64_t*)tracy_malloc_fast( ( 1 + cnt ) * sizeof( uint64_t ) );
s_ring[i].Read( trace+1, offset, sizeof( uint64_t ) * cnt ); ring.Read( trace+1, offset, sizeof( uint64_t ) * cnt );
#if defined __x86_64__ || defined _M_X64 #if defined __x86_64__ || defined _M_X64
// remove non-canonical pointers // remove non-canonical pointers
@ -1033,12 +1034,12 @@ static void SetupSampling( int64_t& samplingPeriod )
// u64 time // u64 time
uint64_t ip, t0; uint64_t ip, t0;
s_ring[i].Read( &ip, offset, sizeof( uint64_t ) ); ring.Read( &ip, offset, sizeof( uint64_t ) );
offset += sizeof( uint64_t ); offset += sizeof( uint64_t );
s_ring[i].Read( &t0, offset, sizeof( uint64_t ) ); ring.Read( &t0, offset, sizeof( uint64_t ) );
#if defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) #if defined TRACY_HW_TIMER && ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 )
t0 = s_ring[i].ConvertTimeToTsc( t0 ); t0 = ring.ConvertTimeToTsc( t0 );
if( t0 != 0 ) if( t0 != 0 )
#endif #endif
{ {
@ -1078,7 +1079,7 @@ static void SetupSampling( int64_t& samplingPeriod )
pos += hdr.size; pos += hdr.size;
} }
assert( pos == end ); assert( pos == end );
s_ring[i].Advance( end ); ring.Advance( end );
} }
if( !traceActive.load( std::memory_order_relaxed) ) break; if( !traceActive.load( std::memory_order_relaxed) ) break;
if( !hadData ) if( !hadData )