summaryrefslogtreecommitdiff
path: root/src/mem/ruby/buffers
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2010-06-10 23:17:06 -0700
committerNathan Binkert <nate@binkert.org>2010-06-10 23:17:06 -0700
commitbc87fa30d72df7db6265be50b2c39dc218076f9f (patch)
tree9e27c5ec1bbdbee048f2e91fc450d71f47bdf88d /src/mem/ruby/buffers
parentaa7888797032bab49b5f0f637c859740497423d8 (diff)
downloadgem5-bc87fa30d72df7db6265be50b2c39dc218076f9f.tar.xz
ruby: get rid of RefCnt and Allocator stuff use base/refcnt.hh
This was somewhat tricky because the RefCnt API was somewhat odd. The biggest confusion was that the the RefCnt object's constructor that took a TYPE& cloned the object. I created an explicit virtual clone() function for things that took advantage of this version of the constructor. I was conservative and used clone() when I was in doubt of whether or not it was necessary. I still think that there are probably too many instances of clone(), but hopefully not too many. I converted several instances of const MsgPtr & to a simple MsgPtr. If the function wants to avoid the overhead of creating another reference, then it should just use a regular pointer instead of a ref counting ptr. There were a couple of instances where refcounted objects were created on the stack. This seems pretty dangerous since if you ever accidentally make a reference to that object with a ref counting pointer, bad things are bound to happen.
Diffstat (limited to 'src/mem/ruby/buffers')
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.cc17
-rw-r--r--src/mem/ruby/buffers/MessageBuffer.hh6
2 files changed, 9 insertions, 14 deletions
diff --git a/src/mem/ruby/buffers/MessageBuffer.cc b/src/mem/ruby/buffers/MessageBuffer.cc
index e64e47cad..26d187305 100644
--- a/src/mem/ruby/buffers/MessageBuffer.cc
+++ b/src/mem/ruby/buffers/MessageBuffer.cc
@@ -111,16 +111,12 @@ MessageBuffer::getMsgPtrCopy() const
{
assert(isReady());
- MsgPtr temp_msg;
- temp_msg = *(m_prio_heap.peekMin().m_msgptr.ref());
- assert(temp_msg.ref() != NULL);
- return temp_msg;
+ return m_prio_heap.peekMin().m_msgptr->clone();
}
const Message*
MessageBuffer::peekAtHeadOfQueue() const
{
- const Message* msg_ptr;
DEBUG_NEWLINE(QUEUE_COMP, MedPrio);
DEBUG_MSG(QUEUE_COMP, MedPrio,
@@ -128,8 +124,8 @@ MessageBuffer::peekAtHeadOfQueue() const
m_name, g_eventQueue_ptr->getTime()));
assert(isReady());
- msg_ptr = m_prio_heap.peekMin().m_msgptr.ref();
- assert(msg_ptr != NULL);
+ const Message* msg_ptr = m_prio_heap.peekMin().m_msgptr.get();
+ assert(msg_ptr);
DEBUG_EXPR(QUEUE_COMP, MedPrio, *msg_ptr);
DEBUG_NEWLINE(QUEUE_COMP, MedPrio);
@@ -149,7 +145,7 @@ random_time()
}
void
-MessageBuffer::enqueue(const MsgPtr& message, Time delta)
+MessageBuffer::enqueue(MsgPtr message, Time delta)
{
DEBUG_NEWLINE(QUEUE_COMP, HighPrio);
DEBUG_MSG(QUEUE_COMP, HighPrio,
@@ -214,7 +210,7 @@ MessageBuffer::enqueue(const MsgPtr& message, Time delta)
m_last_arrival_time = arrival_time;
// compute the delay cycles and set enqueue time
- Message* msg_ptr = message.mod_ref();
+ Message* msg_ptr = message.get();
assert(msg_ptr != NULL);
assert(g_eventQueue_ptr->getTime() >= msg_ptr->getLastEnqueueTime() &&
@@ -332,12 +328,11 @@ MessageBuffer::recycle()
}
int
-MessageBuffer::setAndReturnDelayCycles(MsgPtr& message)
+MessageBuffer::setAndReturnDelayCycles(MsgPtr msg_ptr)
{
int delay_cycles = -1; // null value
// get the delay cycles of the message at the top of the queue
- Message* msg_ptr = message.ref();
// this function should only be called on dequeue
// ensure the msg hasn't been enqueued
diff --git a/src/mem/ruby/buffers/MessageBuffer.hh b/src/mem/ruby/buffers/MessageBuffer.hh
index 6b567d70d..1da6c15ae 100644
--- a/src/mem/ruby/buffers/MessageBuffer.hh
+++ b/src/mem/ruby/buffers/MessageBuffer.hh
@@ -102,8 +102,8 @@ class MessageBuffer
return m_prio_heap.peekMin().m_msgptr;
}
- void enqueue(const MsgPtr& message) { enqueue(message, 1); }
- void enqueue(const MsgPtr& message, Time delta);
+ void enqueue(MsgPtr message) { enqueue(message, 1); }
+ void enqueue(MsgPtr message, Time delta);
// void enqueueAbsolute(const MsgPtr& message, Time absolute_time);
int dequeue_getDelayCycles(MsgPtr& message); // returns delay
// cycles of the
@@ -136,7 +136,7 @@ class MessageBuffer
int m_recycle_latency;
// Private Methods
- int setAndReturnDelayCycles(MsgPtr& message);
+ int setAndReturnDelayCycles(MsgPtr message);
// Private copy constructor and assignment operator
MessageBuffer(const MessageBuffer& obj);