Bug 1049051 - Part 1: Remove ResourceAcquisition. r=froydnj

--HG--
extra : rebase_source : 86bc896f9c2833996c4c5eebcc034acbadedbd4a
This commit is contained in:
Eric Rahm 2014-08-12 11:42:10 -07:00
parent ce43329f4b
commit d733f0c695
3 changed files with 14 additions and 39 deletions

View File

@ -39,7 +39,7 @@ BlockingResourceBase::DDT* BlockingResourceBase::sDeadlockDetector;
bool
BlockingResourceBase::DeadlockDetectorEntry::Print(
const DDT::ResourceAcquisition& aFirstSeen,
const DeadlockDetectorEntry* aFirstSeen,
nsACString& aOut) const
{
fprintf(stderr, "--- %s : %s",
@ -193,22 +193,22 @@ BlockingResourceBase::PrintCycle(const DDT::ResourceAcquisitionArray* aCycle,
fputs("=== Cyclical dependency starts at\n", stderr);
aOut += "Cyclical dependency starts at\n";
const DDT::ResourceAcquisition res = aCycle->ElementAt(0);
maybeImminent &= res.mResource->Print(res, aOut);
const DeadlockDetectorEntry* res = aCycle->ElementAt(0);
maybeImminent &= res->Print(res, aOut);
DDT::ResourceAcquisitionArray::index_type i;
DDT::ResourceAcquisitionArray::size_type len = aCycle->Length();
const DDT::ResourceAcquisition* it = 1 + aCycle->Elements();
const DDT::ResourceAcquisitionArray::elem_type* it = 1 + aCycle->Elements();
for (i = 1; i < len - 1; ++i, ++it) {
fputs("\n--- Next dependency:\n", stderr);
aOut += "\nNext dependency:\n";
maybeImminent &= it->mResource->Print(*it, aOut);
maybeImminent &= (*it)->Print(*it, aOut);
}
fputs("\n=== Cycle completed at\n", stderr);
aOut += "Cycle completed at\n";
it->mResource->Print(*it, aOut);
(*it)->Print(*it, aOut);
return maybeImminent;
}

View File

@ -113,7 +113,7 @@ private:
* contexts into strings, all info is written to stderr, but
* only some info is written into |aOut|
*/
bool Print(const DDT::ResourceAcquisition& aFirstSeen,
bool Print(const DeadlockDetectorEntry* aFirstSeen,
nsACString& aOut) const;
/**

View File

@ -65,32 +65,7 @@ template<typename T>
class DeadlockDetector
{
public:
/**
* ResourceAcquisition
* Consists simply of a resource and the calling context from
* which it was acquired. We pack this information together so
* that it can be returned back to the caller when a potential
* deadlock has been found.
*/
struct ResourceAcquisition
{
const T* mResource;
explicit ResourceAcquisition(const T* aResource)
: mResource(aResource)
{
}
ResourceAcquisition(const ResourceAcquisition& aFrom)
: mResource(aFrom.mResource)
{
}
ResourceAcquisition& operator=(const ResourceAcquisition& aFrom)
{
mResource = aFrom.mResource;
return *this;
}
};
typedef nsTArray<ResourceAcquisition> ResourceAcquisitionArray;
typedef nsTArray<const T*> ResourceAcquisitionArray;
private:
struct OrderingEntry;
@ -278,8 +253,8 @@ public:
if (!cycle) {
NS_RUNTIMEABORT("can't allocate dep. cycle array");
}
cycle->AppendElement(ResourceAcquisition(current->mResource));
cycle->AppendElement(ResourceAcquisition(aProposed));
cycle->AppendElement(current->mResource);
cycle->AppendElement(aProposed);
return cycle;
}
if (InTransitiveClosure(current, proposed)) {
@ -294,7 +269,7 @@ public:
// right conditions.
ResourceAcquisitionArray* cycle = GetDeductionChain(proposed, current);
// show how acquiring |aProposed| would complete the cycle
cycle->AppendElement(ResourceAcquisition(aProposed));
cycle->AppendElement(aProposed);
return cycle;
}
// |aLast|, |aProposed| are unordered according to our
@ -354,7 +329,7 @@ public:
if (!chain) {
NS_RUNTIMEABORT("can't allocate dep. cycle array");
}
chain->AppendElement(ResourceAcquisition(aStart->mResource));
chain->AppendElement(aStart->mResource);
NS_ASSERTION(GetDeductionChain_Helper(aStart, aTarget, chain),
"GetDeductionChain called when there's no deadlock");
@ -368,14 +343,14 @@ public:
ResourceAcquisitionArray* aChain)
{
if (aStart->mOrderedLT.BinaryIndexOf(aTarget) != NoIndex) {
aChain->AppendElement(ResourceAcquisition(aTarget->mResource));
aChain->AppendElement(aTarget->mResource);
return true;
}
index_type i = 0;
size_type len = aStart->mOrderedLT.Length();
for (const OrderingEntry* const* it = aStart->mOrderedLT.Elements(); i < len; ++i, ++it) {
aChain->AppendElement(ResourceAcquisition((*it)->mResource));
aChain->AppendElement((*it)->mResource);
if (GetDeductionChain_Helper(*it, aTarget, aChain)) {
return true;
}