From: Bart Van Assche Date: Thu, 23 Apr 2009 19:23:09 +0000 (+0000) Subject: Simplified bm_clear* implementations. X-Git-Tag: svn/VALGRIND_3_5_0~794 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb26e59f1531b531a4915e9efc1ae6a0728c630f;p=thirdparty%2Fvalgrind.git Simplified bm_clear* implementations. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9594 --- diff --git a/drd/drd_bitmap.c b/drd/drd_bitmap.c index a2215d2573..f4c098912a 100644 --- a/drd/drd_bitmap.c +++ b/drd/drd_bitmap.c @@ -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. */ diff --git a/drd/drd_bitmap.h b/drd/drd_bitmap.h index 993487378d..1689435df4 100644 --- a/drd/drd_bitmap.h +++ b/drd/drd_bitmap.h @@ -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. *