diff options
author | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:06 -0700 |
---|---|---|
committer | Nathan Binkert <nate@binkert.org> | 2010-06-10 23:17:06 -0700 |
commit | bc87fa30d72df7db6265be50b2c39dc218076f9f (patch) | |
tree | 9e27c5ec1bbdbee048f2e91fc450d71f47bdf88d /src/mem/ruby/network/simple | |
parent | aa7888797032bab49b5f0f637c859740497423d8 (diff) | |
download | gem5-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/network/simple')
-rw-r--r-- | src/mem/ruby/network/simple/PerfectSwitch.cc | 8 | ||||
-rw-r--r-- | src/mem/ruby/network/simple/Throttle.cc | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mem/ruby/network/simple/PerfectSwitch.cc b/src/mem/ruby/network/simple/PerfectSwitch.cc index cf3a5af9c..8e6114ba9 100644 --- a/src/mem/ruby/network/simple/PerfectSwitch.cc +++ b/src/mem/ruby/network/simple/PerfectSwitch.cc @@ -170,7 +170,7 @@ PerfectSwitch::wakeup() // Peek at message msg_ptr = m_in[incoming][vnet]->peekMsgPtr(); - net_msg_ptr = dynamic_cast<NetworkMessage*>(msg_ptr.ref()); + net_msg_ptr = safe_cast<NetworkMessage*>(msg_ptr.get()); DEBUG_EXPR(NETWORK_COMP, MedPrio, *net_msg_ptr); output_links.clear(); @@ -272,7 +272,7 @@ PerfectSwitch::wakeup() // This magic line creates a private copy of the // message - unmodified_msg_ptr = *(msg_ptr.ref()); + unmodified_msg_ptr = msg_ptr->clone(); } // Enqueue it - for all outgoing queues @@ -282,13 +282,13 @@ PerfectSwitch::wakeup() if (i > 0) { // create a private copy of the unmodified // message - msg_ptr = *(unmodified_msg_ptr.ref()); + msg_ptr = unmodified_msg_ptr->clone(); } // Change the internal destination set of the // message so it knows which destinations this // link is responsible for. - net_msg_ptr = safe_cast<NetworkMessage*>(msg_ptr.ref()); + net_msg_ptr = safe_cast<NetworkMessage*>(msg_ptr.get()); net_msg_ptr->getInternalDestination() = output_link_destinations[i]; diff --git a/src/mem/ruby/network/simple/Throttle.cc b/src/mem/ruby/network/simple/Throttle.cc index 2d15b1141..5d74afb24 100644 --- a/src/mem/ruby/network/simple/Throttle.cc +++ b/src/mem/ruby/network/simple/Throttle.cc @@ -157,7 +157,7 @@ Throttle::wakeup() // Find the size of the message we are moving MsgPtr msg_ptr = m_in[vnet]->peekMsgPtr(); NetworkMessage* net_msg_ptr = - safe_cast<NetworkMessage*>(msg_ptr.ref()); + safe_cast<NetworkMessage*>(msg_ptr.get()); m_units_remaining[vnet] += network_message_to_size(net_msg_ptr); |