From: Bart Van Assche Date: Sun, 30 Mar 2008 18:41:07 +0000 (+0000) Subject: Split bm_has_any() into bm_has_any_load() and bm_has_any_store(). X-Git-Tag: svn/VALGRIND_3_4_0~770 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=10fac6a933e16507dc5d439006b2462429e06217;p=thirdparty%2Fvalgrind.git Split bm_has_any() into bm_has_any_load() and bm_has_any_store(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7825 --- diff --git a/exp-drd/drd_bitmap.c b/exp-drd/drd_bitmap.c index 03ed89bc60..097b43d830 100644 --- a/exp-drd/drd_bitmap.c +++ b/exp-drd/drd_bitmap.c @@ -280,22 +280,110 @@ Bool bm_has(const struct bitmap* const bm, const Addr a1, const Addr a2, return True; } -Bool bm_has_any(const struct bitmap* const bm, - const Addr a1, const Addr a2, - const BmAccessTypeT access_type) +Bool bm_has_any_load(const struct bitmap* const bm, + const Addr a1, const Addr a2) { - Addr b; + Addr b, b_next; tl_assert(bm); - for (b = a1; b < a2; b++) + for (b = a1; b < a2; b = b_next) { - if (bm_has_1(bm, b, access_type)) + const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS); + + b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT; + if (b_next > a2) { - return True; + b_next = a2; + } + + if (bm2) + { + Addr b_start; + Addr b_end; + UWord b0; + const struct bitmap1* const p1 = &bm2->bm1; + + if ((bm2->addr << ADDR0_BITS) < a1) + b_start = a1; + else + if ((bm2->addr << ADDR0_BITS) < a2) + b_start = (bm2->addr << ADDR0_BITS); + else + break; + tl_assert(a1 <= b_start && b_start <= a2); + + if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2) + b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT; + else + b_end = a2; + tl_assert(a1 <= b_end && b_end <= a2); + tl_assert(b_start < b_end); + tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK)); + + for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++) + { + if (bm0_is_set(p1->bm0_r, b0)) + { + return True; + } + } } } - return False; + return 0; +} + +Bool bm_has_any_store(const struct bitmap* const bm, + const Addr a1, const Addr a2) +{ + Addr b, b_next; + + tl_assert(bm); + + for (b = a1; b < a2; b = b_next) + { + const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS); + + b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT; + if (b_next > a2) + { + b_next = a2; + } + + if (bm2) + { + Addr b_start; + Addr b_end; + UWord b0; + const struct bitmap1* const p1 = &bm2->bm1; + + if ((bm2->addr << ADDR0_BITS) < a1) + b_start = a1; + else + if ((bm2->addr << ADDR0_BITS) < a2) + b_start = (bm2->addr << ADDR0_BITS); + else + break; + tl_assert(a1 <= b_start && b_start <= a2); + + if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2) + b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT; + else + b_end = a2; + tl_assert(a1 <= b_end && b_end <= a2); + tl_assert(b_start < b_end); + tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK)); + + for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++) + { + if (bm0_is_set(p1->bm0_w, b0)) + { + return True; + } + } + } + } + return 0; } /* Return a non-zero value if there is a read access, write access or both */ diff --git a/exp-drd/drd_suppression.c b/exp-drd/drd_suppression.c index 63c7251d19..a66eca0efc 100644 --- a/exp-drd/drd_suppression.c +++ b/exp-drd/drd_suppression.c @@ -102,7 +102,7 @@ Bool drd_is_suppressed(const Addr a1, const Addr a2) */ Bool drd_is_any_suppressed(const Addr a1, const Addr a2) { - return bm_has_any(s_suppressed, a1, a2, eStore); + return bm_has_any_store(s_suppressed, a1, a2); } void drd_start_tracing_address_range(const Addr a1, const Addr a2) @@ -123,13 +123,13 @@ void drd_stop_tracing_address_range(const Addr a1, const Addr a2) bm_clear_load(s_suppressed, a1, a2); if (g_any_address_traced) { - g_any_address_traced = bm_has_any(s_suppressed, 0, ~(Addr)0, eLoad); + g_any_address_traced = bm_has_any_load(s_suppressed, 0, ~(Addr)0); } } Bool drd_is_any_traced(const Addr a1, const Addr a2) { - return bm_has_any(s_suppressed, a1, a2, eLoad); + return bm_has_any_load(s_suppressed, a1, a2); } void drd_suppression_stop_using_mem(const Addr a1, const Addr a2) diff --git a/exp-drd/pub_drd_bitmap.h b/exp-drd/pub_drd_bitmap.h index 72470ace0a..8bfdeeb504 100644 --- a/exp-drd/pub_drd_bitmap.h +++ b/exp-drd/pub_drd_bitmap.h @@ -71,9 +71,10 @@ void bm_access_range_store(struct bitmap* const bm, Bool bm_has(const struct bitmap* const bm, const Addr a1, const Addr a2, const BmAccessTypeT access_type); -Bool bm_has_any(const struct bitmap* const bm, - const Addr a1, const Addr a2, - const BmAccessTypeT access_type); +Bool bm_has_any_load(const struct bitmap* const bm, + const Addr a1, const Addr a2); +Bool bm_has_any_store(const struct bitmap* const bm, + const Addr a1, const Addr a2); UWord bm_has_any_access(const struct bitmap* const bm, const Addr a1, const Addr a2); UWord bm_has_1(const struct bitmap* const bm,