diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2014-03-26 19:21:20 +0000 |
---|---|---|
committer | <> | 2014-05-08 15:03:54 +0000 |
commit | fb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch) | |
tree | c2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/Runtime/common/alloc | |
parent | 58ed4748338f9466599adfc8a9171280ed99e23f (diff) | |
download | VirtualBox-master.tar.gz |
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/Runtime/common/alloc')
-rw-r--r-- | src/VBox/Runtime/common/alloc/alloc.cpp | 2 | ||||
-rw-r--r-- | src/VBox/Runtime/common/alloc/heapoffset.cpp | 2 | ||||
-rw-r--r-- | src/VBox/Runtime/common/alloc/heapsimple.cpp | 2 | ||||
-rw-r--r-- | src/VBox/Runtime/common/alloc/memcache.cpp | 28 |
4 files changed, 15 insertions, 19 deletions
diff --git a/src/VBox/Runtime/common/alloc/alloc.cpp b/src/VBox/Runtime/common/alloc/alloc.cpp index 585a22f6..d4709446 100644 --- a/src/VBox/Runtime/common/alloc/alloc.cpp +++ b/src/VBox/Runtime/common/alloc/alloc.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2011 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/Runtime/common/alloc/heapoffset.cpp b/src/VBox/Runtime/common/alloc/heapoffset.cpp index 2cd8697a..f593b66f 100644 --- a/src/VBox/Runtime/common/alloc/heapoffset.cpp +++ b/src/VBox/Runtime/common/alloc/heapoffset.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2009 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/Runtime/common/alloc/heapsimple.cpp b/src/VBox/Runtime/common/alloc/heapsimple.cpp index 7e680132..015be043 100644 --- a/src/VBox/Runtime/common/alloc/heapsimple.cpp +++ b/src/VBox/Runtime/common/alloc/heapsimple.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2007 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; diff --git a/src/VBox/Runtime/common/alloc/memcache.cpp b/src/VBox/Runtime/common/alloc/memcache.cpp index 57282102..43285e67 100644 --- a/src/VBox/Runtime/common/alloc/memcache.cpp +++ b/src/VBox/Runtime/common/alloc/memcache.cpp @@ -4,7 +4,7 @@ */ /* - * Copyright (C) 2006-2010 Oracle Corporation + * Copyright (C) 2006-2012 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; @@ -122,6 +122,8 @@ typedef struct RTMEMCACHEINT bool fUseFreeList; /** Head of the page list. */ PRTMEMCACHEPAGE pPageHead; + /** Poiner to the insertion point in the page list. */ + PRTMEMCACHEPAGE volatile *ppPageNext; /** Constructor callback. */ PFNMEMCACHECTOR pfnCtor; /** Destructor callback. */ @@ -141,8 +143,8 @@ typedef struct RTMEMCACHEINT * These are marked as used in the allocation bitmaps. * * @todo This doesn't scale well when several threads are beating on the - * cache. Also, it totally doesn't work when we've got a - * constructor/destructor around or the objects are too small. */ + * cache. Also, it totally doesn't work when the objects are too + * small. */ PRTMEMCACHEFREEOBJ volatile pFreeTop; } RTMEMCACHEINT; @@ -209,6 +211,7 @@ RTDECL(int) RTMemCacheCreate(PRTMEMCACHE phMemCache, size_t cbObject, size_t cbA && !pfnCtor && !pfnDtor; pThis->pPageHead = NULL; + pThis->ppPageNext = &pThis->pPageHead; pThis->pfnCtor = pfnCtor; pThis->pfnDtor = pfnDtor; pThis->pvUser = pvUser; @@ -244,7 +247,8 @@ RTDECL(int) RTMemCacheDestroy(RTMEMCACHE hMemCache) return VINF_SUCCESS; AssertPtrReturn(pThis, VERR_INVALID_HANDLE); AssertReturn(pThis->u32Magic == RTMEMCACHE_MAGIC, VERR_INVALID_HANDLE); -#ifdef RT_STRICT + +#if 0 /*def RT_STRICT - don't require eveything to be freed. Caches are very convenient for lazy cleanup. */ uint32_t cFree = pThis->cFree; for (PRTMEMCACHEFREEOBJ pFree = pThis->pFreeTop; pFree && cFree < pThis->cTotal + 5; pFree = pFree->pNext) cFree++; @@ -332,16 +336,9 @@ static int rtMemCacheGrow(RTMEMCACHEINT *pThis) /* Make it the hint. */ ASMAtomicWritePtr(&pThis->pPageHint, pPage); - /* Link the page. */ - PRTMEMCACHEPAGE pPrevPage = pThis->pPageHead; - if (!pPrevPage) - ASMAtomicWritePtr(&pThis->pPageHead, pPage); - else - { - while (pPrevPage->pNext) - pPrevPage = pPrevPage->pNext; - ASMAtomicWritePtr(&pPrevPage->pNext, pPage); - } + /* Link the page in at the end of the list. */ + ASMAtomicWritePtr(pThis->ppPageNext, pPage); + pThis->ppPageNext = &pPage->pNext; /* Add it to the page counts. */ ASMAtomicAddS32(&pThis->cFree, cObjects); @@ -547,8 +544,7 @@ RTDECL(void) RTMemCacheFree(RTMEMCACHE hMemCache, void *pvObj) } else { - /* Note: Do *NOT* attempt to poison the object if we have a constructor - or/and destructor! */ + /* Note: Do *NOT* attempt to poison the object! */ /* * Find the cache page. The page structure is at the start of the page. |