summaryrefslogtreecommitdiff
path: root/libmudflap/mf-runtime.c
diff options
context:
space:
mode:
authorfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-13 18:27:16 +0000
committerfche <fche@138bc75d-0d04-0410-961f-82ee72b054a4>2004-10-13 18:27:16 +0000
commit0c61ade535e67b7e9bef7265af0a1dc99b0dabf3 (patch)
tree5ba143b308278286023d43a624647837da8e9cbd /libmudflap/mf-runtime.c
parente68ba323fd543681236c6e56702da2e290d30c87 (diff)
downloadgcc-0c61ade535e67b7e9bef7265af0a1dc99b0dabf3.tar.gz
2004-10-12 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Check for more headers, functions. * mf-hooks2.c (mkbuffer, unmkbuffer): New helper functions for tracking overridden FILE buffers. (fopen, setvbuf): New/revised hook functions for buffer overriding. (setbuf,setlinebuf,fdopen,freopen,fopen64,freopen64,fclose): Ditto. (fflush): Accept given NULL stream (means "all streams"). * mf-runtime.h.in: * mf-runtime.c (__mfu_check): Accept accesses that span adjacent HEAP/GUESS objects. (LOOKUP_CACHE_SIZE_MAX): Raise to 64K entries tentatively. (__mf_adapt_cache): Use them all. * testsuite/libmudflap.c/pass35-frag.c: Update warning message. * testsuite/libmudflap.c++/ctors.exp: Ditto. * testsuite/libmudflap.c/{pass51,pass52}-frag.c: New tests. * configure, config.h.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88996 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libmudflap/mf-runtime.c')
-rw-r--r--libmudflap/mf-runtime.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/libmudflap/mf-runtime.c b/libmudflap/mf-runtime.c
index a0f9f739f53..64b1842766c 100644
--- a/libmudflap/mf-runtime.c
+++ b/libmudflap/mf-runtime.c
@@ -160,7 +160,7 @@ static void mfsplay_tree_rebalance (mfsplay_tree sp);
/* Required globals. */
#define LOOKUP_CACHE_MASK_DFL 1023
-#define LOOKUP_CACHE_SIZE_MAX 4096 /* Allows max CACHE_MASK 0x0FFF */
+#define LOOKUP_CACHE_SIZE_MAX 65536 /* Allows max CACHE_MASK 0xFFFF */
#define LOOKUP_CACHE_SHIFT_DFL 2
struct __mf_cache __mf_lookup_cache [LOOKUP_CACHE_SIZE_MAX];
@@ -917,7 +917,7 @@ void __mfu_check (void *ptr, size_t sz, int type, const char *location)
judgement = -1;
}
- /* We now know that the access spans one or more valid objects. */
+ /* We now know that the access spans one or more only valid objects. */
if (LIKELY (judgement >= 0))
for (i = 0; i < obj_count; i++)
{
@@ -931,12 +931,58 @@ void __mfu_check (void *ptr, size_t sz, int type, const char *location)
entry->high = obj->high;
judgement = 1;
}
+ }
+
+ /* This access runs off the end of one valid object. That
+ could be okay, if other valid objects fill in all the
+ holes. We allow this only for HEAP and GUESS type
+ objects. Accesses to STATIC and STACK variables
+ should not be allowed to span. */
+ if (UNLIKELY ((judgement == 0) && (obj_count > 1)))
+ {
+ unsigned uncovered = 0;
+ for (i = 0; i < obj_count; i++)
+ {
+ __mf_object_t *obj = all_ovr_obj[i];
+ int j, uncovered_low_p, uncovered_high_p;
+ uintptr_t ptr_lower, ptr_higher;
+
+ uncovered_low_p = ptr_low < obj->low;
+ ptr_lower = CLAMPSUB (obj->low, 1);
+ uncovered_high_p = ptr_high > obj->high;
+ ptr_higher = CLAMPADD (obj->high, 1);
- /* XXX: Access runs off left or right side of this
- object. That could be okay, if there are
- other objects that fill in all the holes. */
+ for (j = 0; j < obj_count; j++)
+ {
+ __mf_object_t *obj2 = all_ovr_obj[j];
+
+ if (i == j) continue;
+
+ /* Filter out objects that cannot be spanned across. */
+ if (obj2->type == __MF_TYPE_STACK
+ || obj2->type == __MF_TYPE_STATIC)
+ continue;
+
+ /* Consider a side "covered" if obj2 includes
+ the next byte on that side. */
+ if (uncovered_low_p
+ && (ptr_lower >= obj2->low && ptr_lower <= obj2->high))
+ uncovered_low_p = 0;
+ if (uncovered_high_p
+ && (ptr_high >= obj2->low && ptr_higher <= obj2->high))
+ uncovered_high_p = 0;
+ }
+
+ if (uncovered_low_p || uncovered_high_p)
+ uncovered ++;
+ }
+
+ /* Success if no overlapping objects are uncovered. */
+ if (uncovered == 0)
+ judgement = 1;
}
+
if (dealloc_me != NULL)
CALL_REAL (free, dealloc_me);
@@ -1413,7 +1459,7 @@ __mf_adapt_cache ()
cache_utilization += 1.0;
cache_utilization /= (1 + __mf_lc_mask);
- new_mask |= 0x3ff; /* XXX: force a large cache. */
+ new_mask |= 0xffff; /* XXX: force a large cache. */
new_mask &= (LOOKUP_CACHE_SIZE_MAX - 1);
VERBOSE_TRACE ("adapt cache obj=%u/%u sizes=%lu/%.0f/%.0f => "