|
From: Jeremy F. <je...@go...> - 2005-02-04 23:33:07
|
CVS commit by fitzhardinge:
Clarify and explain the logic behind the PROT_NONE-shadow memory
optimisation.
M +6 -1 addrcheck/ac_main.c 1.74
M +2 -2 memcheck/mac_shared.h 1.30
M +6 -1 memcheck/mc_main.c 1.60
--- valgrind/addrcheck/ac_main.c #1.73:1.74
@@ -323,5 +323,10 @@ void set_address_range_perms ( Addr a, S
for (; len >= 8; a += 8, len -= 8) {
PROF_EVENT(32);
- if (abyte8 == VGM_BYTE_INVALID && !IS_MAPPABLE(a))
+
+ /* If we're setting the addressability to "invalid", and the
+ secondary map is the distinguished_secondary_map, don't
+ allocate a new secondary map, since the distinguished map is
+ all-invalid anyway. */
+ if (abyte8 == VGM_BYTE_INVALID && IS_DISTINGUISHED(a))
continue;
ENSURE_MAPPABLE(a, "set_address_range_perms(fast)");
--- valgrind/memcheck/mac_shared.h #1.29:1.30
@@ -196,9 +196,9 @@ extern UInt MAC_(event_ctr)[N_PROF_EVENT
((smap) == &distinguished_secondary_map)
-#define IS_MAPPABLE(addr) (!(IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])))
+#define IS_DISTINGUISHED(addr) (IS_DISTINGUISHED_SM(primary_map[(addr) >> 16]))
#define ENSURE_MAPPABLE(addr,caller) \
do { \
- if (IS_DISTINGUISHED_SM(primary_map[(addr) >> 16])) { \
+ if (IS_DISTINGUISHED(addr)) { \
primary_map[(addr) >> 16] = alloc_secondary_map(caller); \
/* VG_(printf)("new 2map because of %p\n", addr); */ \
--- valgrind/memcheck/mc_main.c #1.59:1.60
@@ -353,5 +353,10 @@ static void set_address_range_perms ( Ad
for (; len >= 8; a += 8, len -= 8) {
PROF_EVENT(32);
- if (abyte8 == VGM_BYTE_INVALID && !IS_MAPPABLE(a))
+
+ /* If we're setting the addressability to "invalid", and the
+ secondary map is the distinguished_secondary_map, don't
+ allocate a new secondary map, since the distinguished map is
+ all-invalid anyway. */
+ if (abyte8 == VGM_BYTE_INVALID && IS_DISTINGUISHED(a))
continue;
ENSURE_MAPPABLE(a, "set_address_range_perms(fast)");
|