зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1157870 - Performance Groups should have a unique ID (low-level). r=jandem
--HG-- extra : transplant_source : .%DB%86%B6%B8%84%EB%94%EF%2B%12Of%28%ED%09U%5C%16%2A
This commit is contained in:
Родитель
8b2b1647a0
Коммит
6983f9efc8
|
@ -338,7 +338,7 @@ IterPerformanceStats(JSContext* cx,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!(*walker)(cx, group->data, closure)) {
|
||||
if (!(*walker)(cx, group->data, group->uid, closure)) {
|
||||
// Issue in callback
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5448,6 +5448,9 @@ struct PerformanceGroup {
|
|||
// Performance data for this group.
|
||||
PerformanceData data;
|
||||
|
||||
// An id unique to this runtime.
|
||||
const uint64_t uid;
|
||||
|
||||
// `true` if an instance of `AutoStopwatch` is already monitoring
|
||||
// the performance of this performance group for this iteration
|
||||
// of the event loop, `false` otherwise.
|
||||
|
@ -5472,12 +5475,7 @@ struct PerformanceGroup {
|
|||
stopwatch_ = nullptr;
|
||||
}
|
||||
|
||||
explicit PerformanceGroup(void* key)
|
||||
: stopwatch_(nullptr)
|
||||
, iteration_(0)
|
||||
, key_(key)
|
||||
, refCount_(0)
|
||||
{ }
|
||||
explicit PerformanceGroup(JSContext* cx, void* key);
|
||||
~PerformanceGroup()
|
||||
{
|
||||
MOZ_ASSERT(refCount_ == 0);
|
||||
|
@ -5589,7 +5587,7 @@ extern JS_PUBLIC_API(PerformanceData*)
|
|||
GetPerformanceData(JSRuntime*);
|
||||
|
||||
typedef bool
|
||||
(PerformanceStatsWalker)(JSContext* cx, const PerformanceData& stats, void* closure);
|
||||
(PerformanceStatsWalker)(JSContext* cx, const PerformanceData& stats, uint64_t uid, void* closure);
|
||||
|
||||
/**
|
||||
* Extract the performance statistics.
|
||||
|
|
|
@ -955,7 +955,7 @@ js::PerformanceGroupHolder::getGroup(JSContext* cx)
|
|||
group_ = ptr->value();
|
||||
MOZ_ASSERT(group_);
|
||||
} else {
|
||||
group_ = runtime_->new_<PerformanceGroup>(key);
|
||||
group_ = runtime_->new_<PerformanceGroup>(cx, key);
|
||||
runtime_->stopwatch.groups_.add(ptr, key, group_);
|
||||
}
|
||||
|
||||
|
@ -970,6 +970,15 @@ js::GetPerformanceData(JSRuntime* rt)
|
|||
return &rt->stopwatch.performance;
|
||||
}
|
||||
|
||||
js::PerformanceGroup::PerformanceGroup(JSContext* cx, void* key)
|
||||
: uid(cx->runtime()->stopwatch.uniqueId())
|
||||
, stopwatch_(nullptr)
|
||||
, iteration_(0)
|
||||
, key_(key)
|
||||
, refCount_(0)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
JS_SetCurrentPerfGroupCallback(JSRuntime *rt, JSCurrentPerfGroupCallback cb)
|
||||
{
|
||||
|
|
|
@ -1517,6 +1517,7 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
, currentPerfGroupCallback(nullptr)
|
||||
, isMonitoringJank_(false)
|
||||
, isMonitoringCPOW_(false)
|
||||
, idCounter_(0)
|
||||
{ }
|
||||
|
||||
/**
|
||||
|
@ -1570,6 +1571,13 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
return isMonitoringCPOW_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a identifier for a group, unique to the runtime.
|
||||
*/
|
||||
uint64_t uniqueId() {
|
||||
return idCounter_++;
|
||||
}
|
||||
|
||||
// Some systems have non-monotonic clocks. While we cannot
|
||||
// improve the precision, we can make sure that our measures
|
||||
// are monotonic nevertheless. We do this by storing the
|
||||
|
@ -1620,6 +1628,11 @@ struct JSRuntime : public JS::shadow::Runtime,
|
|||
*/
|
||||
bool isMonitoringJank_;
|
||||
bool isMonitoringCPOW_;
|
||||
|
||||
/**
|
||||
* A counter used to generate unique identifiers for groups.
|
||||
*/
|
||||
uint64_t idCounter_;
|
||||
};
|
||||
Stopwatch stopwatch;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче