mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1237201 part 7 - Handle Vector OOM in nsPerformanceStats, telemetry. r=Yoric
This commit is contained in:
parent
dabcd72958
commit
366cd49655
@ -221,8 +221,10 @@ AutoStopwatch::AutoStopwatch(JSContext* cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IM
|
|||||||
}
|
}
|
||||||
for (auto group = groups->begin(); group < groups->end(); group++) {
|
for (auto group = groups->begin(); group < groups->end(); group++) {
|
||||||
auto acquired = acquireGroup(*group);
|
auto acquired = acquireGroup(*group);
|
||||||
if (acquired)
|
if (acquired) {
|
||||||
groups_.append(acquired);
|
if (!groups_.append(acquired))
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (groups_.length() == 0) {
|
if (groups_.length() == 0) {
|
||||||
// We are not in charge of monitoring anything.
|
// We are not in charge of monitoring anything.
|
||||||
|
@ -164,7 +164,9 @@ nsPerformanceObservationTarget::SetTarget(nsPerformanceGroupDetails* details) {
|
|||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPerformanceObservationTarget::AddJankObserver(nsIPerformanceObserver* observer) {
|
nsPerformanceObservationTarget::AddJankObserver(nsIPerformanceObserver* observer) {
|
||||||
mObservers.append(observer);
|
if (!mObservers.append(observer)) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -188,7 +190,9 @@ void
|
|||||||
nsPerformanceObservationTarget::NotifyJankObservers(nsIPerformanceGroupDetails* source, nsIPerformanceAlert* gravity) {
|
nsPerformanceObservationTarget::NotifyJankObservers(nsIPerformanceGroupDetails* source, nsIPerformanceAlert* gravity) {
|
||||||
// Copy the vector to make sure that it won't change under our feet.
|
// Copy the vector to make sure that it won't change under our feet.
|
||||||
mozilla::Vector<nsCOMPtr<nsIPerformanceObserver>> observers;
|
mozilla::Vector<nsCOMPtr<nsIPerformanceObserver>> observers;
|
||||||
observers.appendAll(mObservers);
|
if (!observers.appendAll(mObservers)) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
|
|
||||||
// Now actually notify.
|
// Now actually notify.
|
||||||
for (auto iter = observers.begin(), end = observers.end(); iter < end; ++iter) {
|
for (auto iter = observers.begin(), end = observers.end(); iter < end; ++iter) {
|
||||||
@ -733,7 +737,9 @@ nsPerformanceStatsService::Dispose()
|
|||||||
// not modify the hashtable while iterating it.
|
// not modify the hashtable while iterating it.
|
||||||
GroupVector groups;
|
GroupVector groups;
|
||||||
for (auto iter = mGroups.Iter(); !iter.Done(); iter.Next()) {
|
for (auto iter = mGroups.Iter(); !iter.Done(); iter.Next()) {
|
||||||
groups.append(iter.Get()->GetKey());
|
if (!groups.append(iter.Get()->GetKey())) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (auto iter = groups.begin(), end = groups.end(); iter < end; ++iter) {
|
for (auto iter = groups.begin(), end = groups.end(); iter < end; ++iter) {
|
||||||
RefPtr<nsPerformanceGroup> group = *iter;
|
RefPtr<nsPerformanceGroup> group = *iter;
|
||||||
@ -1007,7 +1013,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou
|
|||||||
}
|
}
|
||||||
|
|
||||||
// All compartments belong to the top group.
|
// All compartments belong to the top group.
|
||||||
out.append(mTopGroup);
|
if (!out.append(mTopGroup)) {
|
||||||
|
JS_ReportOutOfMemory(cx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsAutoString name;
|
nsAutoString name;
|
||||||
CompartmentName(cx, global, name);
|
CompartmentName(cx, global, name);
|
||||||
@ -1032,7 +1041,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou
|
|||||||
nsPerformanceGroup::GroupScope::ADDON)
|
nsPerformanceGroup::GroupScope::ADDON)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
out.append(entry->GetGroup());
|
if (!out.append(entry->GetGroup())) {
|
||||||
|
JS_ReportOutOfMemory(cx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find out if the compartment is executed by a window. If so, its
|
// Find out if the compartment is executed by a window. If so, its
|
||||||
@ -1054,7 +1066,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou
|
|||||||
nsPerformanceGroup::GroupScope::WINDOW)
|
nsPerformanceGroup::GroupScope::WINDOW)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
out.append(entry->GetGroup());
|
if (!out.append(entry->GetGroup())) {
|
||||||
|
JS_ReportOutOfMemory(cx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// All compartments have their own group.
|
// All compartments have their own group.
|
||||||
@ -1063,7 +1078,10 @@ nsPerformanceStatsService::GetPerformanceGroups(JSContext* cx, JSGroupVector& ou
|
|||||||
name, addonId, windowId,
|
name, addonId, windowId,
|
||||||
mProcessId, isSystem,
|
mProcessId, isSystem,
|
||||||
nsPerformanceGroup::GroupScope::COMPARTMENT);
|
nsPerformanceGroup::GroupScope::COMPARTMENT);
|
||||||
out.append(group);
|
if (!out.append(group)) {
|
||||||
|
JS_ReportOutOfMemory(cx);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1190,8 +1208,9 @@ nsPerformanceStatsService::CommitGroup(uint64_t iteration,
|
|||||||
|
|
||||||
if (totalTimeDelta >= mJankAlertThreshold) {
|
if (totalTimeDelta >= mJankAlertThreshold) {
|
||||||
if (!group->HasPendingAlert()) {
|
if (!group->HasPendingAlert()) {
|
||||||
group->SetHasPendingAlert(true);
|
if (mPendingAlerts.append(group)) {
|
||||||
mPendingAlerts.append(group);
|
group->SetHasPendingAlert(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
|
#include "mozilla/unused.h"
|
||||||
|
|
||||||
#include "base/histogram.h"
|
#include "base/histogram.h"
|
||||||
#include "base/pickle.h"
|
#include "base/pickle.h"
|
||||||
@ -3669,7 +3670,8 @@ TelemetryImpl::RecordThreadHangStats(Telemetry::ThreadHangStats& aStats)
|
|||||||
|
|
||||||
MutexAutoLock autoLock(sTelemetry->mThreadHangStatsMutex);
|
MutexAutoLock autoLock(sTelemetry->mThreadHangStatsMutex);
|
||||||
|
|
||||||
sTelemetry->mThreadHangStats.append(Move(aStats));
|
// Ignore OOM.
|
||||||
|
mozilla::Unused << sTelemetry->mThreadHangStats.append(Move(aStats));
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(TelemetryImpl, nsITelemetry, nsIMemoryReporter)
|
NS_IMPL_ISUPPORTS(TelemetryImpl, nsITelemetry, nsIMemoryReporter)
|
||||||
|
@ -187,7 +187,9 @@ public:
|
|||||||
void Add(PRIntervalTime aTime, HangMonitor::HangAnnotationsPtr aAnnotations) {
|
void Add(PRIntervalTime aTime, HangMonitor::HangAnnotationsPtr aAnnotations) {
|
||||||
TimeHistogram::Add(aTime);
|
TimeHistogram::Add(aTime);
|
||||||
if (aAnnotations) {
|
if (aAnnotations) {
|
||||||
mAnnotations.append(Move(aAnnotations));
|
if (!mAnnotations.append(Move(aAnnotations))) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -437,7 +437,9 @@ BackgroundHangThread::ReportHang(PRIntervalTime aHangTime)
|
|||||||
}
|
}
|
||||||
// Add new histogram
|
// Add new histogram
|
||||||
newHistogram.Add(aHangTime, Move(mAnnotations));
|
newHistogram.Add(aHangTime, Move(mAnnotations));
|
||||||
mStats.mHangs.append(Move(newHistogram));
|
if (!mStats.mHangs.append(Move(newHistogram))) {
|
||||||
|
MOZ_CRASH();
|
||||||
|
}
|
||||||
return mStats.mHangs.back();
|
return mStats.mHangs.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user