Bug 1374127 (part 5) - Remove SyncPopulate's argument. r=mstange.

We can use a static ucontext_t on Linux for synchronous samples instead of
declaring one on the stack in profiler_get_backtrace(). This neatens
SyncPopulate()'s signature.

SyncPopulate() is also only used when HAVE_NATIVE_UNWIND is defined, so the
patch guards the definitions.

--HG--
extra : rebase_source : b71e6d76f24b37bc236ac8f4359d401b1551e2de
This commit is contained in:
Nicholas Nethercote 2017-06-20 08:45:43 +10:00
parent 376df7b9bd
commit 5e6717e1af
4 changed files with 17 additions and 15 deletions

View File

@ -523,13 +523,18 @@ PlatformInit(PSLockRef aLock)
#endif
void
Registers::SyncPopulate(ucontext_t* aContext)
{
MOZ_ASSERT(aContext);
#if defined(HAVE_NATIVE_UNWIND)
// Context used by synchronous samples. It's safe to have a single one because
// only one synchronous sample can be taken at a time (due to
// profiler_get_backtrace()'s PSAutoLock).
ucontext_t sSyncUContext;
if (!getcontext(aContext)) {
FillInRegs(*this, aContext);
void
Registers::SyncPopulate()
{
if (!getcontext(&sSyncUContext)) {
FillInRegs(*this, &sSyncUContext);
}
}
#endif

View File

@ -192,6 +192,7 @@ PlatformInit(PSLockRef aLock)
{
}
#if defined(HAVE_NATIVE_UNWIND)
void
Registers::SyncPopulate()
{
@ -208,4 +209,5 @@ Registers::SyncPopulate()
mPC = reinterpret_cast<Address>(__builtin_extract_return_addr(
__builtin_return_address(0)));
}
#endif

View File

@ -264,6 +264,7 @@ PlatformInit(PSLockRef aLock)
{
}
#if defined(HAVE_NATIVE_UNWIND)
void
Registers::SyncPopulate()
{
@ -280,4 +281,5 @@ Registers::SyncPopulate()
mFP = reinterpret_cast<Address>(context.Ebp);
#endif
}
#endif

View File

@ -641,10 +641,8 @@ public:
#endif
{}
// Fills in mContext, mPC, mSP, mFP, and mLR for a synchronous sample.
#if defined(GP_OS_linux) || defined(GP_OS_android)
void SyncPopulate(ucontext_t* aContext);
#else
#if defined(HAVE_NATIVE_UNWIND)
// Fills in mPC, mSP, mFP, mLR, and mContext for a synchronous sample.
void SyncPopulate();
#endif
@ -2836,12 +2834,7 @@ profiler_get_backtrace()
Registers regs;
#if defined(HAVE_NATIVE_UNWIND)
#if defined(GP_OS_linux) || defined(GP_OS_android)
ucontext_t context;
regs.SyncPopulate(&context);
#else
regs.SyncPopulate();
#endif
#endif
auto buffer = MakeUnique<ProfileBuffer>(PROFILER_GET_BACKTRACE_ENTRIES);