Commit 9c50c73f authored by kmccullough@apple.com's avatar kmccullough@apple.com

2008-06-24 Kevin McCullough <kmccullough@apple.com>

        Reviewed by Tim.

        <rdar://problem/6031594> JSProfiler: Profiler goes into an infinite
        loop sometimes.
        <rdar://problem/6031603> JSProfiler: Profiler asserts in debug and
        give the wrong times in release

        Fixed two issues found by Tim in the same test.

        * profiler/Profile.cpp:
        (KJS::Profile::removeProfileStart): No longer take profile's time from
        all ancestors, but instead attribute it to its parent.  Also add an
        Assert to ensure we only delete the child we mean to.
        (KJS::Profile::removeProfileEnd): Ditto for profileEnd.
        (KJS::Profile::didExecute): Cleaned up the execution order and correctly
        attribute all of the parent's time to the new node.
        * profiler/ProfileNode.cpp: If this node does not have a startTime it
        should not get a giant total time, but instead be 0.
        (KJS::ProfileNode::endAndRecordCall):
        * profiler/ProfileNode.h:
        (KJS::ProfileNode::removeChild): Should reset the sibling pointers since
        one of them has been removed.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34778 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3301ed8d
2008-06-24 Kevin McCullough <kmccullough@apple.com>
Reviewed by Tim.
<rdar://problem/6031594> JSProfiler: Profiler goes into an infinite
loop sometimes.
<rdar://problem/6031603> JSProfiler: Profiler asserts in debug and
give the wrong times in release
Fixed two issues found by Tim in the same test.
* profiler/Profile.cpp:
(KJS::Profile::removeProfileStart): No longer take profile's time from
all ancestors, but instead attribute it to its parent. Also add an
Assert to ensure we only delete the child we mean to.
(KJS::Profile::removeProfileEnd): Ditto for profileEnd.
(KJS::Profile::didExecute): Cleaned up the execution order and correctly
attribute all of the parent's time to the new node.
* profiler/ProfileNode.cpp: If this node does not have a startTime it
should not get a giant total time, but instead be 0.
(KJS::ProfileNode::endAndRecordCall):
* profiler/ProfileNode.h:
(KJS::ProfileNode::removeChild): Should reset the sibling pointers since
one of them has been removed.
2008-06-24 Oliver Hunt <oliver@apple.com>
Reviewed by Cameron.
......
......@@ -99,9 +99,10 @@ void Profile::removeProfileStart() {
if (currentNode->callIdentifier().name != "profile")
return;
for (ProfileNode* currentParent = currentNode->parent(); currentParent; currentParent = currentParent->parent())
currentParent->setTotalTime(currentParent->totalTime() - currentNode->totalTime());
// Attribute the time of the node aobut to be removed to the self time of its parent
currentNode->parent()->setSelfTime(currentNode->parent()->selfTime() + currentNode->totalTime());
ASSERT(currentNode->callIdentifier() == (currentNode->parent()->children()[0])->callIdentifier());
currentNode->parent()->removeChild(0);
}
......@@ -114,9 +115,10 @@ void Profile::removeProfileEnd() {
if (currentNode->callIdentifier().name != "profileEnd")
return;
for (ProfileNode* currentParent = currentNode->parent(); currentParent; currentParent = currentParent->parent())
currentParent->setTotalTime(currentParent->totalTime() - currentNode->totalTime());
// Attribute the time of the node aobut to be removed to the self time of its parent
currentNode->parent()->setSelfTime(currentNode->parent()->selfTime() + currentNode->totalTime());
ASSERT(currentNode->callIdentifier() == (currentNode->parent()->children()[currentNode->parent()->children().size() - 1])->callIdentifier());
currentNode->parent()->removeChild(currentNode->parent()->children().size() - 1);
}
......@@ -138,15 +140,15 @@ void Profile::didExecute(const CallIdentifier& callIdentifier)
m_currentNode = ProfileNode::create(callIdentifier, m_head.get(), m_head.get());
m_currentNode->setStartTime(m_head->startTime());
m_currentNode->didExecute();
m_head->insertNode(m_currentNode.get());
if (m_stoppedProfiling) {
m_currentNode->setTotalTime(m_currentNode->totalTime() + m_head->selfTime());
m_currentNode->setTotalTime(m_head->totalTime());
m_currentNode->setSelfTime(m_head->selfTime());
m_head->setSelfTime(0.0);
m_currentNode->stopProfiling();
m_currentNode = 0;
} else
m_currentNode = m_head;
}
m_head->insertNode(m_currentNode.release());
m_currentNode = m_stoppedProfiling ? 0 : m_head;
return;
}
......
......@@ -228,7 +228,7 @@ void ProfileNode::restore()
void ProfileNode::endAndRecordCall()
{
m_actualTotalTime += getCount() - m_startTime;
m_actualTotalTime += m_startTime ? getCount() - m_startTime : 0.0;
m_startTime = 0.0;
++m_numberOfCalls;
......
......@@ -108,7 +108,7 @@ namespace KJS {
const Vector<RefPtr<ProfileNode> >& children() const { return m_children; }
ProfileNode* firstChild() const { return m_children.size() ? m_children.first().get() : 0; }
ProfileNode* lastChild() const { return m_children.size() ? m_children.last().get() : 0; }
void removeChild(unsigned index) { m_children.remove(index); }
void removeChild(unsigned index) { m_children.remove(index); resetChildrensSiblings(); }
void addChild(PassRefPtr<ProfileNode> prpChild);
void insertNode(PassRefPtr<ProfileNode> prpNode);
......
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