From 355dc6bef40b705a3299edee15ab39f64e6f9f5b Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 1 Jan 2010 17:09:23 +0000 Subject: [PATCH] Inlined several VMCache methods. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34837 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/vm/VMCache.h | 98 ++++++++++++++++++++++++----- src/system/kernel/vm/VMCache.cpp | 39 ------------ 2 files changed, 83 insertions(+), 54 deletions(-) diff --git a/headers/private/kernel/vm/VMCache.h b/headers/private/kernel/vm/VMCache.h index 6ea7de38c8..3a916d42f7 100644 --- a/headers/private/kernel/vm/VMCache.h +++ b/headers/private/kernel/vm/VMCache.h @@ -10,6 +10,7 @@ #define _KERNEL_VM_VM_CACHE_H +#include #include #include #include @@ -69,23 +70,17 @@ public: virtual void Delete(); - bool Lock() - { return mutex_lock(&fLock) == B_OK; } - bool TryLock() - { return mutex_trylock(&fLock) == B_OK; } - bool SwitchLock(mutex* from) - { return mutex_switch_lock(from, &fLock) - == B_OK; } + inline bool Lock(); + inline bool TryLock(); + inline bool SwitchLock(mutex* from); void Unlock(); - void AssertLocked() - { ASSERT_LOCKED_MUTEX(&fLock); } + inline void AssertLocked(); - void AcquireRefLocked(); - void AcquireRef(); - void ReleaseRefLocked(); - void ReleaseRef(); - void ReleaseRefAndUnlock() - { ReleaseRefLocked(); Unlock(); } + inline void AcquireRefLocked(); + inline void AcquireRef(); + inline void ReleaseRefLocked(); + inline void ReleaseRef(); + inline void ReleaseRefAndUnlock(); void WaitForPageEvents(vm_page* page, uint32 events, bool relock); @@ -203,6 +198,79 @@ public: }; + +bool +VMCache::Lock() +{ + return mutex_lock(&fLock) == B_OK; +} + + +bool +VMCache::TryLock() +{ + return mutex_trylock(&fLock) == B_OK; +} + + +bool +VMCache::SwitchLock(mutex* from) +{ + return mutex_switch_lock(from, &fLock) == B_OK; +} + + +void +VMCache::AssertLocked() +{ + ASSERT_LOCKED_MUTEX(&fLock); +} + + +void +VMCache::AcquireRefLocked() +{ + ASSERT_LOCKED_MUTEX(&fLock); + + fRefCount++; +} + + +void +VMCache::AcquireRef() +{ + Lock(); + fRefCount++; + Unlock(); +} + + +void +VMCache::ReleaseRefLocked() +{ + ASSERT_LOCKED_MUTEX(&fLock); + + fRefCount--; +} + + +void +VMCache::ReleaseRef() +{ + Lock(); + fRefCount--; + Unlock(); +} + + +void +VMCache::ReleaseRefAndUnlock() +{ + ReleaseRefLocked(); + Unlock(); +} + + #ifdef __cplusplus extern "C" { #endif diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index b10e13cd58..5eb6f2c299 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -679,44 +678,6 @@ VMCache::Unlock() } -void -VMCache::AcquireRefLocked() -{ -// TODO: Inline! - ASSERT_LOCKED_MUTEX(&fLock); - - fRefCount++; -} - - -void -VMCache::AcquireRef() -{ - Lock(); - fRefCount++; - Unlock(); -} - - -void -VMCache::ReleaseRefLocked() -{ -// TODO: Inline! - ASSERT_LOCKED_MUTEX(&fLock); - - fRefCount--; -} - - -void -VMCache::ReleaseRef() -{ - Lock(); - fRefCount--; - Unlock(); -} - - vm_page* VMCache::LookupPage(off_t offset) {