From fa9aeeb3b14e68d2becc8091e219f6c092561240 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Mon, 14 Dec 2009 09:46:04 +0100 Subject: [PATCH] RemotePlugin: added branch prediction hints Added some branch prediction hints, especially to ShmFifo locking functions. --- include/RemotePlugin.h | 14 +++++++------- src/core/RemotePlugin.cpp | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/include/RemotePlugin.h b/include/RemotePlugin.h index 12ad00026..b4c112ef1 100644 --- a/include/RemotePlugin.h +++ b/include/RemotePlugin.h @@ -284,7 +284,7 @@ public: // recursive lock inline void lock() { - if( !isInvalid() && ++m_lockDepth == 1 ) + if( likely( !isInvalid() && ++m_lockDepth == 1 ) ) { #ifdef USE_QT_SEMAPHORES m_dataSem.acquire(); @@ -297,9 +297,9 @@ public: // recursive unlock inline void unlock() { - if( m_lockDepth > 0 ) + if( likely( m_lockDepth > 0 ) ) { - if( --m_lockDepth == 0 ) + if( likely( --m_lockDepth == 0 ) ) { #ifdef USE_QT_SEMAPHORES m_dataSem.release(); @@ -313,7 +313,7 @@ public: // wait until message-semaphore is available inline void waitForMessage() { - if( !isInvalid() ) + if( likely( !isInvalid() ) ) { #ifdef USE_QT_SEMAPHORES m_messageSem.acquire(); @@ -372,7 +372,7 @@ public: inline bool messagesLeft() { - if( isInvalid() ) + if( unlikely( isInvalid() ) ) { return false; } @@ -748,7 +748,7 @@ public: inline void lock() { - if( !isInvalid() ) + if( likely( !isInvalid() ) ) { m_commMutex.lock(); } @@ -756,7 +756,7 @@ public: inline void unlock() { - if( !isInvalid() ) + if( likely( !isInvalid() ) ) { m_commMutex.unlock(); } diff --git a/src/core/RemotePlugin.cpp b/src/core/RemotePlugin.cpp index a711d27cd..b60e386c8 100644 --- a/src/core/RemotePlugin.cpp +++ b/src/core/RemotePlugin.cpp @@ -150,7 +150,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, { const fpp_t frames = engine::getMixer()->framesPerPeriod(); - if( m_failed || !isRunning() ) + if( unlikely( m_failed || !isRunning() ) ) { if( _out_buf != NULL ) { @@ -160,7 +160,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, return false; } - if( m_shm == NULL ) + if( unlikely( m_shm == NULL ) ) { // m_shm being zero means we didn't initialize everything so // far so process one message each time (and hope we get @@ -227,8 +227,7 @@ bool RemotePlugin::process( const sampleFrame * _in_buf, waitForMessage( IdProcessingDone ); unlock(); - const ch_cnt_t outputs = qMin( m_outputCount, - DEFAULT_CHANNELS ); + const ch_cnt_t outputs = qMin( m_outputCount, DEFAULT_CHANNELS ); if( m_splitChannels ) { for( ch_cnt_t ch = 0; ch < outputs; ++ch ) @@ -328,7 +327,7 @@ void RemotePlugin::resizeSharedProcessingMemory() bool RemotePlugin::processMessage( const message & _m ) { lock(); - message reply_message( _m.id ); + message replyMessage( _m.id ); bool reply = false; switch( _m.id ) { @@ -341,12 +340,12 @@ bool RemotePlugin::processMessage( const message & _m ) case IdSampleRateInformation: reply = true; - reply_message.addInt( engine::getMixer()->processingSampleRate() ); + replyMessage.addInt( engine::getMixer()->processingSampleRate() ); break; case IdBufferSizeInformation: reply = true; - reply_message.addInt( engine::getMixer()->framesPerPeriod() ); + replyMessage.addInt( engine::getMixer()->framesPerPeriod() ); break; case IdChangeInputCount: @@ -371,7 +370,7 @@ bool RemotePlugin::processMessage( const message & _m ) } if( reply ) { - sendMessage( reply_message ); + sendMessage( replyMessage ); } unlock();