зеркало из https://github.com/mozilla/gecko-dev.git
Bug 759532 - Expose Enter/ExitProfileLabel to JS. r=ehsan
--HG-- extra : rebase_source : e1dbc7995ce2dfd52ece4c3fd3d76cc6cd95896f
This commit is contained in:
Родитель
2392e65cbd
Коммит
7e3b302b27
|
@ -18,6 +18,8 @@ interface nsIProfiler : nsISupports
|
|||
boolean IsActive();
|
||||
void GetResponsivenessTimes(out PRUint32 aCount, [retval, array, size_is(aCount)] out double aResult);
|
||||
void GetFeatures(out PRUint32 aCount, [retval, array, size_is(aCount)] out string aFeatures);
|
||||
void EnterProfileLabel(in string aLabel);
|
||||
void ExitProfileLabel();
|
||||
|
||||
/**
|
||||
* Returns a JSON string of an array of shared library objects.
|
||||
|
|
|
@ -169,3 +169,21 @@ nsProfiler::GetFeatures(PRUint32 *aCount, char ***aFeatures)
|
|||
*aCount = len;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfiler::EnterProfileLabel(const char *aLabel)
|
||||
{
|
||||
if (!aLebel)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mozilla_sampler_call_enter(aLabel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProfiler::ExitProfileLabel()
|
||||
{
|
||||
mozilla_sampler_call_exit_no_handle();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -277,6 +277,25 @@ inline void mozilla_sampler_call_exit(void *aHandle)
|
|||
stack->pop();
|
||||
}
|
||||
|
||||
inline void mozilla_sampler_call_exit_no_handle()
|
||||
{
|
||||
// check if we've been initialized to avoid calling pthread_getspecific
|
||||
// with a null tlsStack which will return undefined results.
|
||||
if (!stack_key_initialized)
|
||||
return;
|
||||
|
||||
ProfileStack *stack = tlsStack.get();
|
||||
// we can't infer whether 'stack' has been initialized
|
||||
// based on the value of stack_key_intiailized because
|
||||
// 'stack' is only intialized when a thread is being
|
||||
// profiled.
|
||||
if (!stack) {
|
||||
return;
|
||||
}
|
||||
|
||||
stack->pop();
|
||||
}
|
||||
|
||||
inline void mozilla_sampler_add_marker(const char *aMarker)
|
||||
{
|
||||
ProfileStack *stack = tlsStack.get();
|
||||
|
|
Загрузка…
Ссылка в новой задаче