From 0622f30961fc32b967bb1ef784afc5a205b16f6e Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Tue, 19 Feb 2013 05:56:05 -0500 Subject: mem: Add predecessor to SenderState base class This patch adds a predecessor field to the SenderState base class to make the process of linking them up more uniform, and enable a traversal of the stack without knowing the specific type of the subclasses. There are a number of simplifications done as part of changing the SenderState, particularly in the RubyTest. --- src/cpu/testers/rubytest/Check.cc | 24 +++++++----------------- src/cpu/testers/rubytest/RubyTester.cc | 12 ++++-------- src/cpu/testers/rubytest/RubyTester.hh | 30 ++++++++++++++++-------------- 3 files changed, 27 insertions(+), 39 deletions(-) (limited to 'src/cpu/testers') diff --git a/src/cpu/testers/rubytest/Check.cc b/src/cpu/testers/rubytest/Check.cc index a861dbfd8..ae74da67f 100644 --- a/src/cpu/testers/rubytest/Check.cc +++ b/src/cpu/testers/rubytest/Check.cc @@ -111,16 +111,13 @@ Check::initiatePrefetch() // push the subblock onto the sender state. The sequencer will // update the subblock on the return - pkt->senderState = - new SenderState(m_address, req->getSize(), pkt->senderState); + pkt->senderState = new SenderState(m_address, req->getSize()); if (port->sendTimingReq(pkt)) { DPRINTF(RubyTest, "successfully initiated prefetch.\n"); } else { // If the packet did not issue, must delete - SenderState* senderState = safe_cast(pkt->senderState); - pkt->senderState = senderState->saved; - delete senderState; + delete pkt->senderState; delete pkt->req; delete pkt; @@ -151,8 +148,7 @@ Check::initiateFlush() // push the subblock onto the sender state. The sequencer will // update the subblock on the return - pkt->senderState = - new SenderState(m_address, req->getSize(), pkt->senderState); + pkt->senderState = new SenderState(m_address, req->getSize()); if (port->sendTimingReq(pkt)) { DPRINTF(RubyTest, "initiating Flush - successful\n"); @@ -198,8 +194,7 @@ Check::initiateAction() // push the subblock onto the sender state. The sequencer will // update the subblock on the return - pkt->senderState = - new SenderState(writeAddr, req->getSize(), pkt->senderState); + pkt->senderState = new SenderState(writeAddr, req->getSize()); if (port->sendTimingReq(pkt)) { DPRINTF(RubyTest, "initiating action - successful\n"); @@ -210,9 +205,7 @@ Check::initiateAction() // If the packet did not issue, must delete // Note: No need to delete the data, the packet destructor // will delete it - SenderState* senderState = safe_cast(pkt->senderState); - pkt->senderState = senderState->saved; - delete senderState; + delete pkt->senderState; delete pkt->req; delete pkt; @@ -250,8 +243,7 @@ Check::initiateCheck() // push the subblock onto the sender state. The sequencer will // update the subblock on the return - pkt->senderState = - new SenderState(m_address, req->getSize(), pkt->senderState); + pkt->senderState = new SenderState(m_address, req->getSize()); if (port->sendTimingReq(pkt)) { DPRINTF(RubyTest, "initiating check - successful\n"); @@ -262,9 +254,7 @@ Check::initiateCheck() // If the packet did not issue, must delete // Note: No need to delete the data, the packet destructor // will delete it - SenderState* senderState = safe_cast(pkt->senderState); - pkt->senderState = senderState->saved; - delete senderState; + delete pkt->senderState; delete pkt->req; delete pkt; diff --git a/src/cpu/testers/rubytest/RubyTester.cc b/src/cpu/testers/rubytest/RubyTester.cc index 085647533..68f76f1a6 100644 --- a/src/cpu/testers/rubytest/RubyTester.cc +++ b/src/cpu/testers/rubytest/RubyTester.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 ARM Limited + * Copyright (c) 2012-2013 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -149,17 +149,13 @@ RubyTester::CpuPort::recvTimingResp(PacketPtr pkt) // retrieve the subblock and call hitCallback RubyTester::SenderState* senderState = safe_cast(pkt->senderState); - SubBlock* subblock = senderState->subBlock; - assert(subblock != NULL); + SubBlock& subblock = senderState->subBlock; - // pop the sender state from the packet - pkt->senderState = senderState->saved; - - tester->hitCallback(id, subblock); + tester->hitCallback(id, &subblock); // Now that the tester has completed, delete the senderState // (includes sublock) and the packet, then return - delete senderState; + delete pkt->senderState; delete pkt->req; delete pkt; return true; diff --git a/src/cpu/testers/rubytest/RubyTester.hh b/src/cpu/testers/rubytest/RubyTester.hh index 2fed84e2d..df1bc1fbb 100644 --- a/src/cpu/testers/rubytest/RubyTester.hh +++ b/src/cpu/testers/rubytest/RubyTester.hh @@ -1,4 +1,16 @@ /* + * Copyright (c) 2013 ARM Limited + * All rights reserved + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood * Copyright (c) 2009 Advanced Micro Devices, Inc. * All rights reserved. @@ -69,20 +81,10 @@ class RubyTester : public MemObject struct SenderState : public Packet::SenderState { - SubBlock* subBlock; - Packet::SenderState *saved; - - SenderState(Address addr, int size, - Packet::SenderState *sender_state = NULL) - : saved(sender_state) - { - subBlock = new SubBlock(addr, size); - } - - ~SenderState() - { - delete subBlock; - } + SubBlock subBlock; + + SenderState(Address addr, int size) : subBlock(addr, size) {} + }; typedef RubyTesterParams Params; -- cgit v1.2.3