|
From: <sv...@va...> - 2008-03-23 18:50:30
|
Author: bart
Date: 2008-03-23 18:50:32 +0000 (Sun, 23 Mar 2008)
New Revision: 7766
Log:
Bitmap lookup cache is now really four elements in size.
Modified:
branches/DRDDEV/exp-drd/drd_bitmap.h
Modified: branches/DRDDEV/exp-drd/drd_bitmap.h
===================================================================
--- branches/DRDDEV/exp-drd/drd_bitmap.h 2008-03-23 18:12:24 UTC (rev 7765)
+++ branches/DRDDEV/exp-drd/drd_bitmap.h 2008-03-23 18:50:32 UTC (rev 7766)
@@ -210,6 +210,49 @@
#endif
static __inline__
+struct bitmap2* bm_cache_lookup(const struct bitmap* const bm, const UWord a1)
+{
+ tl_assert(bm);
+
+#if N_CACHE_ELEM > 8
+#error Please update the code below.
+#endif
+#if N_CACHE_ELEM >= 1
+ if (a1 == bm->cache[0].a1)
+ return bm->cache[0].bm2;
+#endif
+#if N_CACHE_ELEM >= 2
+ if (a1 == bm->cache[1].a1)
+ return bm->cache[1].bm2;
+#endif
+#if N_CACHE_ELEM >= 3
+ if (a1 == bm->cache[2].a1)
+ return bm->cache[2].bm2;
+#endif
+#if N_CACHE_ELEM >= 4
+ if (a1 == bm->cache[3].a1)
+ return bm->cache[3].bm2;
+#endif
+#if N_CACHE_ELEM >= 5
+ if (a1 == bm->cache[4].a1)
+ return bm->cache[4].bm2;
+#endif
+#if N_CACHE_ELEM >= 6
+ if (a1 == bm->cache[5].a1)
+ return bm->cache[5].bm2;
+#endif
+#if N_CACHE_ELEM >= 7
+ if (a1 == bm->cache[6].a1)
+ return bm->cache[6].bm2;
+#endif
+#if N_CACHE_ELEM >= 8
+ if (a1 == bm->cache[7].a1)
+ return bm->cache[7].bm2;
+#endif
+ return 0;
+}
+
+static __inline__
void bm_update_cache(struct bitmap* const bm,
const UWord a1,
struct bitmap2* const bm2)
@@ -220,25 +263,25 @@
#error Please update the code below.
#endif
#if N_CACHE_ELEM >= 8
- bm->cache[7] = bm->cache[6];
+ bm->cache[7] = bm->cache[6];
#endif
#if N_CACHE_ELEM >= 7
- bm->cache[6] = bm->cache[5];
+ bm->cache[6] = bm->cache[5];
#endif
#if N_CACHE_ELEM >= 6
- bm->cache[5] = bm->cache[4];
+ bm->cache[5] = bm->cache[4];
#endif
#if N_CACHE_ELEM >= 5
- bm->cache[4] = bm->cache[3];
+ bm->cache[4] = bm->cache[3];
#endif
#if N_CACHE_ELEM >= 4
- bm->cache[3] = bm->cache[2];
+ bm->cache[3] = bm->cache[2];
#endif
#if N_CACHE_ELEM >= 3
- bm->cache[2] = bm->cache[1];
+ bm->cache[2] = bm->cache[1];
#endif
#if N_CACHE_ELEM >= 2
- bm->cache[1] = bm->cache[0];
+ bm->cache[1] = bm->cache[0];
#endif
bm->cache[0].a1 = a1;
bm->cache[0].bm2 = bm2;
@@ -289,22 +332,14 @@
struct bitmap2* bm2;
bm2ref = 0;
- if (bm->cache[0].a1 == a1)
+ bm2 = bm_cache_lookup(bm, a1);
+ if (bm2)
{
- bm2 = bm->cache[0].bm2;
if (bm2->refcnt > 1)
{
bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
}
}
- else if (bm->cache[1].a1 == a1)
- {
- bm2 = bm->cache[1].bm2;
- if (bm2->refcnt > 1)
- {
- bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
- }
- }
else
{
bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
@@ -390,16 +425,9 @@
tl_assert(bm);
tl_assert(a1);
- if (a1 == bm->cache[0].a1)
+ bm2 = bm_cache_lookup(bm, a1);
+ if (bm2 == 0)
{
- bm2 = bm->cache[0].bm2;
- }
- else if (a1 == bm->cache[1].a1)
- {
- bm2 = bm->cache[1].bm2;
- }
- else
- {
bm2ref = VG_(OSetGen_Lookup)(bm->oset, &a1);
if (bm2ref)
{
|