Files
palemoon27/tools/profiler/SyncProfile.cpp
T
roytam1 38bd296c8c import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1145306 - Expose circular buffer status from profiler. r=mstange (8b24a7439)
- Bug 1145824 - Add getElapsedTime to nsIProfiler. (r=mstange) (9bbd99f66)
- Bug 1145824 - In nsProfiler, allow GetProfile and getProfileData to filter by a start time. (r=mstange) (43bdcb254)
- Bug 1141712 - Make LUL work with inplace ticking (not using the unwinder thread). r=mstange. (ed43cdf70)
- Bug 1151679 - Stream the property name of getprop and setprop optimization sites. (r=djvj) (3eb8efeb4)
- Bug 1142181 - ProfilerBacktrace.cpp should #include its own .h file first, r=aklotz (c1aff9f49)
- Bug 1154115 - Rewrite profiler JSON streaming. (r=mstange) (834891a91)
- Bug 1157906 - Can't return arrays as a root response, fixes inspect button. r=bgrins (d66407512)
- Bug 1160361 - Abort tilt commands when remote. r=bgrins (5bcfbc8d0)
- Bug 947242 - DevTools themes - switch to new theme colors;r=jsantell (5ed17dcdc)
2020-08-30 20:39:38 +08:00

62 lines
1.6 KiB
C++

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SyncProfile.h"
SyncProfile::SyncProfile(ThreadInfo* aInfo, int aEntrySize)
: ThreadProfile(aInfo, new ProfileBuffer(aEntrySize))
, mOwnerState(REFERENCED)
, mUtb(nullptr)
{
MOZ_COUNT_CTOR(SyncProfile);
}
SyncProfile::~SyncProfile()
{
MOZ_COUNT_DTOR(SyncProfile);
// SyncProfile owns the ThreadInfo; see NewSyncProfile.
ThreadInfo* info = GetThreadInfo();
delete info;
}
bool
SyncProfile::ShouldDestroy()
{
GetMutex()->AssertNotCurrentThreadOwns();
mozilla::MutexAutoLock lock(*GetMutex());
if (mOwnerState == OWNED) {
mOwnerState = OWNER_DESTROYING;
return true;
}
mOwnerState = ORPHANED;
return false;
}
void
SyncProfile::EndUnwind()
{
// Mutex must be held when this is called
GetMutex()->AssertCurrentThreadOwns();
if (mOwnerState != ORPHANED) {
mOwnerState = OWNED;
}
// Save mOwnerState before we release the mutex
OwnerState ownerState = mOwnerState;
ThreadProfile::EndUnwind();
if (ownerState == ORPHANED) {
delete this;
}
}
// SyncProfiles' stacks are deduplicated in the context of the containing
// profile in which the backtrace is as a marker payload.
void
SyncProfile::StreamJSON(SpliceableJSONWriter& aWriter, UniqueStacks& aUniqueStacks)
{
ThreadProfile::StreamSamplesAndMarkers(aWriter, /* aSinceTime = */ 0, aUniqueStacks);
}