]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Simplified bm_clear* implementations.
authorBart Van Assche <bvanassche@acm.org>
Thu, 23 Apr 2009 19:23:09 +0000 (19:23 +0000)
committerBart Van Assche <bvanassche@acm.org>
Thu, 23 Apr 2009 19:23:09 +0000 (19:23 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9594

drd/drd_bitmap.c
drd/drd_bitmap.h

index a2215d257385c39a71f9436e30afd1754e59be5f..f4c098912a0026f0a2f1ff72369535d6988af00d 100644 (file)
@@ -459,9 +459,14 @@ void DRD_(bm_clear)(struct bitmap* const bm, const Addr a1, const Addr a2)
    tl_assert(a1);
    tl_assert(a1 <= a2);
 
+#if 0
+   if (a2 - a1 >= ADDR0_COUNT)
+      VG_(message)(Vg_DebugMsg, "bm_clear(bm = %p, a1 = 0x%lx, a2 = 0x%lx, delta = 0x%lx",
+                   bm, a1, a2, a2 - a1);
+#endif
+
    for (b = a1; b < a2; b = b_next)
    {
-      struct bitmap2ref* p2ref;
       struct bitmap2* p2;
       Addr c;
 
@@ -469,23 +474,7 @@ void DRD_(bm_clear)(struct bitmap* const bm, const Addr a1, const Addr a2)
       tl_assert(a1 <= b && b < a2);
 #endif
 
-      p2ref = bm2_lookup_next_exclusive(bm, b >> ADDR0_BITS);
-      if (p2ref == 0)
-        break;
-
-      p2 = p2ref->bm2;
-
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(p2ref->addr >= (b >> ADDR0_BITS));
-#endif
-      b = p2ref->addr << ADDR0_BITS;
-      if (b < a1)
-         b = a1;
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(a1 <= b);
-#endif
-      if (b >= a2)
-         break;
+      p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
 
       b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
       if (b_next > a2)
@@ -493,6 +482,9 @@ void DRD_(bm_clear)(struct bitmap* const bm, const Addr a1, const Addr a2)
          b_next = a2;
       }
 
+      if (p2 == 0)
+         continue;
+
       c = b;
       /* If the first address in the bitmap that must be cleared does not */
       /* start on an UWord boundary, start clearing the first addresses.  */
@@ -545,9 +537,14 @@ void DRD_(bm_clear_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
    tl_assert(a1);
    tl_assert(a1 <= a2);
 
+#if 0
+   if (a2 - a1 >= ADDR0_COUNT)
+      VG_(message)(Vg_DebugMsg, "bm_clear_load(bm = %p, a1 = 0x%lx, a2 = 0x%lx, delta = 0x%lx",
+                   bm, a1, a2, a2 - a1);
+#endif
+
    for (b = a1; b < a2; b = b_next)
    {
-      struct bitmap2ref* p2ref;
       struct bitmap2* p2;
       Addr c;
 
@@ -555,23 +552,7 @@ void DRD_(bm_clear_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
       tl_assert(a1 <= b && b < a2);
 #endif
 
-      p2ref = bm2_lookup_next_exclusive(bm, b >> ADDR0_BITS);
-      if (p2ref == 0)
-        break;
-
-      p2 = p2ref->bm2;
-
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(p2ref->addr >= (b >> ADDR0_BITS));
-#endif
-      b = p2ref->addr << ADDR0_BITS;
-      if (b < a1)
-         b = a1;
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(a1 <= b);
-#endif
-      if (b >= a2)
-         break;
+      p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
 
       b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
       if (b_next > a2)
@@ -579,6 +560,9 @@ void DRD_(bm_clear_load)(struct bitmap* const bm, const Addr a1, const Addr a2)
          b_next = a2;
       }
 
+      if (p2 == 0)
+         continue;
+
       c = b;
       /* If the first address in the bitmap that must be cleared does not */
       /* start on an UWord boundary, start clearing the first addresses.  */
@@ -642,9 +626,14 @@ void DRD_(bm_clear_store)(struct bitmap* const bm,
    tl_assert(a1);
    tl_assert(a1 <= a2);
 
+#if 0
+   if (a2 - a1 >= ADDR0_COUNT)
+      VG_(message)(Vg_DebugMsg, "bm_clear_store(bm = %p, a1 = 0x%lx, a2 = 0x%lx, delta = 0x%lx",
+                   bm, a1, a2, a2 - a1);
+#endif
+
    for (b = a1; b < a2; b = b_next)
    {
-      struct bitmap2ref* p2ref;
       struct bitmap2* p2;
       Addr c;
 
@@ -652,23 +641,7 @@ void DRD_(bm_clear_store)(struct bitmap* const bm,
       tl_assert(a1 <= b && b < a2);
 #endif
 
-      p2ref = bm2_lookup_next_exclusive(bm, b >> ADDR0_BITS);
-      if (p2ref == 0)
-        break;
-
-      p2 = p2ref->bm2;
-
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(p2ref->addr >= (b >> ADDR0_BITS));
-#endif
-      b = p2ref->addr << ADDR0_BITS;
-      if (b < a1)
-         b = a1;
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-      tl_assert(a1 <= b);
-#endif
-      if (b >= a2)
-         break;
+      p2 = bm2_lookup_exclusive(bm, b >> ADDR0_BITS);
 
       b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
       if (b_next > a2)
@@ -676,6 +649,9 @@ void DRD_(bm_clear_store)(struct bitmap* const bm,
        b_next = a2;
       }
 
+      if (p2 == 0)
+         continue;
+
       c = b;
       /* If the first address in the bitmap that must be cleared does not */
       /* start on an UWord boundary, start clearing the first addresses.  */
index 993487378d6ffccb492fbdc7f966d75ba7a2cf21..1689435df4e80c049f3a6bf77513fc6617a99b71 100644 (file)
@@ -428,41 +428,6 @@ bm2_lookup_exclusive(struct bitmap* const bm, const UWord a1)
    return bm2;
 }
 
-/** Look up the first address in bitmap bm that is greater than or equal to
- *  a1 and return a pointer to a second level bitmap that is not shared and
- *  hence may be modified.
- *
- *  @param a1 client address shifted right by ADDR0_BITS.
- *  @param bm bitmap pointer.
- */
-static __inline__
-struct bitmap2ref*
-bm2_lookup_next_exclusive(struct bitmap* const bm, const UWord a1)
-{
-   struct bitmap2ref* bm2ref;
-   struct bitmap2* bm2;
-
-   bm2ref = 0;
-   bm2 = 0;
-
-   VG_(OSetGen_ResetIterAt)(bm->oset, &a1);
-   bm2ref = VG_(OSetGen_Next)(bm->oset);
-
-   if (bm2ref)
-   {
-      bm2 = bm2ref->bm2;
-      if (bm2->refcnt > 1)
-      {
-#ifdef ENABLE_DRD_CONSISTENCY_CHECKS
-        tl_assert(bm2ref);
-#endif
-        bm2 = bm2_make_exclusive(*(struct bitmap**)&bm, bm2ref);
-      }
-   }
-
-   return bm2ref;
-}
-
 /** Look up the address a1 in bitmap bm. The returned second level bitmap has
  *  reference count one and hence may be modified.
  *