summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sim/eventq.cc49
-rw-r--r--src/sim/eventq.hh14
-rw-r--r--src/sim/serialize.cc71
-rw-r--r--src/sim/serialize.hh48
4 files changed, 8 insertions, 174 deletions
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index 48664f8e8..604de4a71 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -283,55 +283,6 @@ Event::unserialize(CheckpointIn &cp)
}
void
-EventQueue::serialize(CheckpointOut &cp) const
-{
- std::list<Event *> eventPtrs;
-
- int numEvents = 0;
- Event *nextBin = head;
- while (nextBin) {
- Event *nextInBin = nextBin;
-
- while (nextInBin) {
- if (nextInBin->flags.isSet(Event::AutoSerialize)) {
- eventPtrs.push_back(nextInBin);
- paramOut(cp, csprintf("event%d", numEvents++),
- nextInBin->name());
- }
- nextInBin = nextInBin->nextInBin;
- }
-
- nextBin = nextBin->nextBin;
- }
-
- SERIALIZE_SCALAR(numEvents);
-
- for (Event *ev : eventPtrs)
- ev->serializeSection(cp, ev->name());
-}
-
-void
-EventQueue::unserialize(CheckpointIn &cp)
-{
- int numEvents;
- UNSERIALIZE_SCALAR(numEvents);
-
- std::string eventName;
- for (int i = 0; i < numEvents; i++) {
- // get the pointer value associated with the event
- paramIn(cp, csprintf("event%d", i), eventName);
-
- // create the event based on its pointer value
- Serializable *obj(Serializable::create(cp, eventName));
- Event *event(dynamic_cast<Event *>(obj));
- fatal_if(!event,
- "Event queue unserialized something that wasn't an event.\n");
-
- checkpointReschedule(event);
- }
-}
-
-void
EventQueue::checkpointReschedule(Event *event)
{
// It's safe to call insert() directly here since this method
diff --git a/src/sim/eventq.hh b/src/sim/eventq.hh
index a73e4b9dc..db134a4be 100644
--- a/src/sim/eventq.hh
+++ b/src/sim/eventq.hh
@@ -104,7 +104,12 @@ class EventBase
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
+ /**
+ * This used to be AutoSerialize. This value can't be reused
+ * without changing the checkpoint version since the flag field
+ * gets serialized.
+ */
+ static const FlagsType Reserved0 = 0x0008;
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
@@ -437,7 +442,7 @@ operator!=(const Event &l, const Event &r)
* otherwise they risk being scheduled in the past by
* handleAsyncInsertions().
*/
-class EventQueue : public Serializable
+class EventQueue
{
private:
std::string objName;
@@ -643,11 +648,6 @@ class EventQueue : public Serializable
void unlock() { service_mutex.unlock(); }
/**@}*/
-#ifndef SWIG
- void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
- void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
-#endif
-
/**
* Reschedule an event after a checkpoint.
*
diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc
index b74b4bc9d..3127d9a04 100644
--- a/src/sim/serialize.cc
+++ b/src/sim/serialize.cc
@@ -445,15 +445,12 @@ void
Globals::serialize(CheckpointOut &cp) const
{
paramOut(cp, "curTick", curTick());
- paramOut(cp, "numMainEventQueues", numMainEventQueues);
-
}
void
Globals::unserialize(CheckpointIn &cp)
{
paramIn(cp, "curTick", unserializedCurTick);
- paramIn(cp, "numMainEventQueues", numMainEventQueues);
}
Serializable::Serializable()
@@ -500,8 +497,6 @@ Serializable::serializeAll(const string &cpt_dir)
outstream << "## checkpoint generated: " << ctime(&t);
globals.serializeSection(outstream, "Globals");
- for (uint32_t i = 0; i < numMainEventQueues; ++i)
- mainEventQueue[i]->serializeSection(outstream, "MainEventQueue");
SimObject::serializeAll(outstream);
}
@@ -511,10 +506,8 @@ Serializable::unserializeGlobals(CheckpointIn &cp)
{
globals.unserializeSection(cp, "Globals");
- for (uint32_t i = 0; i < numMainEventQueues; ++i) {
+ for (uint32_t i = 0; i < numMainEventQueues; ++i)
mainEventQueue[i]->setCurTick(globals.unserializedCurTick);
- mainEventQueue[i]->unserializeSection(cp, "MainEventQueue");
- }
}
Serializable::ScopedCheckpointSection::~ScopedCheckpointSection()
@@ -549,59 +542,6 @@ debug_serialize(const string &cpt_dir)
Serializable::serializeAll(cpt_dir);
}
-
-////////////////////////////////////////////////////////////////////////
-//
-// SerializableClass member definitions
-//
-////////////////////////////////////////////////////////////////////////
-
-// Map of class names to SerializableBuilder creation functions.
-// Need to make this a pointer so we can force initialization on the
-// first reference; otherwise, some SerializableClass constructors
-// may be invoked before the classMap constructor.
-map<string, SerializableClass::CreateFunc> *SerializableClass::classMap = 0;
-
-// SerializableClass constructor: add mapping to classMap
-SerializableClass::SerializableClass(const string &className,
- CreateFunc createFunc)
-{
- if (classMap == NULL)
- classMap = new map<string, SerializableClass::CreateFunc>();
-
- if ((*classMap)[className])
- fatal("Error: simulation object class %s redefined\n", className);
-
- // add className --> createFunc to class map
- (*classMap)[className] = createFunc;
-}
-
-//
-//
-Serializable *
-SerializableClass::createObject(CheckpointIn &cp, const string &section)
-{
- string className;
-
- if (!cp.find(section, "type", className)) {
- fatal("Serializable::create: no 'type' entry in section '%s'.\n",
- section);
- }
-
- CreateFunc createFunc = (*classMap)[className];
-
- if (createFunc == NULL) {
- fatal("Serializable::create: no create function for class '%s'.\n",
- className);
- }
-
- Serializable *object = createFunc(cp, section);
-
- assert(object != NULL);
-
- return object;
-}
-
const std::string &
Serializable::currentSection()
{
@@ -610,15 +550,6 @@ Serializable::currentSection()
return path.top();
}
-Serializable *
-Serializable::create(CheckpointIn &cp, const string &section)
-{
- Serializable *object = SerializableClass::createObject(cp, section);
- object->unserializeSection(cp, section);
- return object;
-}
-
-
const char *CheckpointIn::baseFilename = "m5.cpt";
string CheckpointIn::currentDirectory;
diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh
index 4eff2af40..561cd5508 100644
--- a/src/sim/serialize.hh
+++ b/src/sim/serialize.hh
@@ -350,8 +350,6 @@ class Serializable
/** Get the fully-qualified name of the active section */
static const std::string &currentSection();
- static Serializable *create(CheckpointIn &cp, const std::string &section);
-
static int ckptCount;
static int ckptMaxCount;
static int ckptPrevCount;
@@ -364,52 +362,6 @@ class Serializable
void debug_serialize(const std::string &cpt_dir);
-//
-// An instance of SerializableClass corresponds to a class derived from
-// Serializable. The SerializableClass instance serves to bind the string
-// name (found in the config file) to a function that creates an
-// instance of the appropriate derived class.
-//
-// This would be much cleaner in Smalltalk or Objective-C, where types
-// are first-class objects themselves.
-//
-class SerializableClass
-{
- public:
-
- // Type CreateFunc is a pointer to a function that creates a new
- // simulation object builder based on a .ini-file parameter
- // section (specified by the first string argument), a unique name
- // for the object (specified by the second string argument), and
- // an optional config hierarchy node (specified by the third
- // argument). A pointer to the new SerializableBuilder is returned.
- typedef Serializable *(*CreateFunc)(CheckpointIn &cp,
- const std::string &section);
-
- static std::map<std::string,CreateFunc> *classMap;
-
- // Constructor. For example:
- //
- // SerializableClass baseCacheSerializableClass("BaseCacheSerializable",
- // newBaseCacheSerializableBuilder);
- //
- SerializableClass(const std::string &className, CreateFunc createFunc);
-
- // create Serializable given name of class and pointer to
- // configuration hierarchy node
- static Serializable *createObject(CheckpointIn &cp,
- const std::string &section);
-};
-
-//
-// Macros to encapsulate the magic of declaring & defining
-// SerializableBuilder and SerializableClass objects
-//
-
-#define REGISTER_SERIALIZEABLE(CLASS_NAME, OBJ_CLASS) \
-SerializableClass the##OBJ_CLASS##Class(CLASS_NAME, \
- OBJ_CLASS::createForUnserialize);
-
class CheckpointIn
{