[patch] Better checking for cache line state
"Dave Brolley" <[email protected]>
| Newsgroups | gmane.comp.emulators.sid.devel |
|---|---|
| Organization | Red Hat Canada |
| Message-ID | <[email protected]> |
Hi, On the target I'm working on, the programmer can directly write into the cache tags. This requires more vigilance regarding the state of the cache tags. Specifically, we should check the result of valid_p () before using the tag. I've committed the attached patch. Dave
sid-cache.patch.txt
(text/plain, 1.2 KB)
Index: sid/component/cache/cacheutil.cxx
===================================================================
RCS file: /cvs/src/src/sid/component/cache/cacheutil.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -c -p -r1.8 -r1.9
*** sid/component/cache/cacheutil.cxx 29 Apr 2004 20:26:08 -0000 1.8
--- sid/component/cache/cacheutil.cxx 10 May 2004 21:51:10 -0000 1.9
*************** cache_set::find_any_dirty ()
*** 189,195 ****
for (iterator_t it = lines.begin (); it != lines.end (); it++)
{
cache_line* i = * it;
! if (i->dirty_p ()) return i;
}
return 0;
--- 189,195 ----
for (iterator_t it = lines.begin (); it != lines.end (); it++)
{
cache_line* i = * it;
! if (i->valid_p () && i->dirty_p ()) return i;
}
return 0;
*************** bool
*** 206,212 ****
cache_set::vacancy_p () const
{
for (const_iterator_t it = lines.begin (); it != lines.end (); it++)
! if (!(*it)->locked_p ())
return true;
return false;
--- 206,212 ----
cache_set::vacancy_p () const
{
for (const_iterator_t it = lines.begin (); it != lines.end (); it++)
! if (!(*it)->valid_p () || !(*it)->locked_p ())
return true;
return false;