changeset 4fb4eeb5f412 in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=4fb4eeb5f412
description:
eventq: Clean up some flags
- Make the initialized flag always available, not just in debug mode.
- Make the Initialized flag actually use several bits so it is very
unlikely that something that's uninitialized accidentally looks
initialized.
- Add an initialized() function that tells you if the current event is
indeed initialized.
- Clear the flags on delete so it can't be accidentally thought of as
initialized.
- Fix getFlags assert statement. "How did this ever work?"
diffstat:
2 files changed, 22 insertions(+), 23 deletions(-)
src/sim/eventq.cc | 1 +
src/sim/eventq.hh | 44 +++++++++++++++++++++-----------------------
diffs (106 lines):
diff -r 5c7416199efd -r 4fb4eeb5f412 src/sim/eventq.cc
--- a/src/sim/eventq.cc Fri Apr 02 15:28:21 2010 -0700
+++ b/src/sim/eventq.cc Fri Apr 02 15:28:22 2010 -0700
@@ -60,6 +60,7 @@
Event::~Event()
{
assert(!scheduled());
+ flags = 0;
}
const std::string
diff -r 5c7416199efd -r 4fb4eeb5f412 src/sim/eventq.hh
--- a/src/sim/eventq.hh Fri Apr 02 15:28:21 2010 -0700
+++ b/src/sim/eventq.hh Fri Apr 02 15:28:22 2010 -0700
@@ -68,17 +68,22 @@
typedef short FlagsType;
typedef ::Flags<FlagsType> Flags;
- static const FlagsType PublicRead = 0x003f;
- static const FlagsType PublicWrite = 0x001d;
- static const FlagsType Squashed = 0x0001;
- static const FlagsType Scheduled = 0x0002;
- static const FlagsType AutoDelete = 0x0004;
- static const FlagsType AutoSerialize = 0x0008;
- static const FlagsType IsExitEvent = 0x0010;
- static const FlagsType IsMainQueue = 0x0020;
-#ifdef EVENTQ_DEBUG
- static const FlagsType Initialized = 0xf000;
-#endif
+ static const FlagsType PublicRead = 0x003f; // public readable flags
+ static const FlagsType PublicWrite = 0x001d; // public writable flags
+ static const FlagsType Squashed = 0x0001; // has been squashed
+ static const FlagsType Scheduled = 0x0002; // has been scheduled
+ static const FlagsType AutoDelete = 0x0004; // delete after dispatch
+ static const FlagsType AutoSerialize = 0x0008; // must be serialized
+ static const FlagsType IsExitEvent = 0x0010; // special exit event
+ static const FlagsType IsMainQueue = 0x0020; // on main event queue
+ static const FlagsType Initialized = 0x7a40; // somewhat random bits
+ static const FlagsType InitMask = 0xffc0; // mask for init bits
+
+ bool
+ initialized() const
+ {
+ return this && (flags & InitMask) == Initialized;
+ }
public:
typedef int8_t Priority;
@@ -146,7 +151,7 @@
Flags
getFlags(Flags _flags) const
{
- assert(flags.noneSet(~PublicRead));
+ assert(_flags.noneSet(~PublicRead));
return flags.isSet(_flags);
}
@@ -242,14 +247,13 @@
* @param queue that the event gets scheduled on
*/
Event(Priority p = Default_Pri)
- : nextBin(NULL), nextInBin(NULL), _priority(p)
+ : nextBin(NULL), nextInBin(NULL), _priority(p), flags(Initialized)
{
#ifndef NDEBUG
instance = ++instanceCounter;
queue = NULL;
#endif
#ifdef EVENTQ_DEBUG
- flags.set(Initialized);
whenCreated = curTick;
whenScheduled = 0;
#endif
@@ -478,9 +482,7 @@
{
assert((UTick)when >= (UTick)curTick);
assert(!event->scheduled());
-#ifdef EVENTQ_DEBUG
- assert((event->flags & Event::Initialized) == Event::Initialized);
-#endif
+ assert(event->initialized());
event->setWhen(when, this);
insert(event);
@@ -498,9 +500,7 @@
EventQueue::deschedule(Event *event)
{
assert(event->scheduled());
-#ifdef EVENTQ_DEBUG
- assert((event->flags & Event::Initialized) == Event::Initialized);
-#endif
+ assert(event->initialized());
remove(event);
@@ -519,9 +519,7 @@
{
assert(when >= curTick);
assert(always || event->scheduled());
-#ifdef EVENTQ_DEBUG
- assert((event->flags & Event::Initialized) == Event::Initialized);
-#endif
+ assert(event->initialized());
if (event->scheduled())
remove(event);
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev