summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpu/simple_cpu/simple_cpu.cc4
-rw-r--r--dev/etherlink.cc2
-rw-r--r--dev/etherlink.hh4
-rw-r--r--sim/eventq.cc54
-rw-r--r--sim/eventq.hh32
-rw-r--r--sim/serialize.cc28
-rw-r--r--sim/serialize.hh12
-rw-r--r--sim/sim_object.cc2
-rw-r--r--sim/sim_object.hh5
9 files changed, 55 insertions, 88 deletions
diff --git a/cpu/simple_cpu/simple_cpu.cc b/cpu/simple_cpu/simple_cpu.cc
index 519a8cd4d..60d704604 100644
--- a/cpu/simple_cpu/simple_cpu.cc
+++ b/cpu/simple_cpu/simple_cpu.cc
@@ -76,7 +76,7 @@
using namespace std;
SimpleCPU::TickEvent::TickEvent(SimpleCPU *c)
- : Event(&mainEventQueue, "SimpleCPU::TickEvent", 100), cpu(c)
+ : Event(&mainEventQueue, 100), cpu(c)
{
}
@@ -94,7 +94,7 @@ SimpleCPU::TickEvent::description()
SimpleCPU::CacheCompletionEvent::CacheCompletionEvent(SimpleCPU *_cpu)
- : Event(&mainEventQueue, "SimpleCPU::CacheCompletionEvent"),
+ : Event(&mainEventQueue),
cpu(_cpu)
{
}
diff --git a/dev/etherlink.cc b/dev/etherlink.cc
index 40fa65d6f..6fb7187d2 100644
--- a/dev/etherlink.cc
+++ b/dev/etherlink.cc
@@ -80,7 +80,7 @@ EtherLink::Interface::Interface(const std::string &name, Link *tx, Link *rx)
}
EtherLink::Link::Link(const std::string &name, double rate, EtherDump *d)
- : Serializeable(name), txint(NULL), rxint(NULL), ticks_per_byte(rate),
+ : objName(name), txint(NULL), rxint(NULL), ticks_per_byte(rate),
dump(d), event(&mainEventQueue, this)
{}
diff --git a/dev/etherlink.hh b/dev/etherlink.hh
index a88fe24df..ea7bdcbcc 100644
--- a/dev/etherlink.hh
+++ b/dev/etherlink.hh
@@ -54,6 +54,8 @@ class EtherLink : public SimObject
*/
class Link : public Serializeable {
protected:
+ std::string objName;
+
Interface *txint;
Interface *rxint;
@@ -87,6 +89,8 @@ class EtherLink : public SimObject
Link(const std::string &name, double rate, EtherDump *dump);
~Link() {}
+ virtual std::string name() const { return objName; }
+
bool busy() const { return (bool)packet; }
bool transmit(PacketPtr packet);
diff --git a/sim/eventq.cc b/sim/eventq.cc
index ef813eb13..eab499bd9 100644
--- a/sim/eventq.cc
+++ b/sim/eventq.cc
@@ -150,55 +150,53 @@ Event::unserialize(Checkpoint *cp, const string &section)
}
}
-
-void
-EventQueue::nameChildren()
-{
- int numEvents = 0;
- Event *event = head;
- while (event) {
- if (event->getFlags(Event::AutoSerialize)) {
- event->setName(csprintf("%s.event%d", name(), numEvents++));
- }
- event = event->next;
- }
-
- numAutoSerializeEvents = numEvents;
-}
-
void
EventQueue::serialize(ostream &os)
{
- // should have been set by a preceding call to nameChildren()
- assert(numAutoSerializeEvents >= 0);
-
- SERIALIZE_SCALAR(numAutoSerializeEvents);
+ std::list<Event *> eventPtrs;
int numEvents = 0;
Event *event = head;
while (event) {
if (event->getFlags(Event::AutoSerialize)) {
- event->nameOut(os);
- event->serialize(os);
+ eventPtrs.push_back(event);
numEvents++;
}
event = event->next;
}
- assert(numEvents == numAutoSerializeEvents);
-}
+ SERIALIZE_SCALAR(numEvents);
+ int i = 0;
+ for (std::list<Event *>::iterator it=eventPtrs.begin();
+ it != eventPtrs.end(); ++it) {
+ paramOut(os, csprintf("%s.eventPtr%d", name(), i++), (uintptr_t)*it);
+ }
+
+ for (std::list<Event *>::iterator it=eventPtrs.begin();
+ it != eventPtrs.end(); ++it) {
+ (*it)->nameOut(os);
+ (*it)->serialize(os);
+ }
+}
void
EventQueue::unserialize(Checkpoint *cp, const std::string &section)
{
- UNSERIALIZE_SCALAR(numAutoSerializeEvents);
- for (int eventNum = 0; eventNum < numAutoSerializeEvents; ++eventNum) {
- Serializeable::create(cp, csprintf("%s.event%d", section, eventNum));
+ int numEvents;
+ uintptr_t ptr;
+
+ UNSERIALIZE_SCALAR(numEvents);
+
+ for (int i = 0; i < numEvents; i++) {
+ // get the pointer value associated with the event
+ paramIn(cp, section, csprintf("%s.eventPtr%d", name(), i), ptr);
+
+ // create the event based on its pointer value
+ Serializeable::create(cp, csprintf("%s_%x", Event::defaultName, ptr));
}
}
-
void
EventQueue::dump()
{
diff --git a/sim/eventq.hh b/sim/eventq.hh
index 11bfe3a4e..ddf4c3198 100644
--- a/sim/eventq.hh
+++ b/sim/eventq.hh
@@ -104,22 +104,7 @@ class Event : public Serializeable, public FastAlloc
* @param queue that the event gets scheduled on
*/
Event(EventQueue *q, int p = 0)
- : Serializeable(defaultName), queue(q), next(NULL),
- _priority(p), _flags(None),
-#if TRACING_ON
- when_created(curTick), when_scheduled(0),
-#endif
- annotated_value(0)
- {
- }
-
- /*
- * Event constructor
- * @param queue that the event gets scheduled on
- */
- Event(EventQueue *q, std::string _name, int p = 0)
- : Serializeable(_name), queue(q), next(NULL),
- _priority(p), _flags(None),
+ : queue(q), next(NULL), _priority(p), _flags(None),
#if TRACING_ON
when_created(curTick), when_scheduled(0),
#endif
@@ -129,6 +114,10 @@ class Event : public Serializeable, public FastAlloc
~Event() {}
+ virtual std::string name() const {
+ return csprintf("%s_%x", defaultName, (uintptr_t)this);
+ }
+
/// Determine if the current event is scheduled
bool scheduled() const { return getFlags(Scheduled); }
@@ -219,12 +208,12 @@ DelayFunction(Tick when, T *object)
*/
class EventQueue : public Serializeable
{
+ protected:
+ std::string objName;
+
private:
Event *head;
- // only used to hold value between nameChildren() and serialize()
- int numAutoSerializeEvents;
-
void insert(Event *event);
void remove(Event *event);
@@ -232,9 +221,11 @@ class EventQueue : public Serializeable
// constructor
EventQueue(const std::string &n)
- : Serializeable(n), head(NULL), numAutoSerializeEvents(-1)
+ : objName(n), head(NULL)
{}
+ virtual std::string name() const { return objName; }
+
// schedule the given event on this queue
void schedule(Event *ev);
void deschedule(Event *ev);
@@ -266,7 +257,6 @@ class EventQueue : public Serializeable
Tick nextEventTime() { return empty() ? curTick : head->when(); }
- virtual void nameChildren();
virtual void serialize(std::ostream &os);
virtual void unserialize(Checkpoint *cp, const std::string &section);
};
diff --git a/sim/serialize.cc b/sim/serialize.cc
index dfd495a32..84d400e16 100644
--- a/sim/serialize.cc
+++ b/sim/serialize.cc
@@ -49,8 +49,8 @@ using namespace std;
Serializer *Serializeable::serializer = NULL;
-Serializeable::Serializeable(const string &n)
- : objName(n), serialized(false)
+Serializeable::Serializeable()
+ : serialized(false)
{ }
Serializeable::~Serializeable()
@@ -209,16 +209,6 @@ Serializeable::childOut(const string &name, Serializeable *child)
}
#endif
-void
-Serializeable::setName(const string &name)
-{
- if (objName != "") {
- cprintf("Renaming object '%s' to '%s'.\n", objName, name);
- }
-
- objName = name;
-}
-
Serializer::Serializer()
{ }
@@ -272,20 +262,6 @@ Serializer::serialize(const string &f)
add_objects();
while (!objects.empty()) {
- Serializeable *serial = objects.front();
- DPRINTF(Serialize, "Naming children of %s\n", serial->name());
- serial->nameChildren();
- objects.pop_front();
- list.push_back(serial);
- }
-
- while (!list.empty()) {
- list.front()->serialized = false;
- list.pop_front();
- }
-
- add_objects();
- while (!objects.empty()) {
Serializeable *obj = objects.front();
DPRINTF(Serialize, "Serializing %s\n", obj->name());
obj->nameOut(out());
diff --git a/sim/serialize.hh b/sim/serialize.hh
index b615e6527..a8fff7b6f 100644
--- a/sim/serialize.hh
+++ b/sim/serialize.hh
@@ -107,9 +107,6 @@ class Serializeable
friend class Serializer;
protected:
- // object name: should be unique
- std::string objName;
-
bool serialized;
static Serializer *serializer;
@@ -118,15 +115,12 @@ class Serializeable
void nameOut(std::ostream& os, const std::string &_name);
public:
- Serializeable(const std::string &n);
+ Serializeable();
virtual ~Serializeable();
- void setName(const std::string &name);
-
- // return name
- const std::string &name() const { return objName; }
+ // manditory virtual function, so objects must provide names
+ virtual std::string name() const = 0;
- virtual void nameChildren() {}
virtual void serialize(std::ostream& os) {}
virtual void unserialize(Checkpoint *cp, const std::string &section) {}
diff --git a/sim/sim_object.cc b/sim/sim_object.cc
index 1ddb15c82..af6a258ff 100644
--- a/sim/sim_object.cc
+++ b/sim/sim_object.cc
@@ -54,7 +54,7 @@ SimObject::SimObjectList SimObject::simObjectList;
// SimObject constructor: used to maintain static simObjectList
//
SimObject::SimObject(const string &_name)
- : Serializeable(_name)
+ : objName(_name)
{
simObjectList.push_back(this);
}
diff --git a/sim/sim_object.hh b/sim/sim_object.hh
index 20da07164..1a365651b 100644
--- a/sim/sim_object.hh
+++ b/sim/sim_object.hh
@@ -47,6 +47,9 @@
*/
class SimObject : public Serializeable
{
+ protected:
+ std::string objName;
+
private:
friend class Serializer;
@@ -60,6 +63,8 @@ class SimObject : public Serializeable
virtual ~SimObject() {}
+ virtual std::string name() const { return objName; }
+
// register statistics for this object
virtual void regStats();
virtual void regFormulas();