mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Use just sign bit to check end value validity.
This commit is contained in:
parent
9420234a98
commit
54a767bf81
@ -161,6 +161,7 @@ struct ZoneEvent
|
|||||||
tracy_force_inline void SetStart( int64_t start ) { assert( start < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_start_srcloc)+2, &start, 4 ); memcpy( ((char*)&_start_srcloc)+6, ((char*)&start)+4, 2 ); }
|
tracy_force_inline void SetStart( int64_t start ) { assert( start < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_start_srcloc)+2, &start, 4 ); memcpy( ((char*)&_start_srcloc)+6, ((char*)&start)+4, 2 ); }
|
||||||
tracy_force_inline int64_t End() const { return int64_t( _end_child1 ) >> 16; }
|
tracy_force_inline int64_t End() const { return int64_t( _end_child1 ) >> 16; }
|
||||||
tracy_force_inline void SetEnd( int64_t end ) { assert( end < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_end_child1)+2, &end, 4 ); memcpy( ((char*)&_end_child1)+6, ((char*)&end)+4, 2 ); }
|
tracy_force_inline void SetEnd( int64_t end ) { assert( end < (int64_t)( 1ull << 47 ) ); memcpy( ((char*)&_end_child1)+2, &end, 4 ); memcpy( ((char*)&_end_child1)+6, ((char*)&end)+4, 2 ); }
|
||||||
|
tracy_force_inline bool IsEndValid() const { return ( _end_child1 >> 63 ) == 0; }
|
||||||
tracy_force_inline int16_t SrcLoc() const { return int16_t( _start_srcloc & 0xFFFF ); }
|
tracy_force_inline int16_t SrcLoc() const { return int16_t( _start_srcloc & 0xFFFF ); }
|
||||||
tracy_force_inline void SetSrcLoc( int16_t srcloc ) { memcpy( &_start_srcloc, &srcloc, 2 ); }
|
tracy_force_inline void SetSrcLoc( int16_t srcloc ) { memcpy( &_start_srcloc, &srcloc, 2 ); }
|
||||||
tracy_force_inline int32_t Child() const { return int32_t( uint32_t( _end_child1 & 0xFFFF ) | ( uint32_t( _child2 ) << 16 ) ); }
|
tracy_force_inline int32_t Child() const { return int32_t( uint32_t( _end_child1 & 0xFFFF ) | ( uint32_t( _child2 ) << 16 ) ); }
|
||||||
|
@ -3175,7 +3175,7 @@ int View::DrawZoneLevel( const V& vec, bool hover, double pxns, int64_t nspx, co
|
|||||||
const auto zitend = std::lower_bound( it, vec.end(), m_vd.zvEnd + resolution, [] ( const auto& l, const auto& r ) { Adapter a; return a(l).Start() < r; } );
|
const auto zitend = std::lower_bound( it, vec.end(), m_vd.zvEnd + resolution, [] ( const auto& l, const auto& r ) { Adapter a; return a(l).Start() < r; } );
|
||||||
if( it == zitend ) return depth;
|
if( it == zitend ) return depth;
|
||||||
Adapter a;
|
Adapter a;
|
||||||
if( a(*it).End() < 0 && m_worker.GetZoneEnd( a(*it) ) < m_vd.zvStart ) return depth;
|
if( !a(*it).IsEndValid() && m_worker.GetZoneEnd( a(*it) ) < m_vd.zvStart ) return depth;
|
||||||
|
|
||||||
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
const auto w = ImGui::GetWindowContentRegionWidth() - 1;
|
||||||
const auto ty = ImGui::GetFontSize();
|
const auto ty = ImGui::GetFontSize();
|
||||||
@ -6328,7 +6328,7 @@ void View::DrawZoneInfoWindow()
|
|||||||
if( m_timeDist.dataValidFor != &ev )
|
if( m_timeDist.dataValidFor != &ev )
|
||||||
{
|
{
|
||||||
m_timeDist.data.clear();
|
m_timeDist.data.clear();
|
||||||
if( ev.End() >= 0 ) m_timeDist.dataValidFor = &ev;
|
if( ev.IsEndValid() ) m_timeDist.dataValidFor = &ev;
|
||||||
|
|
||||||
if( m_timeDist.runningTime )
|
if( m_timeDist.runningTime )
|
||||||
{
|
{
|
||||||
@ -8189,7 +8189,7 @@ void View::DrawFindZone()
|
|||||||
for( i=m_findZone.sortedNum; i<zsz; i++ )
|
for( i=m_findZone.sortedNum; i<zsz; i++ )
|
||||||
{
|
{
|
||||||
auto& zone = *zones[i].Zone();
|
auto& zone = *zones[i].Zone();
|
||||||
if( zone.End() < 0 ) break;
|
if( !zone.IsEndValid() ) break;
|
||||||
const auto ctx = m_worker.GetContextSwitchData( m_worker.DecompressThread( zones[i].Thread() ) );
|
const auto ctx = m_worker.GetContextSwitchData( m_worker.DecompressThread( zones[i].Thread() ) );
|
||||||
if( !ctx ) break;
|
if( !ctx ) break;
|
||||||
int64_t t;
|
int64_t t;
|
||||||
@ -9138,7 +9138,7 @@ void View::DrawFindZone()
|
|||||||
while( zptr < zend )
|
while( zptr < zend )
|
||||||
{
|
{
|
||||||
auto& ev = *zptr;
|
auto& ev = *zptr;
|
||||||
if( ev.Zone()->End() < 0 ) break;
|
if( !ev.Zone()->IsEndValid() ) break;
|
||||||
|
|
||||||
const auto end = m_worker.GetZoneEndDirect( *ev.Zone() );
|
const auto end = m_worker.GetZoneEndDirect( *ev.Zone() );
|
||||||
const auto start = ev.Zone()->Start();
|
const auto start = ev.Zone()->Start();
|
||||||
@ -9993,7 +9993,7 @@ void View::DrawCompare()
|
|||||||
for( i=m_compare.sortedNum[k]; i<zsz[k]; i++ )
|
for( i=m_compare.sortedNum[k]; i<zsz[k]; i++ )
|
||||||
{
|
{
|
||||||
auto& zone = *zones[i].Zone();
|
auto& zone = *zones[i].Zone();
|
||||||
if( zone.End() < 0 ) break;
|
if( !zone.IsEndValid() ) break;
|
||||||
const auto t = zone.End() - zone.Start();
|
const auto t = zone.End() - zone.Start();
|
||||||
vec.emplace_back( t );
|
vec.emplace_back( t );
|
||||||
total += t;
|
total += t;
|
||||||
@ -14040,7 +14040,7 @@ int View::GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const
|
|||||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||||
if( it != vec->begin() ) --it;
|
if( it != vec->begin() ) --it;
|
||||||
assert( !( zone.End() >= 0 && it->Start() > zone.End() ) );
|
assert( !( zone.IsEndValid() && it->Start() > zone.End() ) );
|
||||||
if( it == &zone ) return depth;
|
if( it == &zone ) return depth;
|
||||||
assert( it->Child() >= 0 );
|
assert( it->Child() >= 0 );
|
||||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||||
@ -14050,7 +14050,7 @@ int View::GetZoneDepth( const ZoneEvent& zone, uint64_t tid ) const
|
|||||||
{
|
{
|
||||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||||
if( it != timeline->begin() ) --it;
|
if( it != timeline->begin() ) --it;
|
||||||
assert( !( zone.End() >= 0 && (*it)->Start() > zone.End() ) );
|
assert( !( zone.IsEndValid() && (*it)->Start() > zone.End() ) );
|
||||||
if( *it == &zone ) return depth;
|
if( *it == &zone ) return depth;
|
||||||
assert( (*it)->Child() >= 0 );
|
assert( (*it)->Child() >= 0 );
|
||||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||||
@ -14073,7 +14073,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
|||||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||||
if( it != vec->begin() ) --it;
|
if( it != vec->begin() ) --it;
|
||||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && it->Start() > zone.End() ) break;
|
||||||
if( it == &zone ) return parent;
|
if( it == &zone ) return parent;
|
||||||
if( it->Child() < 0 ) break;
|
if( it->Child() < 0 ) break;
|
||||||
parent = it;
|
parent = it;
|
||||||
@ -14083,7 +14083,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone ) const
|
|||||||
{
|
{
|
||||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||||
if( it != timeline->begin() ) --it;
|
if( it != timeline->begin() ) --it;
|
||||||
if( zone.End() >= 0 && (*it)->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && (*it)->Start() > zone.End() ) break;
|
||||||
if( *it == &zone ) return parent;
|
if( *it == &zone ) return parent;
|
||||||
if( (*it)->Child() < 0 ) break;
|
if( (*it)->Child() < 0 ) break;
|
||||||
parent = *it;
|
parent = *it;
|
||||||
@ -14107,7 +14107,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) cons
|
|||||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||||
if( it != vec->begin() ) --it;
|
if( it != vec->begin() ) --it;
|
||||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && it->Start() > zone.End() ) break;
|
||||||
if( it == &zone ) return parent;
|
if( it == &zone ) return parent;
|
||||||
if( it->Child() < 0 ) break;
|
if( it->Child() < 0 ) break;
|
||||||
parent = it;
|
parent = it;
|
||||||
@ -14117,7 +14117,7 @@ const ZoneEvent* View::GetZoneParent( const ZoneEvent& zone, uint64_t tid ) cons
|
|||||||
{
|
{
|
||||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||||
if( it != timeline->begin() ) --it;
|
if( it != timeline->begin() ) --it;
|
||||||
if( zone.End() >= 0 && (*it)->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && (*it)->Start() > zone.End() ) break;
|
||||||
if( *it == &zone ) return parent;
|
if( *it == &zone ) return parent;
|
||||||
if( (*it)->Child() < 0 ) break;
|
if( (*it)->Child() < 0 ) break;
|
||||||
parent = *it;
|
parent = *it;
|
||||||
@ -14178,7 +14178,7 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const
|
|||||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||||
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
auto it = std::upper_bound( vec->begin(), vec->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||||
if( it != vec->begin() ) --it;
|
if( it != vec->begin() ) --it;
|
||||||
if( zone.End() >= 0 && it->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && it->Start() > zone.End() ) break;
|
||||||
if( it == &zone ) return thread;
|
if( it == &zone ) return thread;
|
||||||
if( it->Child() < 0 ) break;
|
if( it->Child() < 0 ) break;
|
||||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||||
@ -14187,7 +14187,7 @@ const ThreadData* View::GetZoneThreadData( const ZoneEvent& zone ) const
|
|||||||
{
|
{
|
||||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
auto it = std::upper_bound( timeline->begin(), timeline->end(), zone.Start(), [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||||
if( it != timeline->begin() ) --it;
|
if( it != timeline->begin() ) --it;
|
||||||
if( zone.End() >= 0 && (*it)->Start() > zone.End() ) break;
|
if( zone.IsEndValid() && (*it)->Start() > zone.End() ) break;
|
||||||
if( *it == &zone ) return thread;
|
if( *it == &zone ) return thread;
|
||||||
if( (*it)->Child() < 0 ) break;
|
if( (*it)->Child() < 0 ) break;
|
||||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||||
@ -14302,7 +14302,7 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
|
|||||||
auto vec = (Vector<ZoneEvent>*)timeline;
|
auto vec = (Vector<ZoneEvent>*)timeline;
|
||||||
auto it = std::upper_bound( vec->begin(), vec->end(), time, [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
auto it = std::upper_bound( vec->begin(), vec->end(), time, [] ( const auto& l, const auto& r ) { return l < r.Start(); } );
|
||||||
if( it != vec->begin() ) --it;
|
if( it != vec->begin() ) --it;
|
||||||
if( it->Start() > time || ( it->End() >= 0 && it->End() < time ) ) return ret;
|
if( it->Start() > time || ( it->IsEndValid() && it->End() < time ) ) return ret;
|
||||||
ret = it;
|
ret = it;
|
||||||
if( it->Child() < 0 ) return ret;
|
if( it->Child() < 0 ) return ret;
|
||||||
timeline = &m_worker.GetZoneChildren( it->Child() );
|
timeline = &m_worker.GetZoneChildren( it->Child() );
|
||||||
@ -14311,7 +14311,7 @@ const ZoneEvent* View::FindZoneAtTime( uint64_t thread, int64_t time ) const
|
|||||||
{
|
{
|
||||||
auto it = std::upper_bound( timeline->begin(), timeline->end(), time, [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
auto it = std::upper_bound( timeline->begin(), timeline->end(), time, [] ( const auto& l, const auto& r ) { return l < r->Start(); } );
|
||||||
if( it != timeline->begin() ) --it;
|
if( it != timeline->begin() ) --it;
|
||||||
if( (*it)->Start() > time || ( (*it)->End() >= 0 && (*it)->End() < time ) ) return ret;
|
if( (*it)->Start() > time || ( (*it)->IsEndValid() && (*it)->End() < time ) ) return ret;
|
||||||
ret = *it;
|
ret = *it;
|
||||||
if( (*it)->Child() < 0 ) return ret;
|
if( (*it)->Child() < 0 ) return ret;
|
||||||
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
timeline = &m_worker.GetZoneChildren( (*it)->Child() );
|
||||||
@ -14513,7 +14513,7 @@ int64_t View::GetZoneChildTimeFast( const ZoneEvent& zone )
|
|||||||
auto& vec = *(Vector<ZoneEvent>*)&children;
|
auto& vec = *(Vector<ZoneEvent>*)&children;
|
||||||
for( auto& v : vec )
|
for( auto& v : vec )
|
||||||
{
|
{
|
||||||
assert( v.End() >= 0 );
|
assert( v.IsEndValid() );
|
||||||
time += v.End() - v.Start();
|
time += v.End() - v.Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14521,7 +14521,7 @@ int64_t View::GetZoneChildTimeFast( const ZoneEvent& zone )
|
|||||||
{
|
{
|
||||||
for( auto& v : children )
|
for( auto& v : children )
|
||||||
{
|
{
|
||||||
assert( v->End() >= 0 );
|
assert( v->IsEndValid() );
|
||||||
time += v->End() - v->Start();
|
time += v->End() - v->Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14535,7 +14535,7 @@ int64_t View::GetZoneSelfTime( const ZoneEvent& zone )
|
|||||||
if( m_cache.zoneSelfTime2.first == &zone ) return m_cache.zoneSelfTime2.second;
|
if( m_cache.zoneSelfTime2.first == &zone ) return m_cache.zoneSelfTime2.second;
|
||||||
const auto ztime = m_worker.GetZoneEnd( zone ) - zone.Start();
|
const auto ztime = m_worker.GetZoneEnd( zone ) - zone.Start();
|
||||||
const auto selftime = ztime - GetZoneChildTime( zone );
|
const auto selftime = ztime - GetZoneChildTime( zone );
|
||||||
if( zone.End() >= 0 )
|
if( zone.IsEndValid() )
|
||||||
{
|
{
|
||||||
m_cache.zoneSelfTime2 = m_cache.zoneSelfTime;
|
m_cache.zoneSelfTime2 = m_cache.zoneSelfTime;
|
||||||
m_cache.zoneSelfTime = std::make_pair( &zone, selftime );
|
m_cache.zoneSelfTime = std::make_pair( &zone, selftime );
|
||||||
|
@ -1892,7 +1892,7 @@ int64_t Worker::GetZoneEnd( const ZoneEvent& ev )
|
|||||||
auto ptr = &ev;
|
auto ptr = &ev;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if( ptr->End() >= 0 ) return ptr->End();
|
if( ptr->IsEndValid() ) return ptr->End();
|
||||||
if( ptr->Child() < 0 ) return ptr->Start();
|
if( ptr->Child() < 0 ) return ptr->Start();
|
||||||
auto& children = GetZoneChildren( ptr->Child() );
|
auto& children = GetZoneChildren( ptr->Child() );
|
||||||
if( children.is_magic() )
|
if( children.is_magic() )
|
||||||
@ -5056,7 +5056,7 @@ void Worker::ReconstructZoneStatistics( ZoneEvent& zone, uint16_t thread )
|
|||||||
ztd.SetZone( &zone );
|
ztd.SetZone( &zone );
|
||||||
ztd.SetThread( thread );
|
ztd.SetThread( thread );
|
||||||
|
|
||||||
if( zone.End() >= 0 )
|
if( zone.IsEndValid() )
|
||||||
{
|
{
|
||||||
auto timeSpan = zone.End() - zone.Start();
|
auto timeSpan = zone.End() - zone.Start();
|
||||||
if( timeSpan > 0 )
|
if( timeSpan > 0 )
|
||||||
|
Loading…
Reference in New Issue
Block a user