Commit e4f53f8a authored by timothy@apple.com's avatar timothy@apple.com

Fixes a bug in the profiler where call and apply would show up

and double the time spent in a function. We don't want to show call
and apply at all in the profiles. This change excludes them.

Reviewed by Kevin McCullough.

* profiler/ProfileNode.cpp:
(KJS::ProfileNode::stopProfiling): Remove a second for loop and
calculate self time in the existing loop.
* profiler/Profiler.cpp:
(KJS::shouldExcludeFunction): Helper inline function that returns
true in the current function in an InternalFunctionImp and it is
has the functionName call or apply.
(KJS::Profiler::willExecute): Call shouldExcludeFunction and return
early if if returns true.
(KJS::Profiler::didExecute): Ditto.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33928 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 96ad88ab
2008-05-19 Timothy Hatcher <timothy@apple.com>
Fixes a bug in the profiler where call and apply would show up
and double the time spent in a function. We don't want to show call
and apply at all in the profiles. This change excludes them.
Reviewed by Kevin McCullough.
* profiler/ProfileNode.cpp:
(KJS::ProfileNode::stopProfiling): Remove a second for loop and
calculate self time in the existing loop.
* profiler/Profiler.cpp:
(KJS::shouldExcludeFunction): Helper inline function that returns
true in the current function in an InternalFunctionImp and it is
has the functionName call or apply.
(KJS::Profiler::willExecute): Call shouldExcludeFunction and return
early if if returns true.
(KJS::Profiler::didExecute): Ditto.
2008-05-19 Kevin McCullough <kmccullough@apple.com>
Reviewed by Tim.
......
......@@ -96,13 +96,15 @@ void ProfileNode::stopProfiling()
if (m_startTime)
endAndRecordCall();
StackIterator endOfChildren = m_children.end();
for (StackIterator it = m_children.begin(); it != endOfChildren; ++it)
(*it)->stopProfiling();
ASSERT(m_selfTime == 0.0);
// Calculate Self time and the percentages once we stop profiling.
for (StackIterator currentChild = m_children.begin(); currentChild != m_children.end(); ++currentChild)
StackIterator endOfChildren = m_children.end();
for (StackIterator currentChild = m_children.begin(); currentChild != endOfChildren; ++currentChild) {
(*currentChild)->stopProfiling();
m_selfTime += (*currentChild)->totalTime();
}
ASSERT(m_selfTime <= m_totalTime);
m_selfTime = m_totalTime - m_selfTime;
......
......@@ -81,11 +81,26 @@ void Profiler::stopProfiling()
m_currentProfile = 0;
}
static inline bool shouldExcludeFunction(ExecState* exec, JSObject* calledFunction)
{
if (!calledFunction->inherits(&InternalFunctionImp::info))
return false;
// Don't record a call for function.call and function.apply.
if (static_cast<InternalFunctionImp*>(calledFunction)->functionName() == exec->propertyNames().call)
return true;
if (static_cast<InternalFunctionImp*>(calledFunction)->functionName() == exec->propertyNames().apply)
return true;
return false;
}
void Profiler::willExecute(ExecState* exec, JSObject* calledFunction)
{
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
if (shouldExcludeFunction(exec, calledFunction))
return;
Vector<UString> callStackNames;
getStackNames(callStackNames, exec, calledFunction);
m_currentProfile->willExecute(callStackNames);
......@@ -106,6 +121,9 @@ void Profiler::didExecute(ExecState* exec, JSObject* calledFunction)
if (!m_profiling || exec->lexicalGlobalObject()->pageGroupIdentifier() != m_pageGroupIdentifier)
return;
if (shouldExcludeFunction(exec, calledFunction))
return;
Vector<UString> callStackNames;
getStackNames(callStackNames, exec, calledFunction);
m_currentProfile->didExecute(callStackNames);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment