Revert "Save one byte on ContextSwitchData."

Counting bits is hard, let's go shopping.
This commit is contained in:
Bartosz Taudul 2019-08-14 13:53:25 +02:00
parent 3996516fce
commit 0bb0c10e3c
3 changed files with 12 additions and 14 deletions

View File

@ -222,13 +222,11 @@ enum { CrashEventSize = sizeof( CrashEvent ) };
struct ContextSwitchData
{
static uint8_t Reason( const ContextSwitchData& cs ) { return cs.data & 0xF; }
static uint8_t State( const ContextSwitchData& cs ) { return cs.data >> 4; }
int64_t start;
int64_t end;
uint8_t cpu;
uint8_t data;
int8_t reason;
int8_t state;
};
enum { ContextSwitchDataSize = sizeof( ContextSwitchData ) };

View File

@ -2349,12 +2349,12 @@ void View::DrawContextSwitches( const ContextSwitch* ctx, bool hover, double pxn
{
TextFocused( "CPU:", RealToString( ev.cpu, true ) );
}
TextFocused( "Wait reason:", DecodeContextSwitchReasonCode( ContextSwitchData::Reason( *pit ) ) );
TextFocused( "Wait reason:", DecodeContextSwitchReasonCode( pit->reason ) );
ImGui::SameLine();
TextDisabledUnformatted( DecodeContextSwitchReason( ContextSwitchData::Reason( *pit ) ) );
TextFocused( "Wait state:", DecodeContextSwitchStateCode( ContextSwitchData::State( *pit ) ) );
TextDisabledUnformatted( DecodeContextSwitchReason( pit->reason ) );
TextFocused( "Wait state:", DecodeContextSwitchStateCode( pit->state ) );
ImGui::SameLine();
TextDisabledUnformatted( DecodeContextSwitchState( ContextSwitchData::State( *pit ) ) );
TextDisabledUnformatted( DecodeContextSwitchState( pit->state ) );
ImGui::EndTooltip();
if( ImGui::IsMouseClicked( 2 ) )

View File

@ -1167,7 +1167,7 @@ Worker::Worker( FileRead& f, EventType::Type eventMask )
{
ptr->start = ReadTimeOffset( f, refTime );
ptr->end = ReadTimeOffset( f, refTime );
f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->data ) );
f.Read( &ptr->cpu, sizeof( ptr->cpu ) + sizeof( ptr->reason ) + sizeof( ptr->state ) );
ptr++;
}
m_data.ctxSwitch.emplace( thread, data );
@ -3726,9 +3726,8 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
auto& item = data.back();
assert( item.start <= time );
item.end = time;
assert( ( ev.reason & 0xF ) == ev.reason );
assert( ( ev.state & 0xF ) == ev.state );
item.data = ev.reason | ( ev.state << 4 );
item.reason = ev.reason;
item.state = ev.state;
}
}
if( ev.newThread != 0 )
@ -3745,7 +3744,8 @@ void Worker::ProcessContextSwitch( const QueueContextSwitch& ev )
item.start = time;
item.end = -1;
item.cpu = ev.cpu;
item.data = ~0;
item.reason = -1;
item.state = -1;
}
}
@ -4496,7 +4496,7 @@ void Worker::Write( FileWrite& f )
{
WriteTimeOffset( f, refTime, cs.start );
WriteTimeOffset( f, refTime, cs.end );
f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.data ) );
f.Write( &cs.cpu, sizeof( cs.cpu ) + sizeof( cs.reason ) + sizeof( cs.state ) );
}
}
}