[CPU] - skip some operations that cost precious time in mutex lock/unlock that are called frequently for some gains when not debugging
This commit is contained in:
parent
b2c37c26ce
commit
99ff1c9b19
|
@ -55,26 +55,32 @@ Memory* PPCFrontend::memory() const { return processor_->memory(); }
|
||||||
// Checks the state of the global lock and sets scratch to the current MSR
|
// Checks the state of the global lock and sets scratch to the current MSR
|
||||||
// value.
|
// value.
|
||||||
void CheckGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
void CheckGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
||||||
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
|
||||||
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
||||||
std::lock_guard<std::recursive_mutex> lock(*global_mutex);
|
#ifdef _DEBUG
|
||||||
|
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
||||||
|
std::lock_guard<std::recursive_mutex> lock(*global_mutex);
|
||||||
|
#endif
|
||||||
ppc_context->scratch = *global_lock_count ? 0 : 0x8000;
|
ppc_context->scratch = *global_lock_count ? 0 : 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enters the global lock. Safe to recursion.
|
// Enters the global lock. Safe to recursion.
|
||||||
void EnterGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
void EnterGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
||||||
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
||||||
|
#ifdef _DEBUG
|
||||||
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
||||||
global_mutex->lock();
|
|
||||||
xe::atomic_inc(global_lock_count);
|
xe::atomic_inc(global_lock_count);
|
||||||
|
#endif
|
||||||
|
global_mutex->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leaves the global lock. Safe to recursion.
|
// Leaves the global lock. Safe to recursion.
|
||||||
void LeaveGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
void LeaveGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
|
||||||
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
auto global_mutex = reinterpret_cast<std::recursive_mutex*>(arg0);
|
||||||
|
#ifdef _DEBUG
|
||||||
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
|
||||||
auto new_lock_count = xe::atomic_dec(global_lock_count);
|
auto new_lock_count = xe::atomic_dec(global_lock_count);
|
||||||
assert_true(new_lock_count >= 0);
|
assert_true(new_lock_count >= 0);
|
||||||
|
#endif
|
||||||
global_mutex->unlock();
|
global_mutex->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue