* mudflap cache question
@ 2005-06-14 20:33 Herman ten Brugge
2005-06-15 15:16 ` Frank Ch. Eigler
0 siblings, 1 reply; 2+ messages in thread
From: Herman ten Brugge @ 2005-06-14 20:33 UTC (permalink / raw)
To: gcc
I just read the mudflap pdf file and wanted to know how the cache was
implemented.
I looked at the code in mf-runtime.c and found the cache functions. The
code for the
__mf_uncache_object looks strange to me however.
The code looks like:
static void
__mf_uncache_object (__mf_object_t *old_obj)
{
/* Remove any low/high pointers for this object from the lookup cache. */
/* Can it possibly exist in the cache? */
if (LIKELY (old_obj->read_count + old_obj->write_count))
{
uintptr_t low = old_obj->low;
uintptr_t high = old_obj->high;
unsigned idx_low = __MF_CACHE_INDEX (low);
unsigned idx_high = __MF_CACHE_INDEX (high);
unsigned i;
for (i = idx_low; i <= idx_high; i++)
{
struct __mf_cache *entry = & __mf_lookup_cache [i];
/* NB: the "||" in the following test permits this code to
tolerate the situation introduced by __mf_check over
contiguous objects, where a cache entry spans several
objects. */
if (entry->low == low || entry->high == high)
{
entry->low = MAXPTR;
entry->high = MINPTR;
}
}
}
}
__MF_CACHE_INDEX(ptr) is (ptr >> 2) & 0x3ff at startup.
Suppose we have an old_obj->low of 0x10000 and an old_obj->high of
0x20000. Then the
cache entries we look at is just entry 0. Which I believe is just wrong.
Any pointer
between 0x10000 and 0x20000 must fill other cache entries. It gets even
worse when
the old_obj->low = 0x1fff0 and object high is 0x20000. Then we probably
won't
invalidate any cache entry.
Should I write a bug report?
Herman.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: mudflap cache question
2005-06-14 20:33 mudflap cache question Herman ten Brugge
@ 2005-06-15 15:16 ` Frank Ch. Eigler
0 siblings, 0 replies; 2+ messages in thread
From: Frank Ch. Eigler @ 2005-06-15 15:16 UTC (permalink / raw)
To: Herman ten Brugge; +Cc: gcc
Hi -
Herman ten Brugge <hermantenbrugge@home.nl> writes:
> [...]
> I looked at the code in mf-runtime.c and found the cache
> functions. The code [...]
> __mf_uncache_object (__mf_object_t *old_obj)
> [...]
> unsigned idx_low = __MF_CACHE_INDEX (low);
> unsigned idx_high = __MF_CACHE_INDEX (high);
> for (i = idx_low; i <= idx_high; i++)
> [... check cache slot at index i ...]
> [...]
> __MF_CACHE_INDEX(ptr) is (ptr >> 2) & 0x3ff at startup.
>
> Suppose we have an old_obj->low of 0x10000 and an old_obj->high of
> 0x20000. Then the cache entries we look at is just entry 0. Which I
> believe is just wrong. Any pointer between 0x10000 and 0x20000 must
> fill other cache entries. [...]
You're right, one can't treat this way a data structure that is trying
to be a hash table. Probably this wasn't found before because it
would result in false no-error indications, which are quiet.
> Should I write a bug report?
Not necessary, this is fine. Thank you.
- FChE
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-15 15:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-14 20:33 mudflap cache question Herman ten Brugge
2005-06-15 15:16 ` Frank Ch. Eigler
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).