using namespace std;
-MSHR::MSHR()
+MSHR::MSHR() : readyTime(0), _isUncacheable(false), downstreamPending(false),
+ pendingDirty(false), postInvalidate(false),
+ postDowngrade(false), queue(NULL), order(0), addr(0), size(0),
+ inService(false), isForward(false), threadNum(InvalidThreadID),
+ data(NULL)
{
- inService = false;
- ntargets = 0;
- threadNum = InvalidThreadID;
- targets = new TargetList();
- deferredTargets = new TargetList();
}
inService = false;
downstreamPending = false;
threadNum = 0;
- ntargets = 1;
- assert(targets->isReset());
+ assert(targets.isReset());
// Don't know of a case where we would allocate a new MSHR for a
// snoop (mem-side request), so set source according to request here
Target::Source source = (target->cmd == MemCmd::HardPFReq) ?
Target::FromPrefetcher : Target::FromCPU;
- targets->add(target, whenReady, _order, source, true);
- assert(deferredTargets->isReset());
+ targets.add(target, whenReady, _order, source, true);
+ assert(deferredTargets.isReset());
data = NULL;
}
downstreamPending = false;
// recursively clear flag on any MSHRs we will be forwarding
// responses to
- targets->clearDownstreamPending();
+ targets.clearDownstreamPending();
}
bool
return true;
}
inService = true;
- pendingDirty = (targets->needsExclusive ||
+ pendingDirty = (targets.needsExclusive ||
(!pkt->sharedAsserted() && pkt->memInhibitAsserted()));
postInvalidate = postDowngrade = false;
if (!downstreamPending) {
// let upstream caches know that the request has made it to a
// level where it's going to get a response
- targets->clearDownstreamPending();
+ targets.clearDownstreamPending();
}
return false;
}
void
MSHR::deallocate()
{
- assert(targets->empty());
- targets->resetFlags();
- assert(deferredTargets->isReset());
- assert(ntargets == 0);
+ assert(targets.empty());
+ targets.resetFlags();
+ assert(deferredTargets.isReset());
inService = false;
}
assert(pkt->cmd != MemCmd::HardPFReq);
if (inService &&
- (!deferredTargets->empty() || hasPostInvalidate() ||
+ (!deferredTargets.empty() || hasPostInvalidate() ||
(pkt->needsExclusive() &&
(!isPendingDirty() || hasPostDowngrade() || isForward)))) {
// need to put on deferred list
if (hasPostInvalidate())
replaceUpgrade(pkt);
- deferredTargets->add(pkt, whenReady, _order, Target::FromCPU, true);
+ deferredTargets.add(pkt, whenReady, _order, Target::FromCPU, true);
} else {
// No request outstanding, or still OK to append to
// outstanding request: append to regular target list. Only
// mark pending if current request hasn't been issued yet
// (isn't in service).
- targets->add(pkt, whenReady, _order, Target::FromCPU, !inService);
+ targets.add(pkt, whenReady, _order, Target::FromCPU, !inService);
}
-
- ++ntargets;
}
bool
// local bus first, some other invalidating transaction
// reached the global bus before the upgrade did.
if (pkt->needsExclusive()) {
- targets->replaceUpgrades();
- deferredTargets->replaceUpgrades();
+ targets.replaceUpgrades();
+ deferredTargets.replaceUpgrades();
}
return false;
if (pkt->needsExclusive()) {
// snooped request still precedes the re-request we'll have to
// issue for deferred targets, if any...
- deferredTargets->replaceUpgrades();
+ deferredTargets.replaceUpgrades();
}
if (hasPostInvalidate()) {
// Actual target device (typ. a memory) will delete the
// packet on reception, so we need to save a copy here.
PacketPtr cp_pkt = new Packet(pkt, true);
- targets->add(cp_pkt, curTick(), _order, Target::FromSnoop,
- downstreamPending && targets->needsExclusive);
- ++ntargets;
+ targets.add(cp_pkt, curTick(), _order, Target::FromSnoop,
+ downstreamPending && targets.needsExclusive);
if (isPendingDirty()) {
pkt->assertMemInhibit();
bool
MSHR::promoteDeferredTargets()
{
- assert(targets->empty());
- if (deferredTargets->empty()) {
+ assert(targets.empty());
+ if (deferredTargets.empty()) {
return false;
}
// swap targets & deferredTargets lists
- TargetList *tmp = targets;
- targets = deferredTargets;
- deferredTargets = tmp;
-
- assert(targets->size() == ntargets);
+ std::swap(targets, deferredTargets);
// clear deferredTargets flags
- deferredTargets->resetFlags();
+ deferredTargets.resetFlags();
- order = targets->front().order;
- readyTime = std::max(curTick(), targets->front().readyTime);
+ order = targets.front().order;
+ readyTime = std::max(curTick(), targets.front().readyTime);
return true;
}
{
if (!pkt->sharedAsserted()
&& !(hasPostInvalidate() || hasPostDowngrade())
- && deferredTargets->needsExclusive) {
+ && deferredTargets.needsExclusive) {
// We got an exclusive response, but we have deferred targets
// which are waiting to request an exclusive copy (not because
// of a pending invalidate). This can happen if the original
// MOESI/MESI protocol. Since we got the exclusive copy
// there's no need to defer the targets, so move them up to
// the regular target list.
- assert(!targets->needsExclusive);
- targets->needsExclusive = true;
+ assert(!targets.needsExclusive);
+ targets.needsExclusive = true;
// if any of the deferred targets were upper-level cache
// requests marked downstreamPending, need to clear that
assert(!downstreamPending); // not pending here anymore
- deferredTargets->clearDownstreamPending();
+ deferredTargets.clearDownstreamPending();
// this clears out deferredTargets too
- targets->splice(targets->end(), *deferredTargets);
- deferredTargets->resetFlags();
+ targets.splice(targets.end(), deferredTargets);
+ deferredTargets.resetFlags();
}
}
pkt->checkFunctional(this, addr, size, NULL);
return false;
} else {
- return (targets->checkFunctional(pkt) ||
- deferredTargets->checkFunctional(pkt));
+ return (targets.checkFunctional(pkt) ||
+ deferredTargets.checkFunctional(pkt));
}
}
hasPostDowngrade() ? "PostDowngr" : "");
ccprintf(os, "%s Targets:\n", prefix);
- targets->print(os, verbosity, prefix + " ");
- if (!deferredTargets->empty()) {
+ targets.print(os, verbosity, prefix + " ");
+ if (!deferredTargets.empty()) {
ccprintf(os, "%s Deferred Targets:\n", prefix);
- deferredTargets->print(os, verbosity, prefix + " ");
+ deferredTargets.print(os, verbosity, prefix + " ");
}
}
print(str);
return str.str();
}
-
-MSHR::~MSHR()
-{
- delete[] targets;
- delete[] deferredTargets;
-}
/*
- * 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
class MSHR : public Packet::SenderState, public Printable
{
+ /**
+ * Consider the MSHRQueue a friend to avoid making everything public
+ */
+ friend class MSHRQueue;
+
+ private:
+
+ /** Cycle when ready to issue */
+ Tick readyTime;
+
+ /** True if the request is uncacheable */
+ bool _isUncacheable;
+
+ /** Flag set by downstream caches */
+ bool downstreamPending;
+
+ /** Will we have a dirty copy after this request? */
+ bool pendingDirty;
+
+ /** Did we snoop an invalidate while waiting for data? */
+ bool postInvalidate;
+
+ /** Did we snoop a read while waiting for data? */
+ bool postDowngrade;
+
public:
class Target {
/** Pointer to queue containing this MSHR. */
MSHRQueue *queue;
- /** Cycle when ready to issue */
- Tick readyTime;
-
/** Order number assigned by the miss queue. */
Counter order;
/** True if the request is just a simple forward from an upper level */
bool isForward;
- /** True if we need to get an exclusive copy of the block. */
- bool needsExclusive() const { return targets->needsExclusive; }
-
- /** True if the request is uncacheable */
- bool _isUncacheable;
-
- bool downstreamPending;
-
/** The pending* and post* flags are only valid if inService is
* true. Using the accessor functions lets us detect if these
* flags are accessed improperly.
*/
- /** Will we have a dirty copy after this request? */
- bool pendingDirty;
+ /** True if we need to get an exclusive copy of the block. */
+ bool needsExclusive() const { return targets.needsExclusive; }
+
bool isPendingDirty() const {
assert(inService); return pendingDirty;
}
- /** Did we snoop an invalidate while waiting for data? */
- bool postInvalidate;
bool hasPostInvalidate() const {
assert(inService); return postInvalidate;
}
- /** Did we snoop a read while waiting for data? */
- bool postDowngrade;
bool hasPostDowngrade() const {
assert(inService); return postDowngrade;
}
/** Thread number of the miss. */
ThreadID threadNum;
- /** The number of currently allocated targets. */
- unsigned short ntargets;
+ private:
/** Data buffer (if needed). Currently used only for pending
* upgrade handling. */
*/
Iterator allocIter;
-private:
/** List of all requests that match the address */
- TargetList *targets;
+ TargetList targets;
- TargetList *deferredTargets;
+ TargetList deferredTargets;
-public:
+ public:
- bool isUncacheable() { return _isUncacheable; }
+ bool isUncacheable() const { return _isUncacheable; }
/**
* Allocate a miss to this MSHR.
/** A simple constructor. */
MSHR();
- /** A simple destructor. */
- ~MSHR();
/**
* Returns the current number of allocated targets.
* @return The current number of allocated targets.
*/
- int getNumTargets() const { return ntargets; }
-
- /**
- * Returns a pointer to the target list.
- * @return a pointer to the target list.
- */
- TargetList *getTargetList() { return targets; }
+ int getNumTargets() const
+ { return targets.size() + deferredTargets.size(); }
/**
* Returns true if there are targets left.
* @return true if there are targets
*/
- bool hasTargets() const { return !targets->empty(); }
+ bool hasTargets() const { return !targets.empty(); }
/**
* Returns a reference to the first target.
* @return A pointer to the first target.
*/
- Target *getTarget() const
+ Target *getTarget()
{
assert(hasTargets());
- return &targets->front();
+ return &targets.front();
}
/**
*/
void popTarget()
{
- --ntargets;
- targets->pop_front();
+ targets.pop_front();
}
bool isForwardNoResponse() const
{
if (getNumTargets() != 1)
return false;
- Target *tgt = getTarget();
+ const Target *tgt = &targets.front();
return tgt->source == Target::FromCPU && !tgt->pkt->needsResponse();
}