summaryrefslogtreecommitdiff
path: root/src/vm/cachelinealloc.h
diff options
context:
space:
mode:
authordotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
committerdotnet-bot <dotnet-bot@microsoft.com>2015-01-30 14:14:42 -0800
commitef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch)
treedee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/vm/cachelinealloc.h
downloadcoreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2
coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/vm/cachelinealloc.h')
-rw-r--r--src/vm/cachelinealloc.h147
1 files changed, 147 insertions, 0 deletions
diff --git a/src/vm/cachelinealloc.h b/src/vm/cachelinealloc.h
new file mode 100644
index 0000000000..d2184f7174
--- /dev/null
+++ b/src/vm/cachelinealloc.h
@@ -0,0 +1,147 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+//---------------------------------------------------------------------------
+// CCacheLineAllocator
+//
+
+//
+// @doc
+// @module cachelineAlloc.h
+//
+// This file defines the CacheLine Allocator class.
+//
+// @comm
+//
+//
+// <nl> Definitions.:
+// <nl> Class Name Header file
+// <nl> --------------------------- ---------------
+// <nl> <c CCacheLineAllocator> BAlloc.h
+//
+// <nl><nl>
+// Notes:
+// The CacheLineAllocator maintains a pool of free CacheLines
+//
+// The CacheLine Allocator provides static member functions
+// GetCacheLine and FreeCacheLine,
+//
+// <nl><nl>
+//
+//---------------------------------------------------------------------------
+
+#ifndef _H_CACHELINE_ALLOCATOR_
+#define _H_CACHELINE_ALLOCATOR_
+
+#include "slist.h"
+
+#include <pshpack1.h>
+
+class CacheLine
+{
+public:
+ enum
+ {
+ numEntries = 15,
+ numValidBytes = numEntries * sizeof(void *)
+ };
+
+ // store next pointer and the entries
+ SLink m_Link;
+ union
+ {
+ void* m_pAddr[numEntries];
+ BYTE m_xxx[numValidBytes];
+ };
+
+ // init
+ void Init32()
+ {
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ // initialize cacheline
+ memset(&m_Link,0,32);
+ }
+
+ void Init64()
+ {
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ // initialize cacheline
+ memset(&m_Link,0,64);
+ }
+
+ CacheLine()
+ {
+ CONTRACTL
+ {
+ NOTHROW;
+ GC_NOTRIGGER;
+ MODE_ANY;
+ }
+ CONTRACTL_END;
+
+ // initialize cacheline
+ memset(&m_Link,0,sizeof(CacheLine));
+ }
+};
+#include <poppack.h>
+
+typedef CacheLine* LPCacheLine;
+
+/////////////////////////////////////////////////////////
+// class CCacheLineAllocator
+// Handles Allocation/DeAllocation of cache lines
+// used for hash table overflow buckets
+///////////////////////////////////////////////////////
+class CCacheLineAllocator
+{
+ typedef SList<CacheLine, true> REGISTRYLIST;
+ typedef SList<CacheLine, true> FREELIST32;
+ typedef SList<CacheLine, true> FREELIST64;
+
+public:
+
+ //constructor
+ CCacheLineAllocator ();
+ //destructor
+ ~CCacheLineAllocator ();
+
+ // free cacheline blocks
+ FREELIST32 m_freeList32; //32 byte
+ FREELIST64 m_freeList64; //64 byte
+
+ // registry for virtual free
+ REGISTRYLIST m_registryList;
+
+ void *VAlloc(ULONG cbSize);
+
+ void VFree(void* pv);
+
+ // GetCacheLine,
+ void * GetCacheLine32();
+
+ // GetCacheLine,
+ void * GetCacheLine64();
+
+ // FreeCacheLine,
+ void FreeCacheLine32(void *pCacheLine);
+
+ // FreeCacheLine,
+ void FreeCacheLine64(void *pCacheLine);
+
+};
+#endif