Esempio n. 1
0
PerformanceGroup*
js::PerformanceGroupHolder::getGroup(JSContext* cx)
{
    if (group_)
        return group_;

    void* key = getHashKey(cx);
    JSRuntime::Stopwatch::Groups::AddPtr ptr =
        runtime_->stopwatch.groups_.lookupForAdd(key);
    if (ptr) {
        group_ = ptr->value();
        MOZ_ASSERT(group_);
    } else {
        group_ = runtime_->new_<PerformanceGroup>(cx, key);
        runtime_->stopwatch.groups_.add(ptr, key, group_);
    }

    group_->incRefCount();

    return group_;
}
Esempio n. 2
0
PerformanceGroup*
js::PerformanceGroupHolder::getSharedGroup(JSContext* cx)
{
    if (sharedGroup_)
        return sharedGroup_;

    if (!runtime_->stopwatch.groups().initialized())
        return nullptr;

    void* key = getHashKey(cx);
    JSRuntime::Stopwatch::Groups::AddPtr ptr = runtime_->stopwatch.groups().lookupForAdd(key);
    if (ptr) {
        sharedGroup_ = ptr->value();
        MOZ_ASSERT(sharedGroup_);
    } else {
        sharedGroup_ = runtime_->new_<PerformanceGroup>(cx, key);
        if (!sharedGroup_)
          return nullptr;
        runtime_->stopwatch.groups().add(ptr, key, sharedGroup_);
    }

    return sharedGroup_;
}